Commit dbc7ffa4 authored by Florent Chehab's avatar Florent Chehab

UniversityScholarship added

parent 2e677840
......@@ -11,7 +11,7 @@ package UniversityModule{
class CultureUniversity as "Culture"
class PhotoUniversity
class ScholarshipUniversity
Universityclass Scholarship
class Courses
class SpecialOffer
class OtherStuff
......@@ -39,7 +39,7 @@ package UniversityModule{
PhotoUniversity -left-|> PhotoCopyUniversity
ScholarshipUniversity -right-|> ScholarShipCopyUniversity
UniversityScholarship -right-|> ScholarShipCopyUniversity
class UniversityModules #grey
......@@ -52,7 +52,7 @@ package UniversityModule{
UniversityInfo "1" -down[bold,#green]- "1" UniversityModules
SemesterDate "1" -down[bold,#green]- "1" UniversityModules
ScholarshipUniversity "*" -left- "1" UniversityModules
UniversityScholarship "*" -left- "1" UniversityModules
}
UniversityModules -down[bold,#green]- University
......
# Generated by Django 2.0.3 on 2018-08-19 19:46
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import rex.models.tools.usefullLinksField
class Migration(migrations.Migration):
dependencies = [
('rex', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='UniversityScholarship',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('comment', models.TextField()),
('usefull_links', rex.models.tools.usefullLinksField.UsefullLinksField(validators=[rex.models.tools.usefullLinksField.validate_usefull_links])),
('type', models.CharField(max_length=200)),
('currency', models.CharField(max_length=50)),
('amount_min', models.DecimalField(decimal_places=2, max_digits=20, validators=[django.core.validators.MinValueValidator(0)])),
('amount_max', models.DecimalField(decimal_places=2, max_digits=20, validators=[django.core.validators.MinValueValidator(0)])),
('university', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='univScholarship', to='rex.University')),
],
options={
'abstract': False,
},
),
]
......@@ -6,8 +6,8 @@ from django.core.validators import MinValueValidator
class Scholarship(BasicModule):
type = models.CharField(max_length=200) # TODO add required
currency = models.CharField(max_length=50) # TODO add required
type = models.CharField(max_length=200)
currency = models.CharField(max_length=50)
amount_min = models.DecimalField(
max_digits=20,
decimal_places=2,
......
from .university import University # noqa: F401
from .campus import Campus, CampusViewSet, CampusSerializer # noqa: F401
from .universityAPI import UniversitySerializer, UniversityViewSet # noqa: F401
from .universityScholarship import UniversityScholarship, UniversityScholarshipViewSet # noqa: F401
from django.db import models
from rex.models.university import University
from rex.models.module import Scholarship
from rest_framework import serializers, viewsets, permissions
class UniversityScholarship(Scholarship):
module_name = "University Scholarship"
university = models.ForeignKey(
University, on_delete=models.PROTECT, null=False, related_name="univScholarship")
# API
class UniversityScholarshipSerializer(serializers.ModelSerializer):
modified_by = serializers.SerializerMethodField()
modified_date = serializers.SerializerMethodField()
def get_modified_by(self, obj):
return obj.modified_by()
def get_modified_date(self, obj):
return obj.modified_date()
class Meta:
model = UniversityScholarship
fields = ('university', 'modified_by', 'modified_date',
'type', 'currency', 'amount_min', 'amount_max', 'id')
class UniversityScholarshipViewSet(viewsets.ModelViewSet):
permission_classes = (permissions.DjangoModelPermissions,)
queryset = UniversityScholarship.objects.all() # pylint: disable=E1101
serializer_class = UniversityScholarshipSerializer
......@@ -2,7 +2,7 @@ from django.conf.urls import url, include
from rex import views
from rest_framework import routers
from rex.models.location import CountryViewSet, CityViewSet
from rex.models.university import CampusViewSet, UniversityViewSet
from rex.models.university import CampusViewSet, UniversityViewSet, UniversityScholarshipViewSet
from rest_framework.documentation import include_docs_urls
......@@ -17,5 +17,6 @@ router.register(r'country', CountryViewSet)
router.register(r'city', CityViewSet)
router.register(r'campus', CampusViewSet)
router.register(r'university', UniversityViewSet)
router.register(r'university_scholarship', UniversityScholarshipViewSet)
urlpatterns += [url(r'^api/', include(router.urls))]
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