Don't works for me :'(

El lunes, 1 de septiembre de 2014 12:07:19 UTC-5, Collin Anderson escribió:
>
> > Can't create other users
> > Can't create other topics or subtopics
> These can be done using built in permissions and groups
>
> Something like this might work for the rest:
>
> class NewsAdmin(models.Model):
>
>     def get_queryset(self, request):
>         queryset = super(NewsAdmin, self).get_queryset(request):
>         if request.user.groups.filter(name="Author").exist():  # is the 
> user an author?
>              queryset = queryset.filter(author=self.user)  # only allow 
> users to edit their own posts
>         return queryset
>
>     def get_readonly_fields(self, request, obj=None):
>         readonly_fields = super(NewsAdmin, self).get_readonly_field(
> request, obj)
>         if request.user.groups.filter(name="Author").exist():  # is the 
> user an author?
>             readonly_fields += ['published']  # don't allow authors to 
> change the publish status
>         return readonly_fields
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/16b7bc84-1ef7-407e-a6c1-14d07fe1de83%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to