Great idea, I'll do that.

Thanks!

Kevin

On Feb 23, 11:30 am, Daniel Roseman <roseman.dan...@googlemail.com>
wrote:
> On Feb 23, 7:19 pm, Kevin Audleman <kevin.audle...@gmail.com> wrote:
>
>
>
> > Hello,
>
> > I am using the excellent django-profiles module provided by
> > Ubernostrum which gives my site the following views:
>
> > - list members
> > - view member
> > - edit member
>
> > The module handles all of the views and urls so basically all I had to
> > do was write templates and put a slug into my urls.py.
>
> > The requirements for my site are that all of these pages require a
> > login. However the module only adds the @login_required decorator to
> > the edit page and leaves the list members and edit members views
> > public.
>
> > How do I add a login check to the other two views? A couple of not
> > great options I've though of are:
>
> > 1. Copy and paste the views to my own module and add the decorator
> > myself. Bad because I've overridden core functionality of a module.
> > 2. Handle permissions at the template level. Not ideal because the
> > rest of my site handles it at the view level and I don't want to mix
> > techniques.
>
> > Is there another, simpler way of doing it?
>
> > Thanks,
> > Kevin Audleman
>
> The best way would be to wrap the views in other function in your own
> module. Your views would take the same parameters as the original
> ones, and would simply call the originals and return whatever they
> returned. The URLs would point to your views, rather than the
> originals.
>
> from django_profiles import list_members
>
> @login_required
> def my_list_members(request, params):
>     return list_members(request, params)
>
> Obviously, using the right parameters in each case.
> --
> DR.
--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to