From 7e9fdbf3b7de38f3d9c5b9e1e56c566a21cb4413 Mon Sep 17 00:00:00 2001 From: Taizo 'Tsa6' Simpson Date: Sat, 26 Aug 2017 02:37:20 -0400 Subject: [PATCH] Added timestamps --- LandingPage/models.py | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/LandingPage/models.py b/LandingPage/models.py index c373478..11f1875 100644 --- a/LandingPage/models.py +++ b/LandingPage/models.py @@ -14,7 +14,15 @@ def name_season_artwork(inst, name): show_static_storage = FileSystemStorage(location=os.path.join(os.path.dirname(settings.MEDIA_ROOT), 'uploaded_resources'), base_url='showstatic') # Create your models here. -class Show(models.Model): +class TimestampedModel: + timestamp = models.DateTimeField( + auto_now=True, + help_text='The date and time this object was created' + ) + class Meta: + abstract = True + +class Show(TimestampedModel): name = models.CharField( max_length=40, help_text="The full name of the show", @@ -61,7 +69,7 @@ class Show(models.Model): verbose_name="Artwork" ) -class User(models.Model): +class User(TimestampedModel): auth_token=models.CharField( max_length=16, help_text="User's authentication token from IcyNet's auth system", @@ -85,7 +93,7 @@ class User(models.Model): class Admin(User): pass -class Ban(models.Model): +class Ban(TimestampedModel): user = models.OneToOneField( User, on_delete=models.CASCADE, @@ -126,7 +134,7 @@ class Ban(models.Model): verbose_name = 'Site Wide Ban' ) -class ShowModerator(models.Model): +class ShowModerator(TimestampedModel): show = models.ForeignKey( Show, on_delete=models.CASCADE, @@ -150,7 +158,7 @@ class ShowModerator(models.Model): verbose_name='Appointed by' ) -class Report(models.Model): +class Report(TimestampedModel): reporter = models.ForeignKey( User, on_delete=models.SET_NULL, @@ -174,7 +182,7 @@ class Report(models.Model): verbose_name = 'Content URL' ) -class ShowSubmission(models.Model): +class ShowSubmission(TimestampedModel): user = models.ForeignKey( User, on_delete=models.CASCADE, @@ -246,7 +254,7 @@ class Episode(models.Model): verbose_name='Original Air Date' ) -class Submission(models.Model): +class Submission(TimestampedModel): episode = models.ForeignKey( Episode, on_delete=models.CASCADE, @@ -269,7 +277,7 @@ class Submission(models.Model): max_length=200 ) -class SubmissionVote(models.Model): +class SubmissionVote(TimestampedModel): submission = models.ForeignKey( Submission, on_delete=models.CASCADE, @@ -286,7 +294,7 @@ class SubmissionVote(models.Model): help_text='If this is true, the vote is an upvote. Otherwise, it is a downvote' ) -class Favorite(models.Model): +class Favorite(TimestampedModel): user = models.ForeignKey( User, on_delete=models.CASCADE @@ -296,7 +304,7 @@ class Favorite(models.Model): on_delete=models.CASCADE ) -class Watch(models.Model): +class Watch(TimestampedModel): user = models.ForeignKey( User, on_delete=models.CASCADE @@ -306,7 +314,7 @@ class Watch(models.Model): on_delete=models.CASCADE ) -class DiscussionBoard(models.Model): +class DiscussionBoard(TimestampedModel): show = models.ForeignKey( Show, on_delete=models.CASCADE, @@ -329,7 +337,7 @@ class DiscussionBoard(models.Model): verbose_name='Body' ) -class DiscussionReply(models.Model): +class DiscussionReply(TimestampedModel): board = models.ForeignKey( DiscussionBoard, on_delete=models.CASCADE, @@ -348,7 +356,7 @@ class DiscussionReply(models.Model): verbose_name='Body' ) -class DiscussionVote(models.Model): +class DiscussionVote(TimestampedModel): user = models.ForeignKey( User, on_delete=models.CASCADE,