From: <al...@us...> - 2009-11-13 00:33:18
|
Revision: 13038 http://translate.svn.sourceforge.net/translate/?rev=13038&view=rev Author: alaaosh Date: 2009-11-13 00:33:12 +0000 (Fri, 13 Nov 2009) Log Message: ----------- a function to check permissions properly without having access to a request object Modified Paths: -------------- src/trunk/Pootle/local_apps/pootle_app/models/permissions.py Modified: src/trunk/Pootle/local_apps/pootle_app/models/permissions.py =================================================================== --- src/trunk/Pootle/local_apps/pootle_app/models/permissions.py 2009-11-13 00:32:21 UTC (rev 13037) +++ src/trunk/Pootle/local_apps/pootle_app/models/permissions.py 2009-11-13 00:33:12 UTC (rev 13038) @@ -107,6 +107,14 @@ cached_permission_set.save() return permissions + +def check_profile_permission(profile, permission_codename, directory): + """it checks if current user has the permission the perform C{permission_codename}""" + if profile.user.is_superuser: + return True + permissions = get_matching_permissions(profile, directory) + return permission_codename in permissions + def check_permission(permission_codename, request): """it checks if current user has the permission the perform C{permission_codename}""" if request.user.is_superuser: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |