Re: Passenger 57 - a Django query problem

2010-02-21 Thread derek
First off - my apologies to all who have replied so diligently without
so much as a "hi" from me before now...  soon after posting this I
fell ill and did not have an opportunity to reply.

Second; I posted this same message three days ago and for some unknown
reason, it did not show up on the mailing list (?).

Finally, thanks to Emily and Bruno for supplying suggestions and
having to make educated guesses or do crystal-ball gazing... apologies
for not phrasing or constructing my original question very clearly.

Now back to the problem...

This _is_ a somewhat artificially constructed problem as I am trying
to get a bearing on how to do this in my actual code, without getting
bogged down in all its nuances.  Nonetheless, this is a very good
parallel to the situation I am dealing with.

I am not trying to calculate an _actual_ discount here (although the
code supplied by Emily may be helpful at some point) - rather I am
trying to figure how to ask a question (i.e write a query) that has a
True/False answer - which I would state loosely in English "does this
qualify for a discount"? or, more explicitly "does the Passenger's
membership of (one or more) Alliances match any of the Airline's
membership of (one or more) Alliances"?

To expand further:

Case 1: If Passenger 57 has membership of Alliance==Pacific and
Alliance==European, then according to the situation postulated above
the answer should be "False".
Case 2: If, however, Passenger 57 has membership of Alliance==Pacific
and Alliance==Star, then the answer would be "True" (because AIA also
has membership of Alliance==Star).

I was hoping there would be a simple "one liner" that could give this
result... I am more looking for guidance in how to do this kind of
querying with the Django ORM rather than help with model or database
construction.

Thanks again - I will try and clarify more quickly in future.

Derek

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-21 Thread Sithembewena Lloyd Dube
Thank you everybody. Chapter closed.

On Sun, Feb 21, 2010 at 4:11 AM, Steven Elliott Jr
wrote:

> I've always found both the Django and Python communities to be among the
> friendliest and most helpful. Please be kind to one another and respectful
> of everyones comments. We are here to support one another in our efforts to
> better our django skills and to better the community and project as a whole.
> Let's not start bickering amongst ourselves...
>
> Best,
> Steven Elliott
>
> Sent from my iPhone
>
>
> On Feb 20, 2010, at 7:19 PM, Russell Keith-Magee 
> wrote:
>
>  On Sun, Feb 21, 2010 at 4:11 AM, Sithembewena Lloyd Dube
>>  wrote:
>>
>>> I wonder what Atamert the peacemaker has to say now, since the person to
>>> whose defense he came admitted he was wrong. Amazing to note that Atamert
>>> noticed my directness to Bruno, but did not notice how nasty Bruno was to
>>> other respondents (namely Emily and Derek).
>>>
>>> What have you to say, o' wise Atamert?
>>>
>>
>> Ok, I'm stepping in here.
>>
>> Emily is right - this sort of tone is *exactly* what we don't want on
>> Django users. Django-users has historically been a very friendly
>> place. I don't want that to change.
>>
>> Bruno; Lloyd; Atamert -  at this point, I don't care who started it.
>> When you wrestle in mud, everyone gets dirty - even the bystanders. So
>> Stop. Now.
>>
>> If you want to have some petty name calling argument, take it somewhere
>> else.
>>
>> If you persist in posting to django-users with anything other than
>> helpful responses to the original question, I will start banning
>> accounts.
>>
>> Yours,
>> Russ Magee %-)
>>
>> --
>> 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 at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
> --
> 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 at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-20 Thread Steven Elliott Jr
I've always found both the Django and Python communities to be among  
the friendliest and most helpful. Please be kind to one another and  
respectful of everyones comments. We are here to support one another  
in our efforts to better our django skills and to better the community  
and project as a whole. Let's not start bickering amongst ourselves...


Best,
Steven Elliott

Sent from my iPhone

On Feb 20, 2010, at 7:19 PM, Russell Keith-Magee  
 wrote:



On Sun, Feb 21, 2010 at 4:11 AM, Sithembewena Lloyd Dube
 wrote:
I wonder what Atamert the peacemaker has to say now, since the  
person to
whose defense he came admitted he was wrong. Amazing to note that  
Atamert
noticed my directness to Bruno, but did not notice how nasty Bruno  
was to

other respondents (namely Emily and Derek).

What have you to say, o' wise Atamert?


Ok, I'm stepping in here.

Emily is right - this sort of tone is *exactly* what we don't want on
Django users. Django-users has historically been a very friendly
place. I don't want that to change.

Bruno; Lloyd; Atamert -  at this point, I don't care who started it.
When you wrestle in mud, everyone gets dirty - even the bystanders. So
Stop. Now.

If you want to have some petty name calling argument, take it  
somewhere else.


