Guest User

dfewrt43few

a guest
Apr 2nd, 2019
11
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #plik models.py
  2.  
  3. class Player(models.Model):
  4.  
  5.     name = models.CharField(max_length=30)
  6.     user = models.ForeignKey(User, null=True, blank=True, on_delete=models.SET_NULL)
  7.     # tu jeszcze sporo pól ale dla czytelności nie warto wypisywać
  8.     def __str__(self):
  9.         if self.user is not None:
  10.             return self.name + "(" + self.user + ")"
  11.         return self.name
  12.  
  13. class Leaderboard(models.Model):
  14.  
  15.     date_published = models.DateTimeField()
  16.     description = models.TextField(null=True, blank=True)
  17.     scenario = models.ForeignKey(Scenario, null=True, blank=True, on_delete=models.SET_NULL)
  18.     players = models.ManyToManyField(Player, through="PlayerLeaderboard", related_name="Players")
  19.  
  20. class PlayerLeaderboard(models.Model):
  21.  
  22.     player = models.ForeignKey(Player, on_delete=models.CASCADE)
  23.     leaderboard = models.ForeignKey(Leaderboard, on_delete=models.CASCADE)
  24.     is_host = models.BooleanField(default=False)
  25.  
  26. # są jeszcze inne klasy ale nie są one znaczące do pytania
RAW Paste Data