Commit c4fb7e40 authored by Florent Chehab's avatar Florent Chehab

Scholarship model update with currency

parent 8009e70d
Pipeline #26318 passed with stages
in 1 minute and 25 seconds
from django.contrib import admin
from reversion_compare.admin import CompareVersionAdmin
from rex.models.university import University, Campus
from rex.models.university import University, Campus, UniversityScholarship
from rex.models.location import Country, City
......@@ -10,3 +10,4 @@ admin.site.register(City)
admin.site.register(University, CompareVersionAdmin)
admin.site.register(Campus, CompareVersionAdmin)
admin.site.register(UniversityScholarship, CompareVersionAdmin)
# Generated by Django 2.0.3 on 2018-08-20 15:00
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('rex', '0003_currency'),
]
operations = [
migrations.AlterField(
model_name='universityscholarship',
name='currency',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='rex.Currency'),
),
]
# Generated by Django 2.0.3 on 2018-08-20 15:02
from django.db import migrations, models
import rex.models.tools.usefullLinksField
class Migration(migrations.Migration):
dependencies = [
('rex', '0004_auto_20180820_1700'),
]
operations = [
migrations.AlterField(
model_name='universityscholarship',
name='comment',
field=models.TextField(blank=True),
),
migrations.AlterField(
model_name='universityscholarship',
name='usefull_links',
field=rex.models.tools.usefullLinksField.UsefullLinksField(null=True, validators=[rex.models.tools.usefullLinksField.validate_usefull_links]),
),
]
# Generated by Django 2.0.3 on 2018-08-20 15:15
from django.db import migrations
import rex.models.tools.usefullLinksField
class Migration(migrations.Migration):
dependencies = [
('rex', '0005_auto_20180820_1702'),
]
operations = [
migrations.AlterField(
model_name='universityscholarship',
name='usefull_links',
field=rex.models.tools.usefullLinksField.UsefullLinksField(blank=True, default=[], validators=[rex.models.tools.usefullLinksField.validate_usefull_links]),
),
]
......@@ -5,8 +5,8 @@ from rex.models.module import Module
class BasicModule(Module):
comment = models.TextField()
usefull_links = UsefullLinksField()
comment = models.TextField(blank=True)
usefull_links = UsefullLinksField(blank=True)
class Meta:
abstract = True
from django.db import models
from rex.models.module import BasicModule
from rex.models.module.currency import Currency
from django.core.exceptions import ValidationError
from django.core.validators import MinValueValidator
......@@ -7,7 +8,7 @@ from django.core.validators import MinValueValidator
class Scholarship(BasicModule):
type = models.CharField(max_length=200)
currency = models.CharField(max_length=50)
currency = models.ForeignKey(Currency, on_delete=models.PROTECT)
amount_min = models.DecimalField(
max_digits=20,
decimal_places=2,
......
......@@ -32,4 +32,5 @@ class UsefullLinksField(JSONField):
def __init__(self, *args, **kwargs):
kwargs['validators'] = [validate_usefull_links]
kwargs['default'] = []
super(UsefullLinksField, self).__init__(*args, **kwargs)
......@@ -24,7 +24,7 @@ class UniversityScholarshipSerializer(serializers.ModelSerializer):
class Meta:
model = UniversityScholarship
fields = ('university', 'modified_by', 'modified_date',
fields = ('university', 'modified_by', 'modified_date', 'comment', 'usefull_links',
'type', 'currency', 'amount_min', 'amount_max', 'id')
......
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