I may have a similar post to this that was submitted accidentally as I
fat-fingered a key.  Sorry about that.

I'm having a bit of confusion as to how to best approach the display
of edit/delete/create links in my templates as my application needs
this to be based on group permissions OR cascading object owenership.

The situation is I have two models with a FK relationship and each has
a method to check if a user is the owner of that object or it's parent
object.

class Project(models.Model):
    owner = models.ForeignKey(User)

   def is_owner(self, user):
        if user == self.owner:
            return True
        return False
    ...

class Release(models.Model):
    owner = models.ForeignKey(User)

    def is_owner(self, user):
        if user == self.owner:
            return True
        if self.project_fk.is_owner(user):
            return True
        return False
    ....

For permission checking in my views this was pretty straight forward.
I created a decorator called has_perm_or_owner that checks for
particular permissions or if a user is an object owner.

My question is how do I handle similar checks in my templates?

I can easily display a link based on permissions and can even display
them based on weather the logged in user is the owner of a particular
object being edited and such, but how do I get it to use this
cascading check?

Thanks in advance for any help.

--~--~---------~--~----~------------~-------~--~----~
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