vida wrote:
> After reading the docs and looking for posts relating this problem
> here and in .developers, I found no "standard" way of checking for a
> user's group permissions in the templates.
> 
> So what I did is to add the following method to auth.models.User
> (yeah, yeah, it *should* be in appname.models.UserProfile):
> 
> def group_permissions(self):
>     class GroupPermissions:
>         def __init__(self, permissions):
>             for perm in permissions:
>                 setattr(self, perm, True)
> 
>         def __str__(self):
>             return 'The user belongs to the following groups: %s' % \
>                 ', '.join([k for k, v in self.__dict__.iteritems()])
> 
>     return GroupPermissions(self.get_group_permissions())
> 
> 
> which lets me write something like the following in my templates:
> {% if user.group_permissions.permission_name %} draw custom menues for
> this particular group here {% endif %}
> 
> So, is there already a way to do this and I missed it? If not, given
> that it is apparently not advisable (is it?) to extend the
> auth.models.User class, how about we add it?

maybe i'm missing something here, but is it really important for you to 
use only through-a-group gained permissions?

isn't it enough to simply check for the given permission?
because if it's enough, then simply use the "perms" variable in the 
templates.


gabor

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to