Skip to content

Instantly share code, notes, and snippets.

@ingenieroariel
Created November 22, 2011 19:40
Show Gist options
  • Save ingenieroariel/1386686 to your computer and use it in GitHub Desktop.
Save ingenieroariel/1386686 to your computer and use it in GitHub Desktop.
Make all maps and layers private in a GeoNode
from geonode.core.models import AUTHENTICATED_USERS, ANONYMOUS_USERS
def restrict(item):
"""Works with GeoNode Map and Layer objects to disable unauthenticated access.
"""
item.set_gen_level(ANONYMOUS_USERS, item.LEVEL_NONE)
item.set_gen_level(AUTHENTICATED_USERS, item.LEVEL_READ)
def publish(item):
"""Works with GeoNode Map and Layer objects to enable unauthenticated access.
"""
item.set_gen_level(ANONYMOUS_USERS, item.LEVEL_READ)
item.set_gen_level(AUTHENTICATED_USERS, item.LEVEL_ADMIN)
for layer in Layer.objects.all():
restrict(layer)
print 'Restricted ', layer.name
for map in Map.objects.all():
restrict(map)
print 'Restricted ', map.title
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment