models.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. from django.db import models
  2. from glitchtip.base_models import CreatedModel
  3. class Release(CreatedModel):
  4. organization = models.ForeignKey(
  5. "organizations_ext.Organization", on_delete=models.CASCADE
  6. )
  7. projects = models.ManyToManyField("projects.Project", related_name="releases")
  8. version = models.CharField(max_length=255)
  9. ref = models.CharField(
  10. max_length=255, null=True, blank=True, help_text="May be branch or tag name"
  11. )
  12. url = models.URLField(null=True, blank=True)
  13. released = models.DateTimeField(null=True, blank=True)
  14. data = models.JSONField(default=dict)
  15. owner = models.ForeignKey(
  16. "users.User",
  17. null=True,
  18. blank=True,
  19. on_delete=models.SET_NULL,
  20. help_text="Release manager - the person initiating the release",
  21. )
  22. commit_count = models.PositiveSmallIntegerField(default=0)
  23. # last commit - not implemented
  24. # authors - not implemented
  25. deploy_count = models.PositiveSmallIntegerField(default=0)
  26. # last_deploy - not implemented
  27. files = models.ManyToManyField(
  28. "files.File",
  29. through="sourcecode.DebugSymbolBundle",
  30. through_fields=["release", "file"],
  31. )
  32. class Meta:
  33. unique_together = ("organization", "version")
  34. class ReleaseProject(models.Model):
  35. """Through model may be used to store cached event counts in the future"""
  36. project = models.ForeignKey("projects.Project", on_delete=models.CASCADE)
  37. release = models.ForeignKey(Release, on_delete=models.CASCADE)
  38. class Meta:
  39. unique_together = ("project", "release")