models.py 905 B

12345678910111213141516171819202122232425262728
  1. from django.db import models
  2. class EnvironmentProject(models.Model):
  3. project = models.ForeignKey("projects.Project", on_delete=models.CASCADE)
  4. environment = models.ForeignKey(
  5. "environments.Environment", on_delete=models.CASCADE
  6. )
  7. is_hidden = models.BooleanField(default=False)
  8. created = models.DateTimeField(auto_now_add=True, db_index=True)
  9. class Meta:
  10. unique_together = ("project", "environment")
  11. class Environment(models.Model):
  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. created = models.DateTimeField(auto_now_add=True, db_index=True)
  18. class Meta:
  19. unique_together = ("organization", "name")
  20. def __str__(self):
  21. return self.name