Commit c776e24f authored by Florent Chehab's avatar Florent Chehab

Bug corrected and importance level added

parent 9c099cdf
# Generated by Django 2.0.3 on 2018-09-09 12:55
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('backend', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='campus',
name='importance_level',
field=models.CharField(choices=[('-', 'normal'), ('+', 'important'), ('++', 'IMPORTANT')], default='-', max_length=2),
),
migrations.AddField(
model_name='countrydri',
name='importance_level',
field=models.CharField(choices=[('-', 'normal'), ('+', 'important'), ('++', 'IMPORTANT')], default='-', max_length=2),
),
migrations.AddField(
model_name='countryscholarship',
name='importance_level',
field=models.CharField(choices=[('-', 'normal'), ('+', 'important'), ('++', 'IMPORTANT')], default='-', max_length=2),
),
migrations.AddField(
model_name='universitydri',
name='importance_level',
field=models.CharField(choices=[('-', 'normal'), ('+', 'important'), ('++', 'IMPORTANT')], default='-', max_length=2),
),
migrations.AddField(
model_name='universityinfo',
name='importance_level',
field=models.CharField(choices=[('-', 'normal'), ('+', 'important'), ('++', 'IMPORTANT')], default='-', max_length=2),
),
migrations.AddField(
model_name='universityscholarship',
name='importance_level',
field=models.CharField(choices=[('-', 'normal'), ('+', 'important'), ('++', 'IMPORTANT')], default='-', max_length=2),
),
migrations.AddField(
model_name='universitysemestersdates',
name='importance_level',
field=models.CharField(choices=[('-', 'normal'), ('+', 'important'), ('++', 'IMPORTANT')], default='-', max_length=2),
),
]
......@@ -4,11 +4,22 @@ from backend.models.tools import JSONField
from backend.models.tag.tagged_item_validation import validate_content_against_config
from backend.models.tag.tags_config import USEFULL_LINKS_CONFIG
IMPORTANCE_LEVEL = (
('-', 'normal'),
('+', 'important'),
('++', 'IMPORTANT')
)
class BasicModule(MyModelVersionned):
comment = models.TextField(blank=True)
usefull_links = JSONField(default=list)
importance_level = models.CharField(
max_length=2,
choices=IMPORTANCE_LEVEL,
default='-',
)
class Meta:
abstract = True
......
......@@ -28,6 +28,7 @@ class Scholarship(BasicModule):
class ScholarshipSerializer(BasicModuleSerializer):
def my_validate(self, attrs):
attrs = super(ScholarshipSerializer, self).my_validate(attrs)
if attrs['amount_max'] < attrs['amount_min']:
raise serializers.ValidationError(
"Amount_max should be greater or equal than amount_min")
......
......@@ -29,6 +29,8 @@ class UniversitySemestersDates(BasicModule):
class UniversitySemestersDatesSerializer(BasicModuleSerializer):
def my_validate(self, attrs):
attrs = super(UniversitySemestersDatesSerializer, self).my_validate(attrs)
s_b, s_e = attrs['spring_begin'], attrs['spring_end']
a_b, a_e = attrs['autumn_begin'], attrs['autumn_end']
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment