VRE Backend API and Scheduler
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

88 lines
3.6 KiB

from django.db import models
from django.conf import settings
from django.utils.translation import gettext_lazy as _
from lib.models.base import MetaDataModel
# Create your models here.
class University(MetaDataModel):
"""
A model to represent a University. This model is used to combine faculties and their study fields. Also researchers are member of a university.
It will inherit the attributes :attr:`~lib.models.base.MetaDataModel.created_at` and :attr:`~lib.models.base.MetaDataModel.updated_at` from the Abstract model :class:`~lib.models.base.MetaDataModel`
Attributes
----------
name : str
The name of the university. Max length is 200 characters.
email : str
The general email address for the university. Max length is 200 characters.
website: str
The general website for the university. Max length is 200 characters.
"""
class Meta:
verbose_name = _('university')
verbose_name_plural = _('universities')
ordering = ['name']
name = models.CharField(_('Name'), max_length=200, help_text=_('The name of the university.'))
email = models.EmailField(_('Email address'), max_length=200, help_text=_('The general email address for this university.'))
website = models.CharField(_('Website'), max_length=200, help_text=_('The full url to this university website.'))
def __str__(self):
"""str: Returns a readable string for the university."""
return f'{self.name} ({self.email})'
class Faculty(MetaDataModel):
"""
A model to represent a faculty at a university and holds the study fields that are available with in this faculty.
It will inherit the attributes :attr:`~lib.models.base.MetaDataModel.created_at` and :attr:`~lib.models.base.MetaDataModel.updated_at` from the Abstract model :class:`~lib.models.base.MetaDataModel`
Attributes
----------
name : str
The name of the faculty. Max length is 200 characters.
university: University
The university where this faculty belongs to
"""
class Meta:
verbose_name = _('faculty')
verbose_name_plural = _('faculties')
ordering = ['name']
name = models.CharField(_('Name'), max_length=200, help_text=_('The name of the faculty.'))
university = models.ForeignKey(University, verbose_name=University._meta.verbose_name, on_delete=models.CASCADE, help_text=_('To wich university belongs this faculty'))
def __str__(self):
"""str: Returns a readable string for the facutlty."""
return f'{self.name} ({self.university.name})'
class StudyField(MetaDataModel):
"""
A model to represent a study field. These study fields are used for creating research studies.
It will inherit the attributes :attr:`~lib.models.base.MetaDataModel.created_at` and :attr:`~lib.models.base.MetaDataModel.updated_at` from the Abstract model :class:`~lib.models.base.MetaDataModel`
Attributes
----------
name : str
The name of the study field. Max length is 200 characters.
faculty: Faculty
The faculty where this study belongs to.
"""
class Meta:
verbose_name = _('study field')
verbose_name_plural = _('study fields')
ordering = ['name']
name = models.CharField(_('Name'), max_length=200, help_text=_('The name of the study field.'))
faculty = models.ForeignKey(Faculty, verbose_name=Faculty._meta.verbose_name, on_delete=models.CASCADE, help_text=_('To wich faculty belongs this study'))
def __str__(self):
"""str: Returns a readable string for the studyfield."""
return f'{self.name}'