Skip to content

Commit

Permalink
Remove null parameter and refactor code
Browse files Browse the repository at this point in the history
* CharField will store an empty string if no choice is selected
  • Loading branch information
algomaster99 committed Jun 24, 2020
1 parent f9683c4 commit 2f126b4
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion constants/collaboration_types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Collaboration Types
# Collaboration types
UNDERGRADUATE = 'ug'
POSTGRADUATE = 'pg'
DOCTORATE = 'phd'
Expand Down
7 changes: 7 additions & 0 deletions constants/phd_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# PhD Types
FULLTIME = 'f'
PARTTIME = 'p'
PHD_TYPES = (
(FULLTIME, 'Fulltime'),
(PARTTIME, 'Parttime'),
)
2 changes: 1 addition & 1 deletion constants/semesters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Semesters Types
# Semester types
SPRING = 's'
AUTUMN = 'a'
SEMESTER_TYPES = (
Expand Down
8 changes: 0 additions & 8 deletions constants/supervision.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,3 @@
(PROJECT, 'Project'),
(DOCTORATE, 'Doctorate'),
)

# PhD Types
FULLTIME = 'f'
PARTTIME = 'p'
PHD_TYPES = (
(FULLTIME, 'Fulltime'),
(PARTTIME, 'Parttime'),
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 2.2.6 on 2020-06-24 09:07
# Generated by Django 3.0.3 on 2020-06-24 21:23

from django.db import migrations, models

Expand All @@ -13,12 +13,12 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='collaboration',
name='level',
field=models.CharField(choices=[('ug', 'Undergraduate'), ('pg', 'Postgraduate'), ('phd', 'PhD'), ('rp', 'Research Project'), ('oth', 'Other')], default='oth', max_length=3),
field=models.CharField(blank=True, choices=[('ug', 'Undergraduate'), ('pg', 'Postgraduate'), ('phd', 'PhD'), ('rp', 'Research Project'), ('oth', 'Other')], max_length=3),
),
migrations.AddField(
model_name='supervision',
name='phd_type',
field=models.CharField(blank=True, choices=[('f', 'Fulltime'), ('p', 'Parttime')], max_length=1, null=True),
field=models.CharField(blank=True, choices=[('f', 'Fulltime'), ('p', 'Parttime')], max_length=1),
),
migrations.AddField(
model_name='teachingengagement',
Expand Down
2 changes: 1 addition & 1 deletion models/engagements/collaboration.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AbstractCollaboration(OrganisationMixin, BaseModel):
level = models.CharField(
max_length=3,
choices=COLLABORATION_TYPES,
default=OTHER,
blank=True,
)

class Meta:
Expand Down
7 changes: 4 additions & 3 deletions models/engagements/supervision.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import swapper
from django.db import models

from faculty_biodata.constants.supervision import SUPERVISION_CATEGORIES, PHD_TYPES
from faculty_biodata.models.abstract_classes.base_model import BaseModel
from formula_one.mixins.period_mixin import BlurryPeriodMixin

from faculty_biodata.models.abstract_classes.base_model import BaseModel
from faculty_biodata.constants.supervision import SUPERVISION_CATEGORIES
from faculty_biodata.constants.phd_types import PHD_TYPES


class AbstractSupervision(BlurryPeriodMixin, BaseModel):
"""
Expand All @@ -25,7 +27,6 @@ class AbstractSupervision(BlurryPeriodMixin, BaseModel):
max_length=1,
choices=PHD_TYPES,
blank=True,
null=True,
)

name_of_other_supervisors = models.TextField(
Expand Down

0 comments on commit 2f126b4

Please sign in to comment.