Tuesday, January 4, 2011

models queryset and permissions

Hi people, probably I'm making a mountain out of a molehill but I
can't figure
how to solve this problem;

I've a form with a ModelMultipleChoiceField. The queryset will
contains all models for
which the user has a particular permission
(django.contrib.auth.models.Permission) (can_add).

This is the models.py

class Esame(models.Model):
name = models.CharField(max_length=80)
name_model_referenced = models.CharField(max_length=80)

class Ecg(models.Model):
esame = models.ForeignKey(Esame)
patient = models.ForeignKey(Patient, null=True)

class Ecg_da_sforzo(models.Model):
esame = models.ForeignKey(Esame)
patient = models.ForeignKey(Patient, null=True)

Supposing we have a user Tom which can add an Ecg but not an
Ecg_da_sforzo,
can I use the Django Queryset API to obtaing the correct queryset?
If yes, how can I construct it?

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment