class Author(models.Model): name = models.CharField(max_length=75) uuid = models.UUIDField(null=True) books = models.ArrayField(of=BookField) data = models.JSONField(default=None) created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True)
class SearchResult(models.Model): id = models.AutoField(primary_key=True) search = models.ForeignKey('Search', related_name='results') sequencenum = models.IntegerField() metadata = models.JSONField(type=dict) def __str__(self): return self.metadata.get('extract', str(self.sequencenum))
class Search(models.Model): ''' Represents one run of any of the data-searching code ''' label = models.CharField(max_length=10, primary_key=True) metadata = models.JSONField(type=dict) source = models.ForeignKey('SourceInfo', null=True, blank=True) def __str__(self): return self.label or '<untitled>'
class SourceInfo(models.Model): ''' Contains source information ''' id = models.AutoField(primary_key=True) contributor = models.CharField(max_length=200) license = models.CharField(max_length=200) date = models.DateTimeField(default=datetime.now) info = models.JSONField(type=dict, default={}) def __str__(self): return '%s under %s license' % (self.contributor, self.license)
class Task(models.Model): source = models.ForeignKey(Document) status = models.CharField(max_length=12, choices=[ (x,x) for x in ( 'completed', 'in progress', 'available', 'on hold') ]) task_group = models.ForeignKey('TaskGroup') date_completed = models.DateTimeField(null=True,blank=True) user = models.ForeignKey(User) data = models.JSONField(null=True,blank=True)
class Check(models.Model): id = models.UUIDField(auto_add=True, primary_key=True) unblocked = models.SmallIntegerField(default=0) created_at = models.DateTimeField(default=now) started_at = models.DateTimeField(null=True, blank=True) finished_at = models.DateTimeField(null=True, blank=True) requirements = models.ArrayField(models.TextField()) projects = models.ArrayField(models.CharField(max_length=255)) blockers = models.JSONField() public = models.BooleanField(default=True) runs = models.SmallIntegerField(default=0) project = models.ForeignKey(Project, related_name='checks', null=True, blank=True) class Meta: ordering = ('-finished_at',) def __str__(self): return str(self.id) def get_absolute_url(self): return reverse('check-detail', kwargs={'pk': str(self.pk)}) def clean(self): projects = OrderedDict() # using this since sets aren't ordered for requirement in self.requirements: url = urlparse(requirement) if url.scheme in ('http', 'https', 'file'): requirement = [sanitize_github_url(requirement, url)] try: for project in projects_from_requirements(requirement): projects[project] = None except: raise ValidationError("Couldn't check %s." % requirement) else: projects[requirement] = None self.projects = list(projects.keys()) for index, project_name in enumerate(self.projects): validators.RegexValidator(project_name_re, 'Project %s invalid' % project_name)(project_name)
class Song(models.Model): title = models.CharField(max_length=50) data = models.JSONField() sample_lines = models.JSONField(type=list) stuff = models.JSONField(default=None)
class TaskGroup(models.Model): description = models.CharField data = models.JSONField(null=True,blank=True)