Merge pull request #38 from IcyNet/admin-panel-enhancements

Added __str__ methods to all the models
This commit is contained in:
Tsa6 2017-09-24 18:30:59 -04:00 committed by GitHub
commit f92a4e95bf

View File

@ -68,6 +68,8 @@ class Show(TimestampedModel):
help_text="A banner used for the show's page.",
verbose_name="Artwork"
)
def __str__(self):
return '%s [%s]'%(self.name,self.abbr)
class User(TimestampedModel):
user_id = models.CharField(
@ -92,6 +94,8 @@ class User(TimestampedModel):
related_name='watched_by',
through='Watch'
)
def __str__(self):
return self.email
class Admin(User):
pass
@ -136,6 +140,8 @@ class Ban(TimestampedModel):
help_text='If checked, this is a site-wide ban, and the user is automatically banned from all shows, not just those in the Banned From (scope) paramenter',
verbose_name = 'Site Wide Ban'
)
def __str__(self):
return ("Permanent" if self.permanent else "Temporary") + " ban of %s"%self.user
class ShowModerator(TimestampedModel):
show = models.ForeignKey(
@ -160,6 +166,8 @@ class ShowModerator(TimestampedModel):
help_text='The user who appointed this moderator',
verbose_name='Appointed by'
)
def __str__(self):
return "%s on %s"%(self.user,self.show.abbr)
class Report(TimestampedModel):
reporter = models.ForeignKey(
@ -184,6 +192,8 @@ class Report(TimestampedModel):
help_text='The URL of the content being reported',
verbose_name = 'Content URL'
)
def __str__(self):
return "%s's report of %s"%(self.reporter, self.url)
class ShowSubmission(TimestampedModel):
user = models.ForeignKey(
@ -193,11 +203,17 @@ class ShowSubmission(TimestampedModel):
help_text='The user who submitted this show',
verbose_name='Submitter'
)
name = Show.name
name = models.CharField(
max_length=40,
help_text="The full name of the show",
verbose_name="Full Name"
)
details = models.TextField(
help_text='Some details about the show. Why it should be added, where information about it can be found, etc.',
verbose_name='Details'
)
def __str__(self):
return '"%s" by %s'%(self.name, self.user)
class Season(models.Model):
show = models.ForeignKey(
@ -225,6 +241,8 @@ class Season(models.Model):
verbose_name="Artwork",
blank=True
)
def __str__(self):
return self.show.name + " S%d"%self.number
class Episode(models.Model):
show = models.ForeignKey(
@ -255,6 +273,8 @@ class Episode(models.Model):
help_text='The date this episode officially aired for the first time',
verbose_name='Original Air Date'
)
def __str__(self):
return "[s%dep%d] %s%s"%(self.season.number,self.episode,self.show.name, self.name)
class Submission(TimestampedModel):
episode = models.ForeignKey(
@ -278,6 +298,8 @@ class Submission(TimestampedModel):
help_text='Tags applied to this link submission',
max_length=200
)
def __str__(self):
return '%s\'s submission for %s — s%dep%d'%(self.user,self.episode.show.name,self.episode.season.number, self.episode.episode)
class SubmissionVote(TimestampedModel):
submission = models.ForeignKey(
@ -295,6 +317,8 @@ class SubmissionVote(TimestampedModel):
positive = models.BooleanField(
help_text='If this is true, the vote is an upvote. Otherwise, it is a downvote'
)
def __str__(self):
return "%s's vote on %s"%(self.user,self.submission)
class Favorite(TimestampedModel):
user = models.ForeignKey(
@ -305,6 +329,8 @@ class Favorite(TimestampedModel):
Episode,
on_delete=models.CASCADE
)
def __str__(self):
return "%s \u2665 %s"%(self.user, self.episode)
class Watch(TimestampedModel):
user = models.ForeignKey(
@ -315,6 +341,8 @@ class Watch(TimestampedModel):
Episode,
on_delete=models.CASCADE
)
def __str__(self):
return "%s \U0001f441 %s"%(self.user, self.episode)
class DiscussionBoard(TimestampedModel):
show = models.ForeignKey(
@ -338,6 +366,8 @@ class DiscussionBoard(TimestampedModel):
help_text='The body of the post',
verbose_name='Body'
)
def __str__(self):
return '[%s] "%s" by %s'%(self.show.abbr, self.title, self.user)
class DiscussionReply(TimestampedModel):
board = models.ForeignKey(
@ -357,6 +387,8 @@ class DiscussionReply(TimestampedModel):
help_text='The body of the response',
verbose_name='Body'
)
def __str__(self):
return '[%s] %s\'s response to "%s"'%(self.board.show.abbr,self.user, self.board.title)
class DiscussionVote(TimestampedModel):
user = models.ForeignKey(
@ -374,3 +406,5 @@ class DiscussionVote(TimestampedModel):
postive = models.BooleanField(
help_text='If true, the vote is an upvote. Otherwise, it is a downvote. Neutral votes are not recorded'
)
def __str__(self):
return "%s %s %s"%(self.user, '\U0001f592' if self.postive else '\U0001f44e', self.board.title)