Skip to content

Commit

Permalink
Fixed models.py and added to admin.py
Browse files Browse the repository at this point in the history
  • Loading branch information
zachHarpaz committed Sep 29, 2024
1 parent e0dbbff commit 3c8596f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions backend/penndata/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
FitnessRoom,
FitnessSnapshot,
HomePageOrder,
GlobalStat,
IndividualStat
)


Expand All @@ -25,3 +27,5 @@ def image_tag(self, instance):
admin.site.register(FitnessRoom, FitnessRoomAdmin)
admin.site.register(FitnessSnapshot)
admin.site.register(AnalyticsEvent)
admin.site.register(GlobalStat)
admin.site.register(IndividualStat)
14 changes: 7 additions & 7 deletions backend/penndata/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,24 @@ def __str__(self):


# Adding statistics tracking here
class GlobalStats(models.Model):
stat_key = models.CharField(max_length=50, on_delete=models.CASCADE,
class GlobalStat(models.Model):
stat_key = models.CharField(max_length=50,
null=False, blank=False)
stat_value = models.CharField(max_length=50, on_delete=models.CASCADE,
stat_value = models.CharField(max_length=50,
null=False, blank=False)
year = models.IntegerField()

class Meta:
unique_together = ("stat_key", "year")

def __str__(self):
return f"Global -- {self.stat_key}-{str(self.year)} : {self.stat_value}"

class IndividualStats(models.Model):
class IndividualStat(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
stat_key = models.CharField(max_length=50, on_delete=models.CASCADE,
stat_key = models.CharField(max_length=50,
null=False, blank=False)
stat_value = models.CharField(max_length=50, on_delete=models.CASCADE,
stat_value = models.CharField(max_length=50,
null=False, blank=False)
year = models.IntegerField()

Expand Down

0 comments on commit 3c8596f

Please sign in to comment.