From 5f311ca7bd4e5e2ec7fe99bf903ed2793ea83d6f Mon Sep 17 00:00:00 2001 From: Patrick Altman Date: Thu, 18 Dec 2014 08:17:35 -0600 Subject: [PATCH] Replace dotted notation FKs with actual objects --- symposion/proposals/models.py | 7 ++++--- symposion/reviews/models.py | 21 +++++++++------------ symposion/schedule/models.py | 5 +++-- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/symposion/proposals/models.py b/symposion/proposals/models.py index 7678d961..3c953c39 100644 --- a/symposion/proposals/models.py +++ b/symposion/proposals/models.py @@ -16,6 +16,7 @@ from markitup.fields import MarkupField from model_utils.managers import InheritanceManager from symposion.conference.models import Section +from symposion.speakers.models import Speaker class ProposalSection(models.Model): @@ -103,8 +104,8 @@ class ProposalBase(models.Model): default=now, editable=False, ) - speaker = models.ForeignKey("speakers.Speaker", related_name="proposals") - additional_speakers = models.ManyToManyField("speakers.Speaker", through="AdditionalSpeaker", + speaker = models.ForeignKey(Speaker, related_name="proposals") + additional_speakers = models.ManyToManyField(Speaker, through="AdditionalSpeaker", blank=True) cancelled = models.BooleanField(default=False) @@ -153,7 +154,7 @@ class AdditionalSpeaker(models.Model): (SPEAKING_STATUS_DECLINED, _("Declined")), ] - speaker = models.ForeignKey("speakers.Speaker") + speaker = models.ForeignKey(Speaker) proposalbase = models.ForeignKey(ProposalBase) status = models.IntegerField(choices=SPEAKING_STATUS, default=SPEAKING_STATUS_PENDING) diff --git a/symposion/reviews/models.py b/symposion/reviews/models.py index b601e0c2..b51ef2f0 100644 --- a/symposion/reviews/models.py +++ b/symposion/reviews/models.py @@ -52,13 +52,13 @@ class ReviewAssignment(models.Model): (AUTO_ASSIGNED_LATER, "auto-assigned, later"), ] - proposal = models.ForeignKey("proposals.ProposalBase") + proposal = models.ForeignKey(ProposalBase) user = models.ForeignKey(User) origin = models.IntegerField(choices=ORIGIN_CHOICES) assigned_at = models.DateTimeField(default=datetime.now) - opted_out = models.BooleanField() + opted_out = models.BooleanField(default=False) @classmethod def create_assignments(cls, proposal, origin=AUTO_ASSIGNED_INITIAL): @@ -92,7 +92,7 @@ class ReviewAssignment(models.Model): class ProposalMessage(models.Model): - proposal = models.ForeignKey("proposals.ProposalBase", related_name="messages") + proposal = models.ForeignKey(ProposalBase, related_name="messages") user = models.ForeignKey(User) message = MarkupField() @@ -105,7 +105,7 @@ class ProposalMessage(models.Model): class Review(models.Model): VOTES = VOTES - proposal = models.ForeignKey("proposals.ProposalBase", related_name="reviews") + proposal = models.ForeignKey(ProposalBase, related_name="reviews") user = models.ForeignKey(User) # No way to encode "-0" vs. "+0" into an IntegerField, and I don't feel @@ -184,7 +184,7 @@ class Review(models.Model): class LatestVote(models.Model): VOTES = VOTES - proposal = models.ForeignKey("proposals.ProposalBase", related_name="votes") + proposal = models.ForeignKey(ProposalBase, related_name="votes") user = models.ForeignKey(User) # No way to encode "-0" vs. "+0" into an IntegerField, and I don't feel @@ -205,7 +205,7 @@ class LatestVote(models.Model): class ProposalResult(models.Model): - proposal = models.OneToOneField("proposals.ProposalBase", related_name="result") + proposal = models.OneToOneField(ProposalBase, related_name="result") score = models.DecimalField(max_digits=5, decimal_places=2, default=Decimal("0.00")) comment_count = models.PositiveIntegerField(default=0) vote_count = models.PositiveIntegerField(default=0) @@ -281,15 +281,12 @@ class ProposalResult(models.Model): class Comment(models.Model): - proposal = models.ForeignKey("proposals.ProposalBase", related_name="comments") + proposal = models.ForeignKey(ProposalBase, related_name="comments") commenter = models.ForeignKey(User) text = MarkupField() # Or perhaps more accurately, can the user see this comment. - public = models.BooleanField(choices=[ - (True, "public"), - (False, "private"), - ]) + public = models.BooleanField(choices=[(True, "public"), (False, "private")], default=False) commented_at = models.DateTimeField(default=datetime.now) @@ -303,7 +300,7 @@ class NotificationTemplate(models.Model): class ResultNotification(models.Model): - proposal = models.ForeignKey("proposals.ProposalBase", related_name="notifications") + proposal = models.ForeignKey(ProposalBase, related_name="notifications") template = models.ForeignKey(NotificationTemplate, null=True, blank=True, on_delete=models.SET_NULL) timestamp = models.DateTimeField(default=datetime.now) diff --git a/symposion/schedule/models.py b/symposion/schedule/models.py index 38ff6f09..14ea87e4 100644 --- a/symposion/schedule/models.py +++ b/symposion/schedule/models.py @@ -7,6 +7,7 @@ from markitup.fields import MarkupField from symposion.proposals.models import ProposalBase from symposion.conference.models import Section +from symposion.speakers.models import Speaker class Schedule(models.Model): @@ -151,8 +152,8 @@ class Presentation(models.Model): title = models.CharField(max_length=100) description = MarkupField() abstract = MarkupField() - speaker = models.ForeignKey("speakers.Speaker", related_name="presentations") - additional_speakers = models.ManyToManyField("speakers.Speaker", related_name="copresentations", + speaker = models.ForeignKey(Speaker, related_name="presentations") + additional_speakers = models.ManyToManyField(Speaker, related_name="copresentations", blank=True) cancelled = models.BooleanField(default=False) proposal_base = models.OneToOneField(ProposalBase, related_name="presentation")