Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Jan. 4, 2011 12:02:37

M.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

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-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Jan. 4, 2011 12:06:57

M.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

models queryset and permissions


The ModelMultipleChoicheField will return Esame objects

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Jan. 5, 2011 09:13:54

D.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

models queryset and permissions


Esame:
name = models.Foreignkey(User)
...

Then queryset=Esame.name.get_rows_with_permission(Ecg(),'add')

On 1月4日, 下午8时02分, MarcoS <marc.se...@gmail.com> wrote:
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#4 Jan. 5, 2011 10:04:29

M.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

models queryset and permissions


Hi Danfi, thanks for your reply.
This help me!

On 5 Gen, 10:06, Danfi <tda...@gmail.com> wrote:
> Esame:
> name = models.Foreignkey(User)
> ...
>
> Then queryset=Esame.name.get_rows_with_permission(Ecg(),'add')
>
> On 1月4日, 下午8时02分, MarcoS <marc.se...@gmail.com> wrote:
>
> > 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-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 21st of October
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support