Re: Template composition: Rendering based on permissions

2010-04-28 Thread Nick
The bible for user authentication is found here
http://docs.djangoproject.com/en/1.1/topics/auth/

The quick answer to number 2 is to check for authentication in a
template tag:

{% if user.is_authenticated %}
Welcome back you rotten jerk
{% else %}
Log in, you rotten jerk
{% endif %}

On Apr 28, 2:46 pm, Thomas Allen  wrote:
> I think that template context processors are the answer to my first
> question. As for my second question, I could certainly check for
> permission membership in the provided PermWrapper, but I'm very
> interested in a way to check this based on the view permission
> requirement (implicitly).
>
> Thomas
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Template composition: Rendering based on permissions

2010-04-28 Thread Thomas Allen
I think that template context processors are the answer to my first
question. As for my second question, I could certainly check for
permission membership in the provided PermWrapper, but I'm very
interested in a way to check this based on the view permission
requirement (implicitly).

Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Template composition: Rendering based on permissions

2010-04-28 Thread Thomas Allen
Hi everyone,

I have two questions about rendering specific design elements, and the
second ties in somewhat with the first.

How do you make a variable available in multiple views (multiple
templates)? For instance, maybe I want the active user object to be
available on each page so that I can render a link as "Sign Out
(the_username)".

How do you specify the display of a design element based on user
permissions? For instance, a link like that one would display as "Sign
In" and point to the auth login view rather than the logout view if a
user were not logged in. Similarly, I would like to display links only
if the user passes the view in question's @has_permission test.

Thanks,
Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.