If you persist in posting to django-users with anything other than
helpful responses to the original question, I will start banning
accounts.

Yours,
Russ Magee %-)

--
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 at http://groups.google.com/group/django-users?hl=en 
.




--
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-20 Thread Russell Keith-Magee
On Sun, Feb 21, 2010 at 4:11 AM, Sithembewena Lloyd Dube
 wrote:
> I wonder what Atamert the peacemaker has to say now, since the person to
> whose defense he came admitted he was wrong. Amazing to note that Atamert
> noticed my directness to Bruno, but did not notice how nasty Bruno was to
> other respondents (namely Emily and Derek).
>
> What have you to say, o' wise Atamert?

Ok, I'm stepping in here.

Emily is right - this sort of tone is *exactly* what we don't want on
Django users. Django-users has historically been a very friendly
place. I don't want that to change.

Bruno; Lloyd; Atamert -  at this point, I don't care who started it.
When you wrestle in mud, everyone gets dirty - even the bystanders. So
Stop. Now.

If you want to have some petty name calling argument, take it somewhere else.

If you persist in posting to django-users with anything other than
helpful responses to the original question, I will start banning
accounts.

Yours,
Russ Magee %-)

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-20 Thread Sithembewena Lloyd Dube
So, Atamert, Bruno admitted he was wrong. What have you to say??

It's strange that you noticed i was direct with him,but you did not seem to
notice how harsh he was to Emily and Derek??

Anyways, peace..

On Thu, Feb 18, 2010 at 11:25 AM, Atamert Ölçgen  wrote:

> Hi Sithembewena,
>
>
> On Thursday 18 February 2010 00:27:10 Sithembewena Lloyd Dube wrote:
> > Emily provided an answer according to what she understood from the OP. No
> > harm in doing that, at least not worse than no attempt at giving a
> > solution..
> >
> > I think that people who have a problem with posts, even vague ones,
> should
> > stay away from them - let those that would try to help, to do so
> > unhindered..
> >
> > We have no interest in your personal coding style: attempt to help, or
> stay
> > away.
> Bruno is trying to help in his own way. Let's not be unkind to each other
> like
> that.
>
> Also, please use your e-mail app's **draft** feature and send your reply
> when
> it's **done**.
>
>
> --
> Saygılarımla,
> Atamert Ölçgen
>
>  -+-
>  --+
>  +++
>
> www.muhuk.com
> mu...@jabber.org
>
> --
> 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 at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-20 Thread Sithembewena Lloyd Dube
I wonder what Atamert the peacemaker has to say now, since the person to
whose defense he came admitted he was wrong. Amazing to note that Atamert
noticed my directness to Bruno, but did not notice how nasty Bruno was to
other respondents (namely Emily and Derek).

What have you to say, o' wise Atamert?

On Thu, Feb 18, 2010 at 11:25 AM, Atamert Ölçgen  wrote:

> Hi Sithembewena,
>
>
> On Thursday 18 February 2010 00:27:10 Sithembewena Lloyd Dube wrote:
> > Emily provided an answer according to what she understood from the OP. No
> > harm in doing that, at least not worse than no attempt at giving a
> > solution..
> >
> > I think that people who have a problem with posts, even vague ones,
> should
> > stay away from them - let those that would try to help, to do so
> > unhindered..
> >
> > We have no interest in your personal coding style: attempt to help, or
> stay
> > away.
> Bruno is trying to help in his own way. Let's not be unkind to each other
> like
> that.
>
> Also, please use your e-mail app's **draft** feature and send your reply
> when
> it's **done**.
>
>
> --
> Saygılarımla,
> Atamert Ölçgen
>
>  -+-
>  --+
>  +++
>
> www.muhuk.com
> mu...@jabber.org
>
> --
> 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 at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-20 Thread Sithembewena Lloyd Dube
Lol..c'mon Bruno, we just resolved this. Stop attacking Emily. You admitted
in your email to me that you could be, in your own words, an "asshole"
sometimes, that your words were "uselessly harsh", and that Emily was right.
Why come onto the thread and attack her again?

I declare this matter closed: let's all behave like mature grown-ups. This
is not a primary school lunch break where we must eat each other's peanut
butter sandwiches and push the girls around.

Now, hug and make up before you sit in the corner.. [?]


On Fri, Feb 19, 2010 at 10:51 PM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

> On 18 fév, 12:16, Emily Rodgers 
> wrote:
> (snip)
> > I think he stopped helping when he started using phrases like 'crystal
> > ball' and 'wild-guess programming'. They are hostile responses.
> >
>
> Emily, if you manage to stick to your wishfull words for the next ten
> years without even a single possibly "hostile" answer, then you'll
> prove you're a better human being than I'm - needless to say, I whish
> you'll succeed. In the meantime, please reserve your judgments, or
> you're going to fail right from the start...
>
>
> --
> 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 at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.

