خرید بک لینک

Vote count: 0

I have followed the user guide from the django-guardian docs to set up django-guardian. This has given me the possibility to control whether a group can view a specific class or not. This is the example from the django-guardian docs with an added field (customer):

class Task(models.Model):
    summary = models.CharField(max_length=32)
    content = models.TextField()
    customer = models.CharField(max_length=80)
    reported_by = models.ForeignKey(User)
    created_at = models.DateTimeField(auto_now_add=True)

    class Meta:
        permissions = (
            ('view_task', 'View task'),
        )

This (along with other code from the django-guardian docs example) allows me to give specific users and groups permission to "View Task" through the django admin. The thing is that I would like to restrict which tasks groups can see depending on who the customer is. An example could be that only consultants assigned to customer A can see tasks where task.customer = 'A'. Is there a way to set that up?

Any help is much appreciated.

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 14 تير 1395 ساعت: 8:33

صفحه بندی