models.py 815 B

12345678910111213141516171819202122232425262728
  1. from django.db import models
  2. from glitchtip.base_models import CreatedModel
  3. class EnvironmentProject(CreatedModel):
  4. project = models.ForeignKey("projects.Project", on_delete=models.CASCADE)
  5. environment = models.ForeignKey(
  6. "environments.Environment", on_delete=models.CASCADE
  7. )
  8. is_hidden = models.BooleanField(default=False)
  9. class Meta:
  10. unique_together = ("project", "environment")
  11. class Environment(CreatedModel):
  12. name = models.CharField(max_length=256)
  13. organization = models.ForeignKey(
  14. "organizations_ext.Organization", on_delete=models.CASCADE
  15. )
  16. projects = models.ManyToManyField("projects.Project", through=EnvironmentProject)
  17. class Meta:
  18. unique_together = ("organization", "name")
  19. def __str__(self):
  20. return self.name