improved Proposal.proposal

* renamed the field to avoid nasty underscore
 * fixed code to avoid extra query
This commit is contained in:
Brian Rosner 2012-09-13 14:39:58 -06:00
parent a2b72499e0
commit db66749046

View file

@ -67,7 +67,7 @@ class Presentation(models.Model):
speaker = models.ForeignKey("speakers.Speaker", related_name="presentations") speaker = models.ForeignKey("speakers.Speaker", related_name="presentations")
additional_speakers = models.ManyToManyField("speakers.Speaker", blank=True) additional_speakers = models.ManyToManyField("speakers.Speaker", blank=True)
cancelled = models.BooleanField(default=False) cancelled = models.BooleanField(default=False)
_proposal = models.OneToOneField(ProposalBase, related_name="presentation") proposal_base = models.OneToOneField(ProposalBase, related_name="presentation")
section = models.ForeignKey(Section, related_name="presentations") section = models.ForeignKey(Section, related_name="presentations")
@property @property
@ -76,10 +76,9 @@ class Presentation(models.Model):
@property @property
def proposal(self): def proposal(self):
if self._proposal: if self.proposal_base_id is None:
proposal = ProposalBase.objects.get_subclass(pk=self._proposal.pk) return None
return proposal return ProposalBase.objects.get_subclass(pk=self.proposal_base_id)
return None
def speakers(self): def speakers(self):
yield self.speaker yield self.speaker