Merge pull request #38 from IcyNet/admin-panel-enhancements
Added __str__ methods to all the models
This commit is contained in:
commit
f92a4e95bf
@ -68,6 +68,8 @@ class Show(TimestampedModel):
|
|||||||
help_text="A banner used for the show's page.",
|
help_text="A banner used for the show's page.",
|
||||||
verbose_name="Artwork"
|
verbose_name="Artwork"
|
||||||
)
|
)
|
||||||
|
def __str__(self):
|
||||||
|
return '%s [%s]'%(self.name,self.abbr)
|
||||||
|
|
||||||
class User(TimestampedModel):
|
class User(TimestampedModel):
|
||||||
user_id = models.CharField(
|
user_id = models.CharField(
|
||||||
@ -92,6 +94,8 @@ class User(TimestampedModel):
|
|||||||
related_name='watched_by',
|
related_name='watched_by',
|
||||||
through='Watch'
|
through='Watch'
|
||||||
)
|
)
|
||||||
|
def __str__(self):
|
||||||
|
return self.email
|
||||||
|
|
||||||
class Admin(User):
|
class Admin(User):
|
||||||
pass
|
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',
|
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'
|
verbose_name = 'Site Wide Ban'
|
||||||
)
|
)
|
||||||
|
def __str__(self):
|
||||||
|
return ("Permanent" if self.permanent else "Temporary") + " ban of %s"%self.user
|
||||||
|
|
||||||
class ShowModerator(TimestampedModel):
|
class ShowModerator(TimestampedModel):
|
||||||
show = models.ForeignKey(
|
show = models.ForeignKey(
|
||||||
@ -160,6 +166,8 @@ class ShowModerator(TimestampedModel):
|
|||||||
help_text='The user who appointed this moderator',
|
help_text='The user who appointed this moderator',
|
||||||
verbose_name='Appointed by'
|
verbose_name='Appointed by'
|
||||||
)
|
)
|
||||||
|
def __str__(self):
|
||||||
|
return "%s on %s"%(self.user,self.show.abbr)
|
||||||
|
|
||||||
class Report(TimestampedModel):
|
class Report(TimestampedModel):
|
||||||
reporter = models.ForeignKey(
|
reporter = models.ForeignKey(
|
||||||
@ -184,6 +192,8 @@ class Report(TimestampedModel):
|
|||||||
help_text='The URL of the content being reported',
|
help_text='The URL of the content being reported',
|
||||||
verbose_name = 'Content URL'
|
verbose_name = 'Content URL'
|
||||||
)
|
)
|
||||||
|
def __str__(self):
|
||||||
|
return "%s's report of %s"%(self.reporter, self.url)
|
||||||
|
|
||||||
class ShowSubmission(TimestampedModel):
|
class ShowSubmission(TimestampedModel):
|
||||||
user = models.ForeignKey(
|
user = models.ForeignKey(
|
||||||
@ -193,11 +203,17 @@ class ShowSubmission(TimestampedModel):
|
|||||||
help_text='The user who submitted this show',
|
help_text='The user who submitted this show',
|
||||||
verbose_name='Submitter'
|
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(
|
details = models.TextField(
|
||||||
help_text='Some details about the show. Why it should be added, where information about it can be found, etc.',
|
help_text='Some details about the show. Why it should be added, where information about it can be found, etc.',
|
||||||
verbose_name='Details'
|
verbose_name='Details'
|
||||||
)
|
)
|
||||||
|
def __str__(self):
|
||||||
|
return '"%s" by %s'%(self.name, self.user)
|
||||||
|
|
||||||
class Season(models.Model):
|
class Season(models.Model):
|
||||||
show = models.ForeignKey(
|
show = models.ForeignKey(
|
||||||
@ -225,6 +241,8 @@ class Season(models.Model):
|
|||||||
verbose_name="Artwork",
|
verbose_name="Artwork",
|
||||||
blank=True
|
blank=True
|
||||||
)
|
)
|
||||||
|
def __str__(self):
|
||||||
|
return self.show.name + " S%d"%self.number
|
||||||
|
|
||||||
class Episode(models.Model):
|
class Episode(models.Model):
|
||||||
show = models.ForeignKey(
|
show = models.ForeignKey(
|
||||||
@ -255,6 +273,8 @@ class Episode(models.Model):
|
|||||||
help_text='The date this episode officially aired for the first time',
|
help_text='The date this episode officially aired for the first time',
|
||||||
verbose_name='Original Air Date'
|
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):
|
class Submission(TimestampedModel):
|
||||||
episode = models.ForeignKey(
|
episode = models.ForeignKey(
|
||||||
@ -278,6 +298,8 @@ class Submission(TimestampedModel):
|
|||||||
help_text='Tags applied to this link submission',
|
help_text='Tags applied to this link submission',
|
||||||
max_length=200
|
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):
|
class SubmissionVote(TimestampedModel):
|
||||||
submission = models.ForeignKey(
|
submission = models.ForeignKey(
|
||||||
@ -295,6 +317,8 @@ class SubmissionVote(TimestampedModel):
|
|||||||
positive = models.BooleanField(
|
positive = models.BooleanField(
|
||||||
help_text='If this is true, the vote is an upvote. Otherwise, it is a downvote'
|
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):
|
class Favorite(TimestampedModel):
|
||||||
user = models.ForeignKey(
|
user = models.ForeignKey(
|
||||||
@ -305,6 +329,8 @@ class Favorite(TimestampedModel):
|
|||||||
Episode,
|
Episode,
|
||||||
on_delete=models.CASCADE
|
on_delete=models.CASCADE
|
||||||
)
|
)
|
||||||
|
def __str__(self):
|
||||||
|
return "%s \u2665 %s"%(self.user, self.episode)
|
||||||
|
|
||||||
class Watch(TimestampedModel):
|
class Watch(TimestampedModel):
|
||||||
user = models.ForeignKey(
|
user = models.ForeignKey(
|
||||||
@ -315,6 +341,8 @@ class Watch(TimestampedModel):
|
|||||||
Episode,
|
Episode,
|
||||||
on_delete=models.CASCADE
|
on_delete=models.CASCADE
|
||||||
)
|
)
|
||||||
|
def __str__(self):
|
||||||
|
return "%s \U0001f441 %s"%(self.user, self.episode)
|
||||||
|
|
||||||
class DiscussionBoard(TimestampedModel):
|
class DiscussionBoard(TimestampedModel):
|
||||||
show = models.ForeignKey(
|
show = models.ForeignKey(
|
||||||
@ -338,6 +366,8 @@ class DiscussionBoard(TimestampedModel):
|
|||||||
help_text='The body of the post',
|
help_text='The body of the post',
|
||||||
verbose_name='Body'
|
verbose_name='Body'
|
||||||
)
|
)
|
||||||
|
def __str__(self):
|
||||||
|
return '[%s] "%s" by %s'%(self.show.abbr, self.title, self.user)
|
||||||
|
|
||||||
class DiscussionReply(TimestampedModel):
|
class DiscussionReply(TimestampedModel):
|
||||||
board = models.ForeignKey(
|
board = models.ForeignKey(
|
||||||
@ -357,6 +387,8 @@ class DiscussionReply(TimestampedModel):
|
|||||||
help_text='The body of the response',
|
help_text='The body of the response',
|
||||||
verbose_name='Body'
|
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):
|
class DiscussionVote(TimestampedModel):
|
||||||
user = models.ForeignKey(
|
user = models.ForeignKey(
|
||||||
@ -374,3 +406,5 @@ class DiscussionVote(TimestampedModel):
|
|||||||
postive = models.BooleanField(
|
postive = models.BooleanField(
|
||||||
help_text='If true, the vote is an upvote. Otherwise, it is a downvote. Neutral votes are not recorded'
|
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)
|
||||||
|
Reference in New Issue
Block a user