achievement.py 1.0 KB

12345678910111213141516171819
  1. from django.db import models
  2. from webservice_running.models import Sportsman, Achievements
  3. class Achievement(models.Model):
  4. """
  5. Achievement (not to confuse with 'Achievements') stores information about achievement history of users.
  6. Соединяющая таблица пользователя и достижения для истории полученных достижений у конкретного пользователя.
  7. """
  8. sportsman = models.ForeignKey(Sportsman, on_delete=models.DO_NOTHING, related_name="sportsman_achievement")
  9. achievement = models.ForeignKey(Achievements, on_delete=models.DO_NOTHING, related_name="achievement")
  10. time_received = models.DateTimeField(auto_now_add=True)
  11. class Meta:
  12. db_table = "achievement"
  13. verbose_name = "достижение пользователя"
  14. verbose_name_plural = "достижения пользователя"
  15. constraints = [
  16. models.UniqueConstraint(fields=['sportsman', 'achievement'], name='unique_achievement')
  17. ]