Commit 0b4867c0 authored by Florent Chehab's avatar Florent Chehab

UniversityInsurance added

parent 4a48c1ce
...@@ -10,10 +10,11 @@ package UniversityModule{ ...@@ -10,10 +10,11 @@ package UniversityModule{
abstract class ScholarShipCopyUniversity as "Scholarship" #red abstract class ScholarShipCopyUniversity as "Scholarship" #red
class CultureUniversity as "Culture" class CultureUniversity as "Culture"
class PhotoUniversity class PhotoUniversity
class Courses class Courses
class SpecialOffer class SpecialOffer
class OtherStuff class OtherStuff
class Insurances
class SemestersDates{ class SemestersDates{
+ autumn_begin : date + autumn_begin : date
...@@ -23,19 +24,20 @@ package UniversityModule{ ...@@ -23,19 +24,20 @@ package UniversityModule{
} }
class UniversityInfo{ class UniversityInfo{
+ cost_exchange : float + cost_exchange : float
+ cost_double_degree : float + cost_double_degree : float
} }
CultureUniversity -up-|> BasicModuleCopyUniversity CultureUniversity -up-|> BasicModuleCopyUniversity
Courses -up-|> BasicModuleCopyUniversity Courses -up-|> BasicModuleCopyUniversity
SpecialOffer -up-|> BasicModuleCopyUniversity SpecialOffer -up-|> BasicModuleCopyUniversity
OtherStuff -up-|> BasicModuleCopyUniversity OtherStuff -up-|> BasicModuleCopyUniversity
Insurances -up-|> BasicModuleCopyUniversity
SemestersDates -up-|> BasicModuleCopyUniversity SemestersDates -up-|> BasicModuleCopyUniversity
UniversityInfo -up-|> BasicModuleCopyUniversity UniversityInfo -up-|> BasicModuleCopyUniversity
PhotoUniversity -left-|> PhotoCopyUniversity PhotoUniversity -left-|> PhotoCopyUniversity
UniversityScholarship -right-|> ScholarShipCopyUniversity UniversityScholarship -right-|> ScholarShipCopyUniversity
class UniversityVirtualCopy as "University" < copy for\n cleaner UML> #lightgrey class UniversityVirtualCopy as "University" < copy for\n cleaner UML> #lightgrey
...@@ -45,6 +47,7 @@ package UniversityModule{ ...@@ -45,6 +47,7 @@ package UniversityModule{
PhotoUniversity "1" -right[bold,#green]- "1" UniversityVirtualCopy PhotoUniversity "1" -right[bold,#green]- "1" UniversityVirtualCopy
Courses "1" -down[bold,#green]- "1" UniversityVirtualCopy Courses "1" -down[bold,#green]- "1" UniversityVirtualCopy
OtherStuff "1" -down[bold,#green]- "1" UniversityVirtualCopy OtherStuff "1" -down[bold,#green]- "1" UniversityVirtualCopy
Insurances "1" -down[bold,#green]- "1" UniversityVirtualCopy
SpecialOffer "1" -down[bold,#green]- "1" UniversityVirtualCopy SpecialOffer "1" -down[bold,#green]- "1" UniversityVirtualCopy
UniversityInfo "1" -down[bold,#green]- "1" UniversityVirtualCopy UniversityInfo "1" -down[bold,#green]- "1" UniversityVirtualCopy
SemestersDates "1" -down[bold,#green]- "1" UniversityVirtualCopy SemestersDates "1" -down[bold,#green]- "1" UniversityVirtualCopy
......
...@@ -4,6 +4,7 @@ from reversion_compare.admin import CompareVersionAdmin ...@@ -4,6 +4,7 @@ from reversion_compare.admin import CompareVersionAdmin
from rex.models.university import University, Campus, UniversityScholarship from rex.models.university import University, Campus, UniversityScholarship
from rex.models.university import UniversityInfo from rex.models.university import UniversityInfo
from rex.models.university import SemestersDates from rex.models.university import SemestersDates
from rex.models.university import UniversityInsurance
from rex.models.location import Country, City from rex.models.location import Country, City
...@@ -15,3 +16,4 @@ admin.site.register(Campus, CompareVersionAdmin) ...@@ -15,3 +16,4 @@ admin.site.register(Campus, CompareVersionAdmin)
admin.site.register(UniversityScholarship, CompareVersionAdmin) admin.site.register(UniversityScholarship, CompareVersionAdmin)
admin.site.register(UniversityInfo, CompareVersionAdmin) admin.site.register(UniversityInfo, CompareVersionAdmin)
admin.site.register(SemestersDates, CompareVersionAdmin) admin.site.register(SemestersDates, CompareVersionAdmin)
admin.site.register(UniversityInsurance, CompareVersionAdmin)
# Generated by Django 2.0.3 on 2018-08-20 17:01
from django.db import migrations, models
import django.db.models.deletion
import rex.models.tools.usefullLinksField
class Migration(migrations.Migration):
dependencies = [
('rex', '0010_auto_20180820_1830'),
]
operations = [
migrations.CreateModel(
name='UniversityInsurance',
fields=[
('comment', models.TextField(blank=True)),
('usefull_links', rex.models.tools.usefullLinksField.UsefullLinksField(blank=True, default=[], validators=[rex.models.tools.usefullLinksField.validate_usefull_links])),
('university', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, related_name='university_insurances', serialize=False, to='rex.University')),
],
options={
'abstract': False,
},
),
]
from .module import Module # noqa: F401 from .module import Module # noqa: F401
from .basicModule import BasicModule # noqa: F401 from .basicModule import BasicModule, BasicModuleSerializer # noqa: F401
from .scholarship import Scholarship # noqa: F401 from .scholarship import Scholarship # noqa: F401
from django.db import models from django.db import models
from rex.models.tools import UsefullLinksField from rex.models.tools import UsefullLinksField
from rex.models.module import Module from rex.models.module import Module
from rest_framework import serializers
class BasicModule(Module): class BasicModule(Module):
...@@ -10,3 +11,18 @@ class BasicModule(Module): ...@@ -10,3 +11,18 @@ class BasicModule(Module):
class Meta: class Meta:
abstract = True abstract = True
class BasicModuleSerializer(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 = BasicModule
fields = ('comment', 'usefull_links', 'modified_by', 'modified_date')
...@@ -4,3 +4,4 @@ from .universityAPI import UniversitySerializer, UniversityViewSet # noqa: F401 ...@@ -4,3 +4,4 @@ from .universityAPI import UniversitySerializer, UniversityViewSet # noqa: F401
from .universityScholarship import UniversityScholarship, UniversityScholarshipViewSet # noqa: F401 from .universityScholarship import UniversityScholarship, UniversityScholarshipViewSet # noqa: F401
from .universityInfo import UniversityInfo, UniversityInfoViewSet # noqa: F401 from .universityInfo import UniversityInfo, UniversityInfoViewSet # noqa: F401
from .semestersDates import SemestersDates, SemestersDatesViewSet # noqa: F401 from .semestersDates import SemestersDates, SemestersDatesViewSet # noqa: F401
from .basicModulesUniversity import UniversityInsurance, UniversityInsuranceViewSet # noqa: F401
from django.db import models
from rex.models.module import BasicModule
from rex.models.university import University
from rest_framework import viewsets, permissions
from rex.models.module import BasicModuleSerializer
class UniversityInsurance(BasicModule):
university = models.OneToOneField(
University, on_delete=models.CASCADE, related_name='university_insurances', primary_key=True)
class UniversityInsuranceSerializer(BasicModuleSerializer):
class Meta:
model = UniversityInsurance
fields = '__all__'
class UniversityInsuranceViewSet(viewsets.ModelViewSet): # TODO switch to dict
permission_classes = (permissions.DjangoModelPermissions,)
queryset = UniversityInsurance.objects.all() # pylint: disable=E1101
serializer_class = UniversityInsuranceSerializer
#####################
...@@ -8,6 +8,7 @@ from rex.models.university import CampusViewSet ...@@ -8,6 +8,7 @@ from rex.models.university import CampusViewSet
from rex.models.university import UniversityScholarshipViewSet from rex.models.university import UniversityScholarshipViewSet
from rex.models.university import UniversityInfoViewSet from rex.models.university import UniversityInfoViewSet
from rex.models.university import SemestersDatesViewSet from rex.models.university import SemestersDatesViewSet
from rex.models.university import UniversityInsuranceViewSet
from rex.models.tools import CurrencyViewSet from rex.models.tools import CurrencyViewSet
from rest_framework.documentation import include_docs_urls from rest_framework.documentation import include_docs_urls
...@@ -25,6 +26,7 @@ router.register(r'campus', CampusViewSet) ...@@ -25,6 +26,7 @@ router.register(r'campus', CampusViewSet)
router.register(r'university', UniversityViewSet) router.register(r'university', UniversityViewSet)
router.register(r'university_scholarship', UniversityScholarshipViewSet) router.register(r'university_scholarship', UniversityScholarshipViewSet)
router.register(r'university_info', UniversityInfoViewSet) router.register(r'university_info', UniversityInfoViewSet)
router.register(r'university_insurance', UniversityInsuranceViewSet)
router.register(r'semesters_dates', SemestersDatesViewSet) router.register(r'semesters_dates', SemestersDatesViewSet)
router.register(r'currency', CurrencyViewSet) router.register(r'currency', CurrencyViewSet)
......
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