update
This commit is contained in:
35
models.py
35
models.py
@@ -1,9 +1,37 @@
|
||||
# axc_ul/models.py
|
||||
|
||||
from django.db import models
|
||||
from django.db.models import UniqueConstraint
|
||||
|
||||
|
||||
|
||||
|
||||
class Survey(models.Model):
|
||||
|
||||
number = models.IntegerField(unique=True)
|
||||
|
||||
# nside = models.IntegerField(
|
||||
# default=4096
|
||||
# )
|
||||
|
||||
def __str__(self):
|
||||
return f"Survey {self.number} of NSIDE {self.nside}"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Pixel(models.Model):
|
||||
|
||||
id = models.AutoField(primary_key=True)
|
||||
|
||||
survey = models.ForeignKey(
|
||||
Survey,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='pixels',
|
||||
default=0
|
||||
)
|
||||
|
||||
hpid = models.IntegerField(db_index=True)
|
||||
|
||||
counts = models.IntegerField()
|
||||
@@ -12,3 +40,10 @@ class Pixel(models.Model):
|
||||
|
||||
contaminated = models.BooleanField(default=False)
|
||||
|
||||
class Meta:
|
||||
constraints = [
|
||||
UniqueConstraint(fields=['survey', 'hpid'], name='unique_hpid_per_survey'),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return f"Pixel {self.id} (Survey {self.survey.number})"
|
||||
|
Reference in New Issue
Block a user