Commit 97cab068 authored by Florent Chehab's avatar Florent Chehab

Scholarship module added, not tested

parent e7310329
......@@ -4,11 +4,9 @@ from reversion_compare.admin import CompareVersionAdmin
from rex.models.university import University, MainCampus
from rex.models.location import Country, City
from rex.models.module import BasicModule
admin.site.register(Country)
admin.site.register(City)
admin.site.register(BasicModule)
admin.site.register(University, CompareVersionAdmin)
admin.site.register(MainCampus, CompareVersionAdmin)
from django.db import models
from rex.models.tools import UsefullLinksField
from rex.models.module import Module
class BasicModule(models.Model):
class BasicModule(Module):
comment = models.TextField()
usefull_links = UsefullLinksField()
# class Meta:
# abstract = True
class Meta:
abstract = True
from django.db import models
from rex.models.module import BasicModule
from django.core.exceptions import ValidationError
from django.core.validators import MinValueValidator
class Scholarship(BasicModule):
type = models.CharField(required=True, max_length=200)
currency = models.CharField(required=True, max_length=50)
amount_min = models.DecimalField(
max_digits=20,
decimal_places=2,
validators=[MinValueValidator(0)]
)
amount_max = models.DecimalField(
max_digits=20,
decimal_places=2,
validators=[MinValueValidator(0)]
)
# Need custom validation
def clean(self, *args, **kwargs):
if self.amount_max < self.amount_min:
raise ValidationError(
"Amount_max should be greater or equal than amount_min")
super(Scholarship, self).clean(*args, **kwargs)
def save(self, *args, **kwargs):
self.full_clean()
super(Scholarship, self).save(*args, **kwargs)
class Meta:
abstract = True
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