diff --git a/ontology/models/__init__.py b/ontology/models/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..46201bd62ec45e60d74b3875b62a41e3df804dc5 --- /dev/null +++ b/ontology/models/__init__.py @@ -0,0 +1,9 @@ +__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)" +__license__ = "AGPL v3" + + +from .relations import RelationAsym, RelationSym + +from .tag import Tag + +from .topic import Topic diff --git a/ontology/models.py b/ontology/models/relations.py similarity index 53% rename from ontology/models.py rename to ontology/models/relations.py index ad853e03e9f0b1a47ff5b272caeada25d1345f3c..126ab007c702160c0ce558c4c4b6e144e1156db5 100644 --- a/ontology/models.py +++ b/ontology/models/relations.py @@ -3,41 +3,8 @@ __license__ = "AGPL v3" from django.db import models -from django.urls import reverse -from .constants import TOPIC_RELATIONS_ASYM, TOPIC_RELATIONS_SYM - - -class Tag(models.Model): - """ - Tags can be attached to a Topic to specify which category it fits. - Examples: Concept, Device, Model, Theory, ... - """ - name = models.CharField(max_length=32, unique=True) - - class Meta: - ordering = ['name'] - - def __str__(self): - return self.name - - -class Topic(models.Model): - """ - A Topic represents one of the nodes in the ontology. - """ - name = models.CharField(max_length=256, unique=True) - slug = models.SlugField(unique=True, allow_unicode=True) - tags = models.ManyToManyField('ontology.Tag', blank=True) - - class Meta: - ordering = ['name'] - - def __str__(self): - return self.name - - def get_abolute_url(self): - return reverse('ontology:topic_details', kwargs={'slug': self.slug}) +from ..constants import TOPIC_RELATIONS_ASYM, TOPIC_RELATIONS_SYM class RelationAsym(models.Model): diff --git a/ontology/models/tag.py b/ontology/models/tag.py new file mode 100644 index 0000000000000000000000000000000000000000..cb0280c64a6ecddd34e200a683a3b2487eeed014 --- /dev/null +++ b/ontology/models/tag.py @@ -0,0 +1,19 @@ +__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)" +__license__ = "AGPL v3" + + +from django.db import models + + +class Tag(models.Model): + """ + Tags can be attached to a Topic to specify which category it fits. + Examples: Concept, Device, Model, Theory, ... + """ + name = models.CharField(max_length=32, unique=True) + + class Meta: + ordering = ['name'] + + def __str__(self): + return self.name diff --git a/ontology/models/topic.py b/ontology/models/topic.py new file mode 100644 index 0000000000000000000000000000000000000000..7c6b050173ed1e5590dc049e8377c68f7c559720 --- /dev/null +++ b/ontology/models/topic.py @@ -0,0 +1,24 @@ +__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)" +__license__ = "AGPL v3" + + +from django.db import models +from django.urls import reverse + + +class Topic(models.Model): + """ + A Topic represents one of the nodes in the ontology. + """ + name = models.CharField(max_length=256, unique=True) + slug = models.SlugField(unique=True, allow_unicode=True) + tags = models.ManyToManyField('ontology.Tag', blank=True) + + class Meta: + ordering = ['name'] + + def __str__(self): + return self.name + + def get_abolute_url(self): + return reverse('ontology:topic_details', kwargs={'slug': self.slug})