Created
November 22, 2011 19:40
-
-
Save ingenieroariel/1386686 to your computer and use it in GitHub Desktop.
Make all maps and layers private in a GeoNode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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