<<35D.gif>>

Re: Passenger 57 - a Django query problem

2010-02-19 Thread bruno desthuilliers
On 18 fév, 12:16, Emily Rodgers 
wrote:
(snip)
> I think he stopped helping when he started using phrases like 'crystal
> ball' and 'wild-guess programming'. They are hostile responses.
>

Emily, if you manage to stick to your wishfull words for the next ten
years without even a single possibly "hostile" answer, then you'll
prove you're a better human being than I'm - needless to say, I whish
you'll succeed. In the meantime, please reserve your judgments, or
you're going to fail right from the start...


-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-19 Thread bruno desthuilliers
On 18 fév, 12:03, Sithembewena Lloyd Dube  wrote:
> Apologies for my handling of this matter earlier. It was not the Python way
> :)
>
> Bruno, feel welcome here.
>

Ok, I'm back then !-)

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-19 Thread Sithembewena Lloyd Dube
I hope that we can all learn somehow from the incident. When i reacted the
way i did, i was picking up subtle undertones of aggression which i thought
were undue. I have since spoke to Bruno and diffused the situation amicably.

I would agree with what Emily says, and the things I take away from it all
are:

- For the more experienced, if at all you will help, do try to be patient
with posters even in your language. This is partly how the helpfulness of
the list may be judged.
- Try to check impulsive reactions, as they may only add to the problem
rather than solving it. (okay, that would be me i guess).


Finally - yes Emily, my multiple posting was unintentional :-)

Regards,
Sithembewena


On Thu, Feb 18, 2010 at 1:16 PM, Emily Rodgers <
emily.kate.rodg...@googlemail.com> wrote:

>
>
> On Feb 18, 9:25 am, Atamert Ölçgen  wrote:
> > Hi Sithembewena,
> >
> > On Thursday 18 February 2010 00:27:10 Sithembewena Lloyd Dube wrote:>
> Emily provided an answer according to what she understood from the OP. No
> > > harm in doing that, at least not worse than no attempt at giving a
> > > solution..
> >
> > > I think that people who have a problem with posts, even vague ones,
> should
> > > stay away from them - let those that would try to help, to do so
> > > unhindered..
> >
> > > We have no interest in your personal coding style: attempt to help, or
> stay
> > > away.
> >
> > Bruno is trying to help in his own way. Let's not be unkind to each other
> like
> > that.
>
> I think he stopped helping when he started using phrases like 'crystal
> ball' and 'wild-guess programming'. They are hostile responses.
>
> The django-users group used to be a friendly place where people could
> ask sometimes daft, sometimes difficult questions and get a useful
> reply (in either case). This has been happening less and less lately.
> People get responses telling them to learn how to post a question, or
> just critising them for not being specific enough about what they want
> to know, and this is just a bit too hostile IMO. If you think someone
> hasn't provided enough information, it is helpful to ask them direct
> questions that they can answer to provide a useful context (without
> making them feel stupid). Often they aren't familiar with django /
> python / web development, and don't really know what is required for a
> useful answer to be given. It is our job to help them, not scare them
> away.
>
> One of the (many) great things about django is the community. Please
> can we be friendly and helpful here instead of answering questions
> with unhelpful responses?
>
> > Also, please use your e-mail app's **draft** feature and send your reply
> when
> > it's **done**.
>
> I suspect that was unintentional :-)
>
> >
> > --
> > Saygılarımla,
> > Atamert Ölçgen
> >
> >  -+-
> >  --+
> >  +++
> >
> > www.muhuk.com
> > mu...@jabber.org
>
> --
> 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 at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-18 Thread Emily Rodgers


On Feb 18, 9:25 am, Atamert Ölçgen  wrote:
> Hi Sithembewena,
>
> On Thursday 18 February 2010 00:27:10 Sithembewena Lloyd Dube wrote:> Emily 
> provided an answer according to what she understood from the OP. No
> > harm in doing that, at least not worse than no attempt at giving a
> > solution..
>
> > I think that people who have a problem with posts, even vague ones, should
> > stay away from them - let those that would try to help, to do so
> > unhindered..
>
> > We have no interest in your personal coding style: attempt to help, or stay
> > away.
>
> Bruno is trying to help in his own way. Let's not be unkind to each other like
> that.

I think he stopped helping when he started using phrases like 'crystal
ball' and 'wild-guess programming'. They are hostile responses.

The django-users group used to be a friendly place where people could
ask sometimes daft, sometimes difficult questions and get a useful
reply (in either case). This has been happening less and less lately.
People get responses telling them to learn how to post a question, or
just critising them for not being specific enough about what they want
to know, and this is just a bit too hostile IMO. If you think someone
hasn't provided enough information, it is helpful to ask them direct
questions that they can answer to provide a useful context (without
making them feel stupid). Often they aren't familiar with django /
python / web development, and don't really know what is required for a
useful answer to be given. It is our job to help them, not scare them
away.

One of the (many) great things about django is the community. Please
can we be friendly and helpful here instead of answering questions
with unhelpful responses?

> Also, please use your e-mail app's **draft** feature and send your reply when
> it's **done**.

I suspect that was unintentional :-)

>
> --
> Saygılarımla,
> Atamert Ölçgen
>
>  -+-
>  --+
>  +++
>
> www.muhuk.com
> mu...@jabber.org

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.




Re: Passenger 57 - a Django query problem

2010-02-18 Thread Sithembewena Lloyd Dube
Apologies for my handling of this matter earlier. It was not the Python way
:)

Bruno, feel welcome here.



On Thu, Feb 18, 2010 at 11:25 AM, Atamert Ölçgen  wrote:

> Hi Sithembewena,
>
>
> On Thursday 18 February 2010 00:27:10 Sithembewena Lloyd Dube wrote:
> > Emily provided an answer according to what she understood from the OP. No
> > harm in doing that, at least not worse than no attempt at giving a
> > solution..
> >
> > I think that people who have a problem with posts, even vague ones,
> should
> > stay away from them - let those that would try to help, to do so
> > unhindered..
> >
> > We have no interest in your personal coding style: attempt to help, or
> stay
> > away.
> Bruno is trying to help in his own way. Let's not be unkind to each other
> like
> that.
>
> Also, please use your e-mail app's **draft** feature and send your reply
> when
> it's **done**.
>
>
> --
> Saygılarımla,
> Atamert Ölçgen
>
>  -+-
>  --+
>  +++
>
> www.muhuk.com
> mu...@jabber.org
>
> --
> 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 at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-18 Thread Atamert Ölçgen
Hi Sithembewena,


On Thursday 18 February 2010 00:27:10 Sithembewena Lloyd Dube wrote:
> Emily provided an answer according to what she understood from the OP. No
> harm in doing that, at least not worse than no attempt at giving a
> solution..
> 
> I think that people who have a problem with posts, even vague ones, should
> stay away from them - let those that would try to help, to do so
> unhindered..
> 
> We have no interest in your personal coding style: attempt to help, or stay
> away.
Bruno is trying to help in his own way. Let's not be unkind to each other like 
that.

Also, please use your e-mail app's **draft** feature and send your reply when 
it's **done**.


-- 
Saygılarımla,
Atamert Ölçgen

 -+-
 --+
 +++

www.muhuk.com
mu...@jabber.org

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-18 Thread bruno desthuilliers
On Feb 17, 11:32 pm, Sithembewena Lloyd Dube 
wrote:
> Emily provided an answer according to what she understood from the OP. No
> harm in doing that,
> at least not worse than no attempt at giving a
> solution..

I wouldn't have asked for precisions if I didn't intend to try and
help.

> This is not a parade for anyone's personal coding style: attempt to help, or
> stay away.

It has nothing to do with "coding style", it's about having a correct
enough understanding of the problem to have a chance to come with a
sensible answer. But don't worry, I'll now stay away - very far away.
Good bye.

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-17 Thread Sithembewena Lloyd Dube
Emily provided an answer according to what she understood from the OP. No
harm in doing that, at least not worse than no attempt at giving a
solution..

I suspect this is more plausible than philosophising away all night.

On Thu, Feb 18, 2010 at 12:00 AM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

>
>
> On 17 fév, 17:29, Emily Rodgers 
> wrote:
>
> > As I said, we aren't doing his coding for him,
>
> And as I said, this is _not_ the problem. I don't mind providing
> working code as an answer, and did it on quite a few occasions during
> the past 10 years or so, on various newsgroups and mailing lists. But
> crystal-ball coding is just a waste of everyone's time - 8 times out
> 10 (at least), the answer is just plain wrong, the OP wastes time
> trying to use it, then comes back complaining it "doesn't work", etc,
> etc... Been here, done that, bought the T-shirt, ok ?-)
>
> And yes, it's the OP's duty to provide at least the minimum context if
> he hopes to get useful help. So asking the OP to provide this context
> is not "dismissive", it's the required condition for us to have a
> chance to effectively help.
>
> (snip remaining - and somewhat patronizing - comment).
>
> --
> 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 at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-17 Thread Sithembewena Lloyd Dube
Emily provided an answer according to what she understood from the OP. No
harm in doing that, at least not worse than no attempt at giving a
solution..

To me, this is more plausible than philosophising away all night.

Lloyd

On Thu, Feb 18, 2010 at 12:00 AM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

>
>
> On 17 fév, 17:29, Emily Rodgers 
> wrote:
>
> > As I said, we aren't doing his coding for him,
>
> And as I said, this is _not_ the problem. I don't mind providing
> working code as an answer, and did it on quite a few occasions during
> the past 10 years or so, on various newsgroups and mailing lists. But
> crystal-ball coding is just a waste of everyone's time - 8 times out
> 10 (at least), the answer is just plain wrong, the OP wastes time
> trying to use it, then comes back complaining it "doesn't work", etc,
> etc... Been here, done that, bought the T-shirt, ok ?-)
>
> And yes, it's the OP's duty to provide at least the minimum context if
> he hopes to get useful help. So asking the OP to provide this context
> is not "dismissive", it's the required condition for us to have a
> chance to effectively help.
>
> (snip remaining - and somewhat patronizing - comment).
>
> --
> 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 at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-17 Thread Sithembewena Lloyd Dube
Emily provided an answer according to what she understood from the OP. No
harm in doing that, at least not worse than no attempt at giving a
solution..

I suspect this is more plausible than philosophising away all night.

On Thu, Feb 18, 2010 at 12:00 AM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

>
>
> On 17 fév, 17:29, Emily Rodgers 
> wrote:
>
> > As I said, we aren't doing his coding for him,
>
> And as I said, this is _not_ the problem. I don't mind providing
> working code as an answer, and did it on quite a few occasions during
> the past 10 years or so, on various newsgroups and mailing lists. But
> crystal-ball coding is just a waste of everyone's time - 8 times out
> 10 (at least), the answer is just plain wrong, the OP wastes time
> trying to use it, then comes back complaining it "doesn't work", etc,
> etc... Been here, done that, bought the T-shirt, ok ?-)
>
> And yes, it's the OP's duty to provide at least the minimum context if
> he hopes to get useful help. So asking the OP to provide this context
> is not "dismissive", it's the required condition for us to have a
> chance to effectively help.
>
> (snip remaining - and somewhat patronizing - comment).
>
> --
> 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 at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-17 Thread Sithembewena Lloyd Dube
Emily provided an answer according to what she understood from the OP. No
harm in doing that, at least not worse than no attempt at giving a solution.

We have no interest in your personal coding style: attempt to help, or zip
your gob. Have had it with egomaniacs running loose..

Lloyd

On Thu, Feb 18, 2010 at 12:00 AM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

>
>
> On 17 fév, 17:29, Emily Rodgers 
> wrote:
>
> > As I said, we aren't doing his coding for him,
>
> And as I said, this is _not_ the problem. I don't mind providing
> working code as an answer, and did it on quite a few occasions during
> the past 10 years or so, on various newsgroups and mailing lists. But
> crystal-ball coding is just a waste of everyone's time - 8 times out
> 10 (at least), the answer is just plain wrong, the OP wastes time
> trying to use it, then comes back complaining it "doesn't work", etc,
> etc... Been here, done that, bought the T-shirt, ok ?-)
>
> And yes, it's the OP's duty to provide at least the minimum context if
> he hopes to get useful help. So asking the OP to provide this context
> is not "dismissive", it's the required condition for us to have a
> chance to effectively help.
>
> (snip remaining - and somewhat patronizing - comment).
>
> --
> 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 at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-17 Thread Sithembewena Lloyd Dube
Emily provided an answer according to what she understood from the OP. No
harm in doing that, at least not worse than no attempt at giving a
solution..

I suspect this is more plausible than philosophising away all night.

On Thu, Feb 18, 2010 at 12:00 AM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

>
>
> On 17 fév, 17:29, Emily Rodgers 
> wrote:
>
> > As I said, we aren't doing his coding for him,
>
> And as I said, this is _not_ the problem. I don't mind providing
> working code as an answer, and did it on quite a few occasions during
> the past 10 years or so, on various newsgroups and mailing lists. But
> crystal-ball coding is just a waste of everyone's time - 8 times out
> 10 (at least), the answer is just plain wrong, the OP wastes time
> trying to use it, then comes back complaining it "doesn't work", etc,
> etc... Been here, done that, bought the T-shirt, ok ?-)
>
> And yes, it's the OP's duty to provide at least the minimum context if
> he hopes to get useful help. So asking the OP to provide this context
> is not "dismissive", it's the required condition for us to have a
> chance to effectively help.
>
> (snip remaining - and somewhat patronizing - comment).
>
> --
> 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 at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-17 Thread Sithembewena Lloyd Dube
Emily provided an answer according to what she understood from the OP. No
harm in doing that, at least not worse than no attempt at giving a
solution..

I think that people who have a problem with posts, even vague ones, should
stay away from them - let those that would try to help, to do so
unhindered..

We have no interest in your personal coding style: attempt to help, or stay
away.

Lloyd

On Wed, Feb 17, 2010 at 1:20 PM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

> On Feb 17, 10:12 am, Emily Rodgers 
> wrote:
> > On Feb 16, 4:50 pm, bruno desthuilliers
> > > I'm afraid I don't really get what difference it would make. Note that
> > > my question was genuine - I know zilch about the problem domain, I
> > > don't have the fisrt clue about what an "Alliance" might be, so I
> > > don't know if that relationship is redundant or if it's totally
> > > distinct from what you'd get thru the passenger/flight/operator/
> > > memberships link.
> >
> > My assumptions
> (snip)
> > If this is Derek's meaning then
> (snip)
> >  Also, and
> > airline may be
> (snip)
>
> Sorry but that's WAY too much assumptions for me. I don't do wild-
> guess programming, it's just a waste of everyone's time.
>
> > I may be completely wrong of course,
>
> !-)
>
> > and it would be interesting to
> > hear from the OP what his thoughts are.
>
> Indeed.
>
> --
> 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 at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-17 Thread Sithembewena Lloyd Dube
Emily provided an answer according to what she understood from the OP. No
harm in doing that, at least not worse than no attempt at giving a
solution..

This is not a parade for anyone's personal coding style: attempt to help, or
stay away.

Lloyd

On Wed, Feb 17, 2010 at 1:20 PM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

> On Feb 17, 10:12 am, Emily Rodgers 
> wrote:
> > On Feb 16, 4:50 pm, bruno desthuilliers
> > > I'm afraid I don't really get what difference it would make. Note that
> > > my question was genuine - I know zilch about the problem domain, I
> > > don't have the fisrt clue about what an "Alliance" might be, so I
> > > don't know if that relationship is redundant or if it's totally
> > > distinct from what you'd get thru the passenger/flight/operator/
> > > memberships link.
> >
> > My assumptions
> (snip)
> > If this is Derek's meaning then
> (snip)
> >  Also, and
> > airline may be
> (snip)
>
> Sorry but that's WAY too much assumptions for me. I don't do wild-
> guess programming, it's just a waste of everyone's time.
>
> > I may be completely wrong of course,
>
> !-)
>
> > and it would be interesting to
> > hear from the OP what his thoughts are.
>
> Indeed.
>
> --
> 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 at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-17 Thread bruno desthuilliers


On 17 fév, 17:29, Emily Rodgers 
wrote:

> As I said, we aren't doing his coding for him,

And as I said, this is _not_ the problem. I don't mind providing
working code as an answer, and did it on quite a few occasions during
the past 10 years or so, on various newsgroups and mailing lists. But
crystal-ball coding is just a waste of everyone's time - 8 times out
10 (at least), the answer is just plain wrong, the OP wastes time
trying to use it, then comes back complaining it "doesn't work", etc,
etc... Been here, done that, bought the T-shirt, ok ?-)

And yes, it's the OP's duty to provide at least the minimum context if
he hopes to get useful help. So asking the OP to provide this context
is not "dismissive", it's the required condition for us to have a
chance to effectively help.

(snip remaining - and somewhat patronizing - comment).

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-17 Thread Emily Rodgers


On Feb 17, 11:20 am, bruno desthuilliers
 wrote:
> On Feb 17, 10:12 am, Emily Rodgers 
> wrote:> On Feb 16, 4:50 pm, bruno desthuilliers
> > > I'm afraid I don't really get what difference it would make. Note that
> > > my question was genuine - I know zilch about the problem domain, I
> > > don't have the fisrt clue about what an "Alliance" might be, so I
> > > don't know if that relationship is redundant or if it's totally
> > > distinct from what you'd get thru the passenger/flight/operator/
> > > memberships link.
>
> > My assumptions
> (snip)
> > If this is Derek's meaning then
> (snip)
> >  Also, and
> > airline may be
>
> (snip)
>
> Sorry but that's WAY too much assumptions for me. I don't do wild-
> guess programming, it's just a waste of everyone's time.

As I said, we aren't doing his coding for him, more giving examples of
ways to query this kind of thing. Sometimes (particularly if you are a
newbie) it is difficult to explain all of your requirements for a
problem in a concise way to a news group in order to satisfy people
who don't do 'wild-guess programming', and have to simplify things a
lot as it is because you may not want to share your code with the
world. Often in order to give a helpful reply to these types of
questions (rather than a dismissive response) you have to make some
assumptions. Presumably the OP will be able to tell if these
assumptions are reasonable, and if not, this discussion may help to
improve his design.

>
> > I may be completely wrong of course,
>
> !-)
>
> > and it would be interesting to
> > hear from the OP what his thoughts are.
>
> Indeed.

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-17 Thread bruno desthuilliers
On Feb 17, 10:12 am, Emily Rodgers 
wrote:
> On Feb 16, 4:50 pm, bruno desthuilliers
> > I'm afraid I don't really get what difference it would make. Note that
> > my question was genuine - I know zilch about the problem domain, I
> > don't have the fisrt clue about what an "Alliance" might be, so I
> > don't know if that relationship is redundant or if it's totally
> > distinct from what you'd get thru the passenger/flight/operator/
> > memberships link.
>
> My assumptions
(snip)
> If this is Derek's meaning then
(snip)
>  Also, and
> airline may be
(snip)

Sorry but that's WAY too much assumptions for me. I don't do wild-
guess programming, it's just a waste of everyone's time.

> I may be completely wrong of course,

!-)

> and it would be interesting to
> hear from the OP what his thoughts are.

Indeed.

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-17 Thread Emily Rodgers


On Feb 16, 4:50 pm, bruno desthuilliers
 wrote:
> On Feb 16, 4:54 pm, Emily Rodgers 
> wrote:
>
>
>
> > On Feb 16, 3:39 pm, bruno desthuilliers
>
> >  wrote:
> > > On Feb 16, 2:56 pm, Derek  wrote:
> > [snip]
> > > Ain't that "memberships" relationship redundant with passenger->flight-
>
> > > >operator->memberships ?
>
> > I reckon he probably wants to do is split passenger up:
>
> > class Passenger(models.Model):
> >     customer = models.ForeignKey(User)
> >     flight = models.ForeignKey(Flight)
>
> > and have memberships as an attribute of the user.
>
> I'm afraid I don't really get what difference it would make. Note that
> my question was genuine - I know zilch about the problem domain, I
> don't have the fisrt clue about what an "Alliance" might be, so I
> don't know if that relationship is redundant or if it's totally
> distinct from what you'd get thru the passenger/flight/operator/
> memberships link.

My assumptions came from analogous cases in the real world. Often
companies group together to give some kind of club that customers can
sign up to to get benefits of discounts from all companies in the
group (reward cards are the most obvious case I can think of).

If this is Derek's meaning then the passenger (or I think user) may
have memberships to any number of such reward schemes. Also, and
airline may be in more than one alliance (or group that offers a
certain discount for members). The purpose of the query is to see
which reward schemes the passenger is a member of, and what discount
they qualify for (the maximum discount would normally prevail). In my
mind, the membership sits with the user object, and a passenger record
is merely showing that the user is booked onto a flight (so could be
renamed 'FlightBooking').

I may be completely wrong of course, and it would be interesting to
hear from the OP what his thoughts are.


>
>
>
> > > > So, if Passenger 57 books a flight with, say, AIA, which is a member of 
> > > > the
> > > > Star and Western alliances, how can I tell if this qualifies for a
> > > > discount?
>
> > > How could we know ? There's zero documentation about your models
> > > fields, and zero documention about the business rules - specially the
> > > ones one relating to "discount" and "qualification". Or are we
> > > supposed to use a crystal ball ?
>
> > You do have a point, but I think he is wanting a vague idea of how to
> > go about it rather than for us to write his code for him. Or maybe get
> > a discussion going about the pros and cons of different ways of
> > querying.
>
> Here again, my point is that answering the OP question requires some
> (implicit) knowledge of the domain that I just don't have - and I'm
> probably not the only one here lacking that knowledge.

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-16 Thread bruno desthuilliers
On Feb 16, 4:54 pm, Emily Rodgers 
wrote:
> On Feb 16, 3:39 pm, bruno desthuilliers
>
>  wrote:
> > On Feb 16, 2:56 pm, Derek  wrote:
> [snip]
> > Ain't that "memberships" relationship redundant with passenger->flight-
>
> > >operator->memberships ?
>
> I reckon he probably wants to do is split passenger up:
>
> class Passenger(models.Model):
>     customer = models.ForeignKey(User)
>     flight = models.ForeignKey(Flight)
>
> and have memberships as an attribute of the user.

I'm afraid I don't really get what difference it would make. Note that
my question was genuine - I know zilch about the problem domain, I
don't have the fisrt clue about what an "Alliance" might be, so I
don't know if that relationship is redundant or if it's totally
distinct from what you'd get thru the passenger/flight/operator/
memberships link.

>
> > > So, if Passenger 57 books a flight with, say, AIA, which is a member of 
> > > the
> > > Star and Western alliances, how can I tell if this qualifies for a
> > > discount?
>
> > How could we know ? There's zero documentation about your models
> > fields, and zero documention about the business rules - specially the
> > ones one relating to "discount" and "qualification". Or are we
> > supposed to use a crystal ball ?
>
> You do have a point, but I think he is wanting a vague idea of how to
> go about it rather than for us to write his code for him. Or maybe get
> a discussion going about the pros and cons of different ways of
> querying.

Here again, my point is that answering the OP question requires some
(implicit) knowledge of the domain that I just don't have - and I'm
probably not the only one here lacking that knowledge.

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-16 Thread Emily Rodgers


On Feb 16, 3:39 pm, bruno desthuilliers
 wrote:
> On Feb 16, 2:56 pm, Derek  wrote:
[snip]
> Ain't that "memberships" relationship redundant with passenger->flight-
>
> >operator->memberships ?

I reckon he probably wants to do is split passenger up:

class Passenger(models.Model):
customer = models.ForeignKey(User)
flight = models.ForeignKey(Flight)

and have memberships as an attribute of the user. Then you would want
to pass the flight number to the function that determines the
discount.


> > So, if Passenger 57 books a flight with, say, AIA, which is a member of the
> > Star and Western alliances, how can I tell if this qualifies for a
> > discount?
>
> How could we know ? There's zero documentation about your models
> fields, and zero documention about the business rules - specially the
> ones one relating to "discount" and "qualification". Or are we
> supposed to use a crystal ball ?

You do have a point, but I think he is wanting a vague idea of how to
go about it rather than for us to write his code for him. Or maybe get
a discussion going about the pros and cons of different ways of
querying.

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-16 Thread Emily Rodgers


On Feb 16, 1:56 pm, Derek  wrote:
> (not a movie trivia problem!)
>
> The question I need to resolve here is "does Passenger 57 qualify for a
> discount"?
>
> Given the following models:
>
> class Alliance(models.Model):
>     name = models.CharField(max_length=100)
>     #e.g. Star, Western, Pacific, European
>     discount = models.FloatField()
>
> class Airline(models.Model):
>     name = models.CharField(max_length=100)
>     #e.g. AIA, Northwest, Cathay, KLM
>     membership = models.ManyToManyField(Alliance)
>
> class Flight(models.Model):
>     name = models.CharField(max_length=100)
>     operator = models.ForeignKey(Airline)
>
> class Passenger(models.Model):
>     name = models.CharField(max_length=100)
>     flight = models.ForeignKey(Flight)
>     memberships = models.ManyToManyField(Alliance)
>
> So, if Passenger 57 books a flight with, say, AIA, which is a member of the
> Star and Western alliances, how can I tell if this qualifies for a
> discount?  Assume, for purpose of this query, that the logged in user_id is
> the same as the passenger_id (i.e. 57).

How about creating this as a method of the passenger model:

def calculateDiscount(self):
max_discount = 0
# discount_with = None
flight_allies = self.flight.operator.membership.all()
# you may want to make the above "memberships" (with an s) to be
consistent or it will come back to bite you in the bum!
users_allies = self.memberships.all()
for fa in flight_allies:
if fa in users_allies:
if fa.discount > max_discount:
max_discount = fa.discount
# discount_with = fa
return max_discount

I put the 'discount_with' variable in so that if you wanted to know
which membership was used for a discount you can (just need to figure
out the best way to return it - I tend to use objects or dicts). I
haven't in any way tested it, so there may be silly errors, but you
get the idea. There are probably also better (more efficient) ways,
but this is what would occur to me!

To use this form a view, you would do something like:

passenger = Passenger.objects.get(pk=57)
discount = passenger.calculateDiscount()

Presumably you know how to get the id of the logged in user (you would
just put that in instead of 57).

Em

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Passenger 57 - a Django query problem

2010-02-16 Thread bruno desthuilliers


On Feb 16, 2:56 pm, Derek  wrote:
> (not a movie trivia problem!)
>
> The question I need to resolve here is "does Passenger 57 qualify for a
> discount"?
>
> Given the following models:
>
> class Alliance(models.Model):
>     name = models.CharField(max_length=100)
>     #e.g. Star, Western, Pacific, European
>     discount = models.FloatField()
>
> class Airline(models.Model):
>     name = models.CharField(max_length=100)
>     #e.g. AIA, Northwest, Cathay, KLM
>     membership = models.ManyToManyField(Alliance)
>
> class Flight(models.Model):
>     name = models.CharField(max_length=100)
>     operator = models.ForeignKey(Airline)
>
> class Passenger(models.Model):
>     name = models.CharField(max_length=100)
>     flight = models.ForeignKey(Flight)
>     memberships = models.ManyToManyField(Alliance)

Ain't that "memberships" relationship redundant with passenger->flight-
>operator->memberships ?

> So, if Passenger 57 books a flight with, say, AIA, which is a member of the
> Star and Western alliances, how can I tell if this qualifies for a
> discount?

How could we know ? There's zero documentation about your models
fields, and zero documention about the business rules - specially the
ones one relating to "discount" and "qualification". Or are we
supposed to use a crystal ball ?

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.