Something like this should work...
from django import template
import datetime
class CurrentTimeNode(template.Node):
def __init__(self, format_string):
self.format_string = format_string
def render(self, context):
# apply appropriate permissions for this tag
user = context['user']
if user.has_perm('your_package.your_permission_codename'):
return
datetime.datetime.now().strftime(self.format_string)
else:
return 'You do not have permission to see what time it
is.'
On Oct 21, 4:44 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Simple question: is it possible to access all user permissions in
> template tags just as in regular templates through the {{ perms }}
> context variable or do I need to manually pass the permissions are
> template tag params? By default the perms map does not seem to work in
> tags.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---