Replace dotted notation FKs with actual objects

This commit is contained in:
Patrick Altman 2014-12-18 08:17:35 -06:00
parent 2ec9449e38
commit 5f311ca7bd
3 changed files with 16 additions and 17 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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")