diff --git a/geonode/certification/__init__.py b/geonode/certification/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/geonode/certification/fixtures/certification_data.json b/geonode/certification/fixtures/certification_data.json deleted file mode 100755 index 09b09ddd268..00000000000 --- a/geonode/certification/fixtures/certification_data.json +++ /dev/null @@ -1,232 +0,0 @@ -[ - { - "pk": 1, - "model": "auth.user", - "fields": { - "username": "bobby", - "first_name": "", - "last_name": "", - "is_active": true, - "is_superuser": false, - "is_staff": false, - "last_login": "2010-06-10 16:59:13", - "groups": [], - "user_permissions": [], - "password": "sha1$8d019$a84eea3f5093eed93bc68bf62fe400f14042ab06", - "email": "bobby@bob.com", - "date_joined": "2010-06-10 16:58:18" - } - }, - { - "fields": { - "date_joined": "2010-07-20 13:31:27", - "email": "admin@admin.admin", - "first_name": "", - "groups": [], - "is_active": true, - "is_staff": true, - "is_superuser": true, - "last_login": "2010-07-20 17:26:12", - "last_name": "", - "password": "sha1$6c974$de67ee46336cb3b9bb9e90d53863c3a8d01ce944", - "user_permissions": [], - "username": "admin" - }, - "model": "auth.user", - "pk": 2 - }, - { - "fields": { - "typename": "base:CA", - "owner": 1, - "store": "CA", - "name": "CA", - "workspace": "base", - "llbbox" : ["1", "3", "2", "3"], - "srs": "EPSG:4326", - "geographic_bounding_box": "whatever", - "uuid": "254afb8e-5a5f-4c1f-b01b-40af91532298", - "created_dttm": "2010-07-20 13:31:27", - "last_modified": "2010-07-20 13:31:27" - }, - "model": "maps.layer", - "pk": 1 - }, - { - "fields": { - "typename": "base:CA2", - "owner": 1, - "store": "CA2", - "name": "CA2", - "workspace": "base", - "llbbox" : ["10", "30", "20", "30"], - "srs": "EPSG:4326", - "geographic_bounding_box": "whatever2", - "uuid": "254afb8f-5a5f-4c1f-b01b-40af91532298", - "created_dttm": "2013-07-20 13:31:27", - "last_modified": "2013-07-20 13:31:27" - }, - "model": "maps.layer", - "pk": 2 - }, - { - "fields": { - "abstract": "This is a demonstration of GeoNode, an application for assembling and publishing web based maps. After adding layers to the map, use the Save Map button above to contribute your map to the GeoNode community.", - "center_x": -9428760.8701902702, - "center_y": 1427430.7410345681, - "owner": 1, - "projection": "EPSG:900913", - "title": "GeoNode Default Map", - "last_modified": "2010-07-20 13:31:27", - "zoom": 7, - "created_dttm": "2010-07-20 13:31:27" - }, - "model": "maps.map", - "pk": 1 - }, - { - "fields": { - "fixed": false, - "group": "local", - "layer_params": "", - "map": 1, - "name": "base:CA", - "ows_url": "http://localhost:8080/geoserver/wms", - "source_params": "", - "stack_order": 0, - "created_dttm": "2010-07-20 13:31:27", - "last_modified": "2010-07-20 13:31:27" - }, - "model": "maps.maplayer", - "pk": 1 - }, - { - "fields": { - "fixed": false, - "group": "local", - "layer_params": "", - "map": 1, - "name": "base:CA2", - "ows_url": "http://localhost:8080/geoserver/wms", - "source_params": "", - "stack_order": 0, - "created_dttm": "2010-07-20 13:31:27", - "last_modified": "2010-07-20 13:31:27" - }, - "model": "maps.maplayer", - "pk": 2 - }, - { - "fields": { - "fixed": true, - "format": null, - "group": "background", - "layer_params": "{\"args\": [\"base:CA\", \"http://localhost:8001/geoserver/wms\", {\"layers\": [\"base:CA\"], \"tiled\": true, \"tilesOrigin\": [-20037508.34, -20037508.34], \"format\": \"image/png\"}, {\"buffer\": 0}], \"type\": \"OpenLayers.Layer.WMS\"}", - "map": 1, - "name": null, - "opacity": 1, - "ows_url": null, - "source_params": "{\"ptype\": \"gx_olsource\"}", - "stack_order": 1, - "styles": null, - "transparent": false, - "visibility": false, - "created_dttm": "2010-07-20 13:31:27", - "last_modified": "2010-07-20 13:31:27" - }, - "model": "maps.maplayer", - "pk": 3 - }, - { - "fields": { - "fixed": true, - "format": null, - "group": "background", - "layer_params": "{}", - "map": 1, - "name": "SATELLITE", - "opacity": 1, - "ows_url": null, - "source_params": "{\"apiKey\": \"ABQIAAAAkofooZxTfcCv9Wi3zzGTVxTnme5EwnLVtEDGnh-lFVzRJhbdQhQgAhB1eT_2muZtc0dl-ZSWrtzmrw\", \"ptype\": \"gx_googlesource\"}", - "stack_order": 2, - "styles": null, - "transparent": false, - "visibility": false, - "created_dttm": "2010-07-20 13:31:27", - "last_modified": "2010-07-20 13:31:27" - }, - "model": "maps.maplayer", - "pk": 4 - }, - { - "fields": { - "fixed": true, - "format": null, - "group": "background", - "layer_params": "{\"args\": [\"No background\"], \"type\": \"OpenLayers.Layer\"}", - "map": 1, - "name": null, - "opacity": 1, - "ows_url": null, - "source_params": "{\"ptype\": \"gx_olsource\"}", - "stack_order": 3, - "styles": null, - "transparent": false, - "visibility": false, - "created_dttm": "2010-07-20 13:31:27", - "last_modified": "2010-07-20 13:31:27" - }, - "model": "maps.maplayer", - "pk": 5 - }, - { - "fields": { - "subject": "anonymous", - "object_ct": ["maps", "map"], - "object_id": 1, - "role": ["map_readonly", "maps", "map"] - }, - "model": "core.genericobjectrolemapping", - "pk": 1 - }, - { - "fields": { - "subject": "authenticated", - "object_ct": ["maps", "map"], - "object_id": 1, - "role": ["map_readwrite", "maps", "map"] - }, - "model": "core.genericobjectrolemapping", - "pk": 2 - }, - { - "fields": { - "subject": "anonymous", - "object_ct": ["maps", "layer"], - "object_id": 1, - "role": ["layer_readonly", "maps", "layer"] - }, - "model": "core.genericobjectrolemapping", - "pk": 3 - }, - { - "fields": { - "subject": "authenticated", - "object_ct": ["maps", "layer"], - "object_id": 1, - "role": ["layer_readonly", "maps", "layer"] - }, - "model": "core.genericobjectrolemapping", - "pk": 4 - }, - { - "fields": { - "user": 1, - "object_ct": ["maps", "layer"], - "object_id": 1, - "role": ["layer_readwrite", "maps", "layer"] - }, - "model": "core.userobjectrolemapping", - "pk": 1 - } -] diff --git a/geonode/certification/migrations/0001_initial.py b/geonode/certification/migrations/0001_initial.py deleted file mode 100644 index 0da6d5adde6..00000000000 --- a/geonode/certification/migrations/0001_initial.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models -from django.conf import settings - - -class Migration(migrations.Migration): - - dependencies = [ - ('contenttypes', '0002_remove_content_type_name'), - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ] - - operations = [ - migrations.CreateModel( - name='Certification', - fields=[ - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), - ('object_id', models.PositiveIntegerField()), - ('certifier', models.ForeignKey(to=settings.AUTH_USER_MODEL)), - ('object_ct', models.ForeignKey(to='contenttypes.ContentType')), - ], - ), - ] diff --git a/geonode/certification/migrations/__init__.py b/geonode/certification/migrations/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/geonode/certification/models.py b/geonode/certification/models.py deleted file mode 100644 index 6ca8bddadad..00000000000 --- a/geonode/certification/models.py +++ /dev/null @@ -1,70 +0,0 @@ -from django.db import models -from geonode.people.models import Profile -from django.contrib.contenttypes.models import ContentType -from django.contrib.contenttypes.generic import GenericForeignKey -from geonode.maps.models import Map -from geonode.layers.models import Layer -from django.db.models import signals - -# Create your models here. - -class CertificationManager(models.Manager): - - def certify(self, user, model): - """ - Create a certification for a particular map/layer and user - """ - - my_ct = ContentType.objects.get_for_model(model) - certification, created = Certification.objects.get_or_create(certifier=user, object_ct = my_ct, object_id = model.id) - if created: - certification.save() - return certification - - def uncertify(self,user,model): - """ - Delete a certification for a particular map/layer and user - """ - my_ct = ContentType.objects.get_for_model(model) - try: - Certification.objects.get(certifier=user, object_ct = my_ct, object_id = model.id).delete() - except: - pass - - def is_certified(self,user,model_obj): - """ - Return a boolean indicating whether a model object has been certified by a user - """ - if not user.id: - return False - my_ct = ContentType.objects.get_for_model(model_obj) - return bool(Certification.objects.filter(certifier=user, object_ct = my_ct, object_id = model_obj.id)) - - - def certifications_user (self, user): - return Certification.objects.filter(certifier=user) - - def certifications_object (self, model_obj): - my_ct = ContentType.objects.get_for_model(model_obj) - return Certification.objects.filter(object_ct = my_ct, object_id= model_obj.id) - - - -class Certification (models.Model): - certifier = models.ForeignKey(Profile) - object_ct = models.ForeignKey(ContentType) - object_id = models.PositiveIntegerField() - object = GenericForeignKey('object_ct', 'object_id') - - objects = CertificationManager() - - - -def delete_certification(instance, sender, **kwargs): - my_ct = ContentType.objects.get_for_model(instance) - certifications = Certification.objects.filter(object_ct = my_ct, object_id= instance.id) - for certification in certifications: - certification.delete() - -signals.post_delete.connect(delete_certification, sender=Layer) -signals.post_delete.connect(delete_certification, sender=Map) diff --git a/geonode/certification/templates/certification/certification_add.html b/geonode/certification/templates/certification/certification_add.html deleted file mode 100644 index 6896b637174..00000000000 --- a/geonode/certification/templates/certification/certification_add.html +++ /dev/null @@ -1,37 +0,0 @@ -{% extends "site_base.html" %} -{% load i18n %} - -{% block title %} {{ title }} - {{ block.super }} {% endblock %} -{% block head %} - -{{ block.super }} - -{% endblock %} - -{% block body %} - -

{% trans "Are you sure you want to certify" %} {{title}}?

-
- {% csrf_token %} - -
-
- -
- - -{% endblock %} diff --git a/geonode/certification/templates/certification/certification_remove.html b/geonode/certification/templates/certification/certification_remove.html deleted file mode 100644 index 63081fbb926..00000000000 --- a/geonode/certification/templates/certification/certification_remove.html +++ /dev/null @@ -1,39 +0,0 @@ -{% extends "site_base.html" %} -{% load i18n %} - -{% block title %} {{ title }} - {{ block.super }} {% endblock %} - - -{% block head %} - -{{ block.super }} - -{% endblock %} - - -{% block body %} - -

{% trans "Are you sure you want to uncertify" %} {{title}}?

-
- {% csrf_token %} - -
-
- -
- -{% endblock %} diff --git a/geonode/certification/templatetags/__init__.py b/geonode/certification/templatetags/__init__.py deleted file mode 100755 index 792d6005489..00000000000 --- a/geonode/certification/templatetags/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# diff --git a/geonode/certification/templatetags/certified.py b/geonode/certification/templatetags/certified.py deleted file mode 100644 index 7893497e57b..00000000000 --- a/geonode/certification/templatetags/certified.py +++ /dev/null @@ -1,63 +0,0 @@ -from django import template -from geonode.certification.models import Certification -register = template.Library() - -class IsCertifiedNode(template.Node): - def __init__(self, user, obj, varname): - self.user = template.Variable(user) - self.obj = template.Variable(obj) - self.varname = varname - - def render(self, context): - user = self.user.resolve(context) - obj = self.obj.resolve(context) - context[self.varname] = Certification.objects.is_certified(user=user, model_obj=obj) - return '' - -class ObjectCertificationsNode(template.Node): - def __init__(self, obj, varname): - self.obj = template.Variable(obj) - self.varname = varname - - def render(self, context): - obj = self.obj.resolve(context) - context[self.varname] = Certification.objects.certifications_object(model_obj=obj) - return '' - -class UserCertificationsNode(template.Node): - def __init__(self, user, varname): - self.user = template.Variable(user) - self.varname = varname - - def render(self, context): - user = self.user.resolve(context) - context[self.varname] = Certification.objects.certifications_user(user=user) - return '' - -def _check_quoted(string): - return string[0] == '"' and string[-1] == '"' - -@register.tag('is_certified') -def is_certified(parser, token): - """ - {% is_certified user obj as certified %} - """ - args = token.split_contents()[1:] - return IsCertifiedNode(args[0], args[1], args[3]) - - -@register.tag('object_certifications') -def object_certifications(parser, token): - """ - {% is_certified user obj as certified %} - """ - args = token.split_contents()[1:] - return ObjectCertificationsNode(args[0], args[2]) - -@register.tag('user_certifications') -def user_certifications(parser, token): - """ - {% is_certified user obj as certified %} - """ - args = token.split_contents()[1:] - return UserCertificationsNode(args[0], args[2]) diff --git a/geonode/certification/tests.py b/geonode/certification/tests.py deleted file mode 100644 index 4e42c323c4d..00000000000 --- a/geonode/certification/tests.py +++ /dev/null @@ -1,97 +0,0 @@ -from django.contrib.contenttypes.models import ContentType - -from django.test import TestCase -from django.contrib.auth.models import User -from geonode.maps.models import Map, Layer -from geonode.certification.models import Certification - - -class CertificationTest(TestCase): - fixtures = ['certification_data.json'] - - def test_certify_map(self): - """ - Tests creation, removal, and retrieval of map certifications - """ - user_obj = User.objects.get(id=1) - map_obj = Map.objects.get(id=1) - obj_type = ContentType.objects.get_for_model(map_obj) - newcert = Certification.objects.certify(user_obj,map_obj) - - # Verify that the certification is for the correct model type (map) - self.assertEquals(obj_type, newcert.object_ct) - - # Verify that the certification is for the correct map id - self.assertEquals(map_obj.id, newcert.object_id) - - # Verify that there is only 1 certification for this map - self.assertEquals(1, len(Certification.objects.filter(object_ct=obj_type, object_id=map_obj.id))) - - #Verify that the is_certified methods returns true for this map & user - self.assertTrue(Certification.objects.is_certified(user_obj,map_obj)) - - #Verify that the certifications_object methods returns 1 cert. for this map - self.assertEquals(1, len(Certification.objects.certifications_object(map_obj))) - - #Create another certification for this map Verify that certifications_object returns 2 certs. - Certification.objects.certify(User.objects.get(id=2),map_obj) - self.assertEquals(2, len(Certification.objects.certifications_object(map_obj))) - - #Verify that the certifications_user method returns 1 cert. - self.assertEquals(1, len(Certification.objects.certifications_user(user_obj))) - - #Remove user 1 certifications and verify that methods return correct results - Certification.objects.uncertify(user_obj,map_obj) - self.assertEquals(1, len(Certification.objects.certifications_object(map_obj))) - self.assertFalse(Certification.objects.is_certified(user_obj,map_obj)) - self.assertEquals(0, len(Certification.objects.certifications_user(user_obj))) - - #Remove user 2 certifications and verify that methods return correct results - Certification.objects.uncertify(User.objects.get(id=2),map_obj) - self.assertEquals(0, len(Certification.objects.certifications_object(map_obj))) - self.assertFalse(Certification.objects.is_certified(User.objects.get(id=2),map_obj)) - self.assertEquals(0, len(Certification.objects.certifications_user(User.objects.get(id=2)))) - - - def test_certify_layer(self): - """ - Tests creation, removal, and retrieval of layer certifications - """ - user_obj = User.objects.get(id=1) - layer_obj = Layer.objects.get(id=1) - obj_type = ContentType.objects.get_for_model(layer_obj) - newcert = Certification.objects.certify(user_obj,layer_obj) - - # Verify that the certification is for the correct model type (layer) - self.assertEquals(obj_type, newcert.object_ct) - - # Verify that the certification is for the correct layer id - self.assertEquals(layer_obj.id, newcert.object_id) - - # Verify that there is only 1 certification for this layer - self.assertEquals(1, len(Certification.objects.filter(object_ct=obj_type, object_id=layer_obj.id))) - - #Verify that the is_certified methods returns true for this layer & user - self.assertTrue(Certification.objects.is_certified(user_obj,layer_obj)) - - #Verify that the certifications_object methods returns 1 cert. for this layer - self.assertEquals(1, len(Certification.objects.certifications_object(layer_obj))) - - #Create another certification for this layer Verify that certifications_object returns 2 certs. - Certification.objects.certify(User.objects.get(id=2),layer_obj) - self.assertEquals(2, len(Certification.objects.certifications_object(layer_obj))) - - #Verify that the certifications_user method returns 1 cert. - self.assertEquals(1, len(Certification.objects.certifications_user(user_obj))) - - #Remove user 1 certifications and verify that methods return correct results - Certification.objects.uncertify(user_obj,layer_obj) - self.assertEquals(1, len(Certification.objects.certifications_object(layer_obj))) - self.assertFalse(Certification.objects.is_certified(user_obj,layer_obj)) - self.assertEquals(0, len(Certification.objects.certifications_user(user_obj))) - - #Remove user 2 certifications and verify that methods return correct results - Certification.objects.uncertify(User.objects.get(id=2),layer_obj) - self.assertEquals(0, len(Certification.objects.certifications_object(layer_obj))) - self.assertFalse(Certification.objects.is_certified(User.objects.get(id=2),layer_obj)) - self.assertEquals(0, len(Certification.objects.certifications_user(User.objects.get(id=2)))) diff --git a/geonode/certification/urls.py b/geonode/certification/urls.py deleted file mode 100644 index db55bc9af01..00000000000 --- a/geonode/certification/urls.py +++ /dev/null @@ -1,7 +0,0 @@ -from django.conf import settings -from geonode.proxy.urls import urlpatterns as proxy_urlpatterns -from django.conf.urls import patterns, url -urlpatterns = patterns('geonode.certification.views', - url(r'^(?P[a-zA-Z\.]+)/(?P\d+)/certify/?$', 'certify', name="certify"), - url(r'^(?P[a-zA-Z\.]+)/(?P\d+)/uncertify/?$', 'uncertify', name="uncertify"), -) diff --git a/geonode/certification/views.py b/geonode/certification/views.py deleted file mode 100644 index fecc3e8798a..00000000000 --- a/geonode/certification/views.py +++ /dev/null @@ -1,58 +0,0 @@ -# Create your views here. -from django.db.models.loading import get_model -from geonode.certification.models import Certification -from django.http import HttpResponse, HttpResponseRedirect -from django.shortcuts import render_to_response, get_object_or_404 -from django.template import RequestContext -from django.contrib.auth.decorators import login_required - -@login_required -def uncertify(request, modelid, modeltype): - ''' Delete a certification ''' - - model = get_model(*modeltype.split('.',1)) - model_obj = model.objects.get(pk=modelid) - - model_title = modelid - - if hasattr(model_obj, 'title'): - model_title = model_obj.title - - if request.method == 'GET': - return render_to_response("certification/certification_remove.html", RequestContext(request, { - "modeltype": modeltype, - "modelid": modelid, - "title": model_title - })) - elif request.method == 'POST': - certification = Certification.objects.uncertify(request.user,model_obj) - redirecturl = model_obj.get_absolute_url() - if modeltype == "maps.Map": - redirecturl = model_obj.get_absolute_url() + "/info" - return HttpResponseRedirect(redirecturl) - -@login_required -def certify(request, modeltype, modelid): - ''' Certify a map or layer''' - model = get_model(*modeltype.split('.',1)) - model_obj = model.objects.get(pk=modelid) - - model_title = modelid - - if hasattr(model_obj, 'title'): - model_title = model_obj.title - - if request.method == 'GET': - return render_to_response("certification/certification_add.html", RequestContext(request, { - "modeltype": modeltype, - "modelid": modelid, - "title": model_title - })) - elif request.method == 'POST': - certification = Certification.objects.certify(request.user,model_obj) - redirecturl = model_obj.get_absolute_url() - if modeltype == "maps.Map": - redirecturl = model_obj.get_absolute_url() + "/info" - return HttpResponseRedirect(redirecturl) - - \ No newline at end of file diff --git a/geonode/settings.py b/geonode/settings.py index eb790fa3797..1fff1329187 100644 --- a/geonode/settings.py +++ b/geonode/settings.py @@ -281,7 +281,6 @@ 'geonode.geoserver', 'geonode.upload', 'geonode.tasks', - #'geonode.certification', )