Commit c852a598 authored by Florent Chehab's avatar Florent Chehab
Browse files

Core modules finished

parent d9087853
Pipeline #26390 passed with stages
in 1 minute and 26 seconds
...@@ -38,7 +38,7 @@ package Core { ...@@ -38,7 +38,7 @@ package Core {
+ website : url + website : url
} }
University "1" .right. "1" City University "*" .right. "1" City
note on link #white note on link #white
This link is acheived This link is acheived
through the campus module through the campus module
...@@ -50,31 +50,30 @@ package Core { ...@@ -50,31 +50,30 @@ package Core {
} }
Class Semester{ Class Semester{
+ name : string + code : string {key}
+ searchable : bool
} }
Class Departement{ Class Department{
+ code : string
+ name : string + name : string
+ accronyme : string + active : bool
+ searchable : bool
} }
Class Specialty { Class Specialty {
+ code : string
+ name : string + name : string
+ accronyme : string + active : bool
+ searchable : bool
} }
Offer "*" -right- "1" University Offer "*" -right- "1" University
Offer "*" -down- "1" Semester Offer "*" -down- "1" Semester
Offer "*" -left- "1..n" Departement Offer "*" -left- "1..n" Specialty
Specialty "1..n" -left- "1" Departement Specialty "1..n" -left- "1" Department
note "Initial data inserted in db." as N3 note "Initial data inserted in db." as N3
Semester .. N3 Semester .. N3
N3 .. Specialty N3 .. Specialty
N3 .. Departement N3 .. Department
class UsefullLinks #green{ class UsefullLinks #green{
......
...@@ -35,12 +35,21 @@ from rex.models.university import CampusAccommodation ...@@ -35,12 +35,21 @@ from rex.models.university import CampusAccommodation
from rex.models.university import CampusCultureAndStudentLife from rex.models.university import CampusCultureAndStudentLife
from rex.models.university import CampusOtherStuff from rex.models.university import CampusOtherStuff
from rex.models.tools import Currency from rex.models.module import Currency
from rex.models.otherCore import Department
from rex.models.otherCore import Offer
from rex.models.otherCore import Semester
from rex.models.otherCore import Specialty
CLASSIC_MODELS = [ CLASSIC_MODELS = [
Country, Country,
City, City,
Currency Currency,
Department,
Offer,
Semester,
Specialty,
] ]
VERSIONNED_MODELS = [ VERSIONNED_MODELS = [
......
# Generated by Django 2.0.3 on 2018-08-21 14:47
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('rex', '0024_countrydri_universitydri'),
]
operations = [
migrations.CreateModel(
name='Department',
fields=[
('code', models.CharField(max_length=6, primary_key=True, serialize=False)),
('name', models.CharField(max_length=100)),
('active', models.BooleanField()),
],
),
migrations.CreateModel(
name='Offer',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nb_seats_offered', models.IntegerField()),
],
),
migrations.CreateModel(
name='Semester',
fields=[
('code', models.CharField(max_length=6, primary_key=True, serialize=False)),
],
),
migrations.CreateModel(
name='Specialty',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('code', models.CharField(max_length=6)),
('name', models.CharField(max_length=100)),
('active', models.BooleanField()),
('department', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='rex.Department')),
],
),
migrations.AddField(
model_name='offer',
name='semester',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='rex.Semester'),
),
migrations.AddField(
model_name='offer',
name='specialty',
field=models.ManyToManyField(related_name='has_seats_at_univ', to='rex.Specialty'),
),
migrations.AddField(
model_name='offer',
name='university',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='rex.University'),
),
migrations.AlterUniqueTogether(
name='specialty',
unique_together={('code', 'department')},
),
migrations.AlterUniqueTogether(
name='offer',
unique_together={('semester', 'university')},
),
]
...@@ -3,3 +3,4 @@ from .basicModule import BasicModule, BasicModuleSerializer # noqa: F401 ...@@ -3,3 +3,4 @@ from .basicModule import BasicModule, BasicModuleSerializer # noqa: F401
from .scholarship import Scholarship # noqa: F401 from .scholarship import Scholarship # noqa: F401
from .photo import Photo # noqa: F401 from .photo import Photo # noqa: F401
from .driRestrictedModule import DriRestrictedModule, DriRestrictedModuleSerializer # noqa: F401 from .driRestrictedModule import DriRestrictedModule, DriRestrictedModuleSerializer # noqa: F401
from .currency import Currency, CurrencyViewSet, CurrencySerializer # noqa: F401
...@@ -17,10 +17,10 @@ class Currency(models.Model): ...@@ -17,10 +17,10 @@ class Currency(models.Model):
class CurrencySerializer(serializers.ModelSerializer): class CurrencySerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Currency model = Currency
fields = ('code', 'name', 'symbol', 'one_USD_in_this_currency') fields = '__all__'
class CurrencyViewSet(viewsets.ModelViewSet): class CurrencyViewSet(viewsets.ModelViewSet):
permission_classes = (permissions.DjangoModelPermissions,) permission_classes = (permissions.IsAdminUser,)
queryset = Currency.objects.all() # pylint: disable=E1101 queryset = Currency.objects.all() # pylint: disable=E1101
serializer_class = CurrencySerializer serializer_class = CurrencySerializer
from django.db import models from django.db import models
from rex.models.module import BasicModule from rex.models.module import BasicModule
from rex.models.tools import Currency from .currency import Currency
from rest_framework import serializers from rest_framework import serializers
from django.core.validators import MinValueValidator from django.core.validators import MinValueValidator
......
from .semester import Semester, SemesterViewSet # noqa: F401
from .department import Department, DepartmentViewSet # noqa: F401
from .specialty import Specialty, SpecialtyViewSet # noqa: F401
from .offer import Offer, OfferViewSet # noqa: F401
from django.db import models
from rest_framework import serializers, viewsets, permissions
class Department(models.Model):
code = models.CharField(primary_key=True, max_length=6)
name = models.CharField(max_length=100)
active = models.BooleanField()
class DepartmentSerializer(serializers.ModelSerializer):
class Meta:
model = Department
fields = '__all__'
class DepartmentViewSet(viewsets.ModelViewSet):
permission_classes = (permissions.IsAdminUser,)
queryset = Department.objects.all() # pylint: disable=E1101
serializer_class = DepartmentSerializer
from django.db import models
from rest_framework import serializers, viewsets, permissions
from rex.models.university import University
from rex.models.otherCore import Semester, Specialty
class Offer(models.Model):
semester = models.ForeignKey(Semester, on_delete=models.PROTECT)
university = models.ForeignKey(University, on_delete=models.PROTECT)
nb_seats_offered = models.IntegerField()
specialty = models.ManyToManyField(
Specialty, related_name="has_seats_at_univ")
class Meta:
unique_together = ('semester', 'university')
class OfferSerializer(serializers.ModelSerializer):
class Meta:
model = Offer
fields = '__all__'
class OfferViewSet(viewsets.ModelViewSet):
permission_classes = (permissions.IsAdminUser,)
queryset = Offer.objects.all() # pylint: disable=E1101
serializer_class = OfferSerializer
from django.db import models
from rest_framework import serializers, viewsets, permissions
class Semester(models.Model):
code = models.CharField(primary_key=True, max_length=6)
class SemesterSerializer(serializers.ModelSerializer):
class Meta:
model = Semester
fields = '__all__'
class SemesterViewSet(viewsets.ModelViewSet):
permission_classes = (permissions.IsAdminUser,)
queryset = Semester.objects.all() # pylint: disable=E1101
serializer_class = SemesterSerializer
from django.db import models
from rest_framework import serializers, viewsets, permissions
from rex.models.otherCore import Department
class Specialty(models.Model):
code = models.CharField(max_length=6)
department = models.ForeignKey(Department, on_delete=models.PROTECT)
name = models.CharField(max_length=100)
active = models.BooleanField()
class Meta:
unique_together = ('code', 'department')
# TODO add documentation : you should add departement.
class SpecialtySerializer(serializers.ModelSerializer):
class Meta:
model = Specialty
fields = '__all__'
class SpecialtyViewSet(viewsets.ModelViewSet):
permission_classes = (permissions.IsAdminUser,)
queryset = Specialty.objects.all() # pylint: disable=E1101
serializer_class = SpecialtySerializer
from .DictModeViewSet import DictModeViewSet # noqa: F401 from .DictModeViewSet import DictModeViewSet # noqa: F401
from .usefullLinksField import UsefullLinksField # noqa: F401 from .usefullLinksField import UsefullLinksField # noqa: F401
from .validateWithRestFramework import validate_with_rest_framework # noqa: F401 from .validateWithRestFramework import validate_with_rest_framework # noqa: F401
from .currency import Currency, CurrencyViewSet, CurrencySerializer # noqa: F401
from django.db import models from django.db import models
from rex.models.module import BasicModule, BasicModuleSerializer from rex.models.module import BasicModule, BasicModuleSerializer
from rex.models.university import University from rex.models.university import University
from rex.models.tools import Currency from rex.models.module import Currency
from django.core.validators import MinValueValidator from django.core.validators import MinValueValidator
from rest_framework import viewsets, permissions from rest_framework import viewsets, permissions
......
...@@ -8,8 +8,6 @@ class UniversityScholarship(Scholarship): ...@@ -8,8 +8,6 @@ class UniversityScholarship(Scholarship):
university = models.ForeignKey( university = models.ForeignKey(
University, on_delete=models.PROTECT, null=False, related_name="univScholarship") University, on_delete=models.PROTECT, null=False, related_name="univScholarship")
# API
class UniversityScholarshipSerializer(BasicModuleSerializer): class UniversityScholarshipSerializer(BasicModuleSerializer):
......
...@@ -4,6 +4,12 @@ from rest_framework import routers ...@@ -4,6 +4,12 @@ from rest_framework import routers
from rex.models.location import CountryViewSet from rex.models.location import CountryViewSet
from rex.models.location import CityViewSet from rex.models.location import CityViewSet
from rex.models.module import CurrencyViewSet
from rex.models.otherCore import DepartmentViewSet
from rex.models.otherCore import OfferViewSet
from rex.models.otherCore import SemesterViewSet
from rex.models.otherCore import SpecialtyViewSet
from rex.models.location import CountryCultureViewSet from rex.models.location import CountryCultureViewSet
from rex.models.location import CountryHealthInsuranceViewSet from rex.models.location import CountryHealthInsuranceViewSet
from rex.models.location import CountryOtherInsuranceViewSet from rex.models.location import CountryOtherInsuranceViewSet
...@@ -38,8 +44,6 @@ from rex.models.university import CampusAccommodationViewSet ...@@ -38,8 +44,6 @@ from rex.models.university import CampusAccommodationViewSet
from rex.models.university import CampusCultureAndStudentLifeViewSet from rex.models.university import CampusCultureAndStudentLifeViewSet
from rex.models.university import CampusOtherStuffViewSet from rex.models.university import CampusOtherStuffViewSet
from rex.models.tools import CurrencyViewSet
from rest_framework.documentation import include_docs_urls from rest_framework.documentation import include_docs_urls
...@@ -95,6 +99,11 @@ router.register(r'campus_more/transport', CampusTransportViewSet) ...@@ -95,6 +99,11 @@ router.register(r'campus_more/transport', CampusTransportViewSet)
router.register(r'campus_more/other_tuff', CampusOtherStuffViewSet) router.register(r'campus_more/other_tuff', CampusOtherStuffViewSet)
router.register(r'currency', CurrencyViewSet) router.register(r'other/currency', CurrencyViewSet)
router.register(r'other/semester', SemesterViewSet)
router.register(r'other/department', DepartmentViewSet)
router.register(r'other/specialty', SpecialtyViewSet)
router.register(r'other/offer', OfferViewSet)
urlpatterns += [url(r'^api/', include(router.urls))] 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