Skip to content

Commit

Permalink
Add models
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyansh23 committed Oct 24, 2018
0 parents commit b84f3fc
Show file tree
Hide file tree
Showing 82 changed files with 1,125 additions and 0 deletions.
Empty file added __init__.py
Empty file.
Binary file added __pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file added __pycache__/admin.cpython-36.pyc
Binary file not shown.
Binary file added __pycache__/apps.cpython-36.pyc
Binary file not shown.
Binary file added __pycache__/http_urls.cpython-36.pyc
Binary file not shown.
Binary file added __pycache__/ws_urls.cpython-36.pyc
Binary file not shown.
37 changes: 37 additions & 0 deletions admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import swapper

from kernel.admin.site import omnipotence

Education = swapper.load_model('faculty_biodata', 'Education')
Honor = swapper.load_model('faculty_biodata', 'Honor')
Visit = swapper.load_model('faculty_biodata', 'Visit')
Collaboration = swapper.load_model('faculty_biodata', 'Collaboration')
Project = swapper.load_model('faculty_biodata', 'Project')
AssociateScholar = swapper.load_model('faculty_biodata', 'AssociateScholar')
Supervision = swapper.load_model('faculty_biodata', 'Supervision')
TeachingEngagement = swapper.load_model(
'faculty_biodata', 'TeachingEngagement')
Event = swapper.load_model('faculty_biodata', 'Event')
Interest = swapper.load_model('faculty_biodata', 'Interest')
AdministrativePosition = swapper.load_model(
'faculty_biodata',
'AdministrativePosition'
)
Membership = swapper.load_model('faculty_biodata', 'Membership')
# Book = swapper.load_model('faculty_biodata', 'Book')
# Paper = swapper.load_model('faculty_biodata', 'Paper')

omnipotence.register(Education)
omnipotence.register(Honor)
omnipotence.register(Visit)
omnipotence.register(Collaboration)
omnipotence.register(Project)
omnipotence.register(AssociateScholar)
omnipotence.register(Supervision)
omnipotence.register(TeachingEngagement)
omnipotence.register(Event)
omnipotence.register(Interest)
omnipotence.register(AdministrativePosition)
omnipotence.register(Membership)
# omnipotence.register(Book)
# omnipotence.register(Paper)
5 changes: 5 additions & 0 deletions apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class FacultyBiodataConfig(AppConfig):
name = 'faculty_biodata'
3 changes: 3 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nomenclature:
name: faculty_biodata
verboseName: Faculty biodata
Empty file added constants/__init__.py
Empty file.
Binary file added constants/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file not shown.
Binary file added constants/__pycache__/event_roles.cpython-36.pyc
Binary file not shown.
Binary file added constants/__pycache__/project_types.cpython-36.pyc
Binary file not shown.
Binary file added constants/__pycache__/scopes.cpython-36.pyc
Binary file not shown.
Binary file added constants/__pycache__/supervision.cpython-36.pyc
Binary file not shown.
15 changes: 15 additions & 0 deletions constants/event_categories.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Event categories
CONFERENCE = 'con'
GUEST_LECTURE = 'gue'
SEMINAR = 'sem'
SHORT_TERM_COURSE = 'stc'
SPECIAL_LECTURE = 'spl'
TALK = 'tlk'
EVENT_CATEGORIES = (
(CONFERENCE, 'Conference'),
(GUEST_LECTURE, 'Guest lecture'),
(SEMINAR, 'Seminar'),
(SHORT_TERM_COURSE, 'Short term course'),
(SPECIAL_LECTURE, 'Special lecture'),
(TALK, 'Talk'),
)
7 changes: 7 additions & 0 deletions constants/event_roles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Event roles
ORGANISER = 'o'
ATTENDEE = 'a'
EVENT_ROLES = (
(ORGANISER, 'Organiser'),
(ATTENDEE, 'Attendee'),
)
7 changes: 7 additions & 0 deletions constants/project_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Research project types
SPONSORED = 's'
CONSULTANCY = 'c'
PROJECT_TYPES = (
(SPONSORED, 'Sponsored'),
(CONSULTANCY, 'Consultancy'),
)
11 changes: 11 additions & 0 deletions constants/scopes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Scope choices for administrative positions
DEPARTMENTAL = 'd'
CENTRAL = 'c'
INSTITUTE = 'i'
EXTERNAL = 'e'
SCOPES = (
(DEPARTMENTAL, 'Departmental'),
(INSTITUTE, 'Central'),
(INSTITUTE, 'Institute'),
(EXTERNAL, 'External')
)
7 changes: 7 additions & 0 deletions constants/supervision.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Supervision categories
PROJECT = 'pro'
DOCTORATE = 'doc'
SUPERVISION_CATEGORIES = (
(PROJECT, 'Project'),
(DOCTORATE, 'Doctorate'),
)
1 change: 1 addition & 0 deletions http_urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
urlpatterns = []
301 changes: 301 additions & 0 deletions migrations/0001_initial.py

Large diffs are not rendered by default.

Empty file added migrations/__init__.py
Empty file.
Binary file not shown.
Binary file added migrations/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Empty file added mixins/__init__.py
Empty file.
Binary file added mixins/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file added mixins/__pycache__/organisation_mixin.cpython-36.pyc
Binary file not shown.
18 changes: 18 additions & 0 deletions mixins/organisation_mixin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from django.db import models


class OrganisationMixin(models.Model):
"""
This mixin adds the organisation field to the model
"""

organisation = models.CharField(
max_length=127,
)

class Meta:
"""
Meta class for OrganisationMixin
"""

abstract = True
1 change: 1 addition & 0 deletions models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from faculty_biodata.models import accomplishments, engagements, events, publications, miscellaneous
Binary file added models/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions models/abstract_classes/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from faculty_biodata.models.abstract_classes.base_model import BaseModel
Binary file not shown.
Binary file not shown.
39 changes: 39 additions & 0 deletions models/abstract_classes/base_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import swapper
from django.db import models

from kernel.models.root import Model


class BaseModel(Model):
"""
This abstract model contains the common fields of models
"""

faculty_member = models.ForeignKey(
to=swapper.get_model_name('kernel', 'FacultyMember'),
on_delete=models.CASCADE,
)

priority = models.IntegerField(
default=0,
)

visibility = models.BooleanField(
default=True,
)

class Meta:
"""
Meta class for BaseModel
"""

abstract = True

def __str__(self):
"""
Return the string representation of the model
:return: the string representation of the model
"""

faculty_member = self.faculty_member
return f'{faculty_member}'
Binary file added models/accomplishments/.__init__.py.swp
Binary file not shown.
14 changes: 14 additions & 0 deletions models/accomplishments/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from faculty_biodata.models.accomplishments.education import (
AbstractEducation,
Education,
)

from faculty_biodata.models.accomplishments.honor import (
AbstractHonor,
Honor,
)

from faculty_biodata.models.accomplishments.visit import (
AbstractVisit,
Visit
)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
28 changes: 28 additions & 0 deletions models/accomplishments/education.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import swapper

from common_biodata.models.accomplishments.education import AbstractEducation
from faculty_biodata.models.abstract_classes.base_model import BaseModel


class Education(AbstractEducation, BaseModel):
"""
This model contains information about the education of a faculty member
"""

class Meta:
"""
Meta class for AbstractEducation
"""

verbose_name_plural = 'education'
swappable = swapper.swappable_setting('faculty_biodata', 'Education')

def __str__(self):
"""
Return the string representation of the model
:return: the string representation of the model
"""

faculty_member = self.faculty_member
string = super().__str__()
return f'{faculty_member} : {string}'
47 changes: 47 additions & 0 deletions models/accomplishments/honor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import swapper
from django.db import models

from faculty_biodata.mixins.organisation_mixin import OrganisationMixin
from faculty_biodata.models.abstract_classes.base_model import BaseModel


class AbstractHonor(OrganisationMixin, BaseModel):
"""
This model holds the honors awarded to the faculty member
"""

award = models.CharField(
max_length=255,
)

year = models.IntegerField()

class Meta:
"""
Meta class for AbstractHonor
"""

abstract = True

def __str__(self):
"""
Return the string representation of the model
:return: the string representation of the model
"""

faculty_member = self.faculty_member
award = self.award
return f'{faculty_member}: {award}'


class Honor(AbstractHonor):
"""
This class implements AbstractHonor
"""

class Meta:
"""
Meta class for Honor
"""

swappable = swapper.swappable_setting('faculty_biodata', 'Honor')
53 changes: 53 additions & 0 deletions models/accomplishments/visit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import swapper
from django.db import models

from faculty_biodata.models.abstract_classes.base_model import BaseModel


class AbstractVisit(BaseModel):
"""
This model contains the visits by the faculty member
"""

purpose = models.CharField(
max_length=255,
)

place = models.CharField(
max_length=255,
)

date = models.DateField(
blank=True,
null=True,
)

class Meta:
"""
Meta class for AbstractVisit
"""

abstract = True

def __str__(self):
"""
Return the string representation of the model
:return: the string representation of the model
"""

faculty_member = self.faculty_member
place = self.place
return f'{faculty_member}: {place}'


class Visit(AbstractVisit):
"""
This class implements AbstractVisit
"""

class Meta:
"""
Meta class for Visit
"""

swappable = swapper.swappable_setting('faculty_biodata', 'Visit')
23 changes: 23 additions & 0 deletions models/engagements/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from faculty_biodata.models.engagements.collaboration import (
AbstractCollaboration,
Collaboration
)
from faculty_biodata.models.engagements.project import (
AbstractProject,
Project,
)
from faculty_biodata.models.engagements.associate_scholar import (
AbstractAssociateScholar,
AssociateScholar,
)
from faculty_biodata.models.engagements.supervision import (
AbstractSupervision,
Supervision,
)
from faculty_biodata.models.engagements.teaching import (
AbstractTeachingEngagement,
TeachingEngagement,
)
from faculty_biodata.models.engagements import (
positions,
)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
46 changes: 46 additions & 0 deletions models/engagements/associate_scholar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import swapper
from django.db import models

from faculty_biodata.models.abstract_classes.base_model import BaseModel


class AbstractAssociateScholar(BaseModel):
"""
This model contains a research scholar associated with the faculty member
"""

scholar = models.ForeignKey(
to=swapper.get_model_name('kernel', 'Student'),
on_delete=models.CASCADE,
)

class Meta:
"""
Meta class for AbstractAssociateScholar
"""

abstract = True

def __str__(self):
"""
Return the string representation of the model
:return: the string representation of the model
"""

faculty_member = self.faculty_member
scholar = self.scholar
return f'{faculty_member} - {scholar}'


class AssociateScholar(AbstractAssociateScholar):
"""
This class implements AbstractAssociateScholar
"""

class Meta:
"""
Meta class for AssociateScholar
"""

swappable = swapper.swappable_setting('faculty_biodata',
'AssociateScholar')
Loading

0 comments on commit b84f3fc

Please sign in to comment.