Code

Ticket #1808: models.py

File models.py, 1.2 KB (added by mhalle@…, 8 years ago)
Line 
1from django.db import models
2
3class Institution(models.Model):
4    name = models.CharField(maxlength=200, core=True)
5    reference_url = models.CharField(maxlength=200, core=True)
6    class Admin:   # because of this field, no error here
7        pass
8
9    def __repr__(self):
10        return self.name
11
12class License(models.Model):
13    # no Admin class will produce an error when added
14    title = models.CharField(maxlength=200)
15    reference_url = models.URLField()
16    description = models.TextField()
17    def __repr__(self):
18        return self.title
19
20class OperatingSystem(models.Model):
21    # no Admin class: no way to add this object as a subpart of SoftwarePackage   
22    name = models.CharField(maxlength=200, core=True)
23    def __repr__(self):
24        return self.name
25   
26class SoftwarePackage(models.Model):
27    title = models.CharField(maxlength=200)
28    institution = models.ForeignKey(Institution, null=True)
29    license = models.ForeignKey(License, null=True)
30    operating_system = models.ManyToManyField(OperatingSystem, null=True)
31    open_source = models.BooleanField()
32
33    def __repr__(self):
34        return self.title
35    class Admin:
36        pass
37   
38