Commit 04c716cf authored by Florent Chehab's avatar Florent Chehab
Browse files

Merge branch 'update_back_linting' into 'master'

Update back linting and fix documentation job failing on master

Closes #44

See merge request !44
parents 3a3bbbd2 955238be
Pipeline #34792 passed with stages
in 2 minutes and 57 seconds
from django.db import models
from backend_app.models.campus import Campus
from backend_app.models.abstract.taggedItem import TaggedItem, TaggedItemSerializer, TaggedItemViewSet
from backend_app.models.abstract.taggedItem import (
TaggedItem,
TaggedItemSerializer,
TaggedItemViewSet,
)
from backend_app.utils import get_model_config, get_viewset_permissions
class CampusTaggedItem(TaggedItem):
model_config = get_model_config("CampusTaggedItem")
campus = models.ForeignKey(
Campus, on_delete=models.PROTECT, related_name='campus_tagged_items')
Campus, on_delete=models.PROTECT, related_name="campus_tagged_items"
)
@classmethod
def get_serializer(cls):
return CampusTaggedItemSerializer
class Meta:
unique_together = ('campus', 'tag', 'importance_level')
unique_together = ("campus", "tag", "importance_level")
class CampusTaggedItemSerializer(TaggedItemSerializer):
class Meta:
model = CampusTaggedItem
fields = '__all__'
fields = "__all__"
class CampusTaggedItemViewSet(TaggedItemViewSet):
......@@ -31,5 +36,5 @@ class CampusTaggedItemViewSet(TaggedItemViewSet):
BYPASS_DICT_MODE = True
def extend_queryset(self):
campus_id = self.kwargs['campus_id']
campus_id = self.kwargs["campus_id"]
return self.my_model_queryset.filter(campus=campus_id).distinct()
from .city import City, CitySerializer, CityViewSet # noqa: F401
from .cityTaggedItem import CityTaggedItem, CityTaggedItemSerializer, CityTaggedItemViewSet # noqa: F401
from .city import City, CitySerializer, CityViewSet
from .cityTaggedItem import (
CityTaggedItem,
CityTaggedItemSerializer,
CityTaggedItemViewSet,
)
__all__ = [
"City",
"CitySerializer",
"CityViewSet",
"CityTaggedItem",
"CityTaggedItemSerializer",
"CityTaggedItemViewSet",
]
from django.db import models
from backend_app.models.country import Country
from backend_app.models.abstract.my_model import MyModel, MyModelSerializer, MyModelVersionnedViewSet
from backend_app.models.abstract.my_model import (
MyModel,
MyModelSerializer,
MyModelVersionnedViewSet,
)
from backend_app.utils import get_model_config, get_viewset_permissions
......@@ -8,18 +12,17 @@ class City(MyModel):
model_config = get_model_config("City")
name = models.CharField(max_length=200)
local_name = models.CharField(max_length=200, default='', blank=True)
local_name = models.CharField(max_length=200, default="", blank=True)
# We add an area to distinguish similarly named cities
# in a country
area = models.CharField(max_length=200, default='', blank=True)
area = models.CharField(max_length=200, default="", blank=True)
country = models.ForeignKey(Country, on_delete=models.PROTECT)
class CitySerializer(MyModelSerializer):
class Meta:
model = City
fields = '__all__'
fields = "__all__"
class CityViewSet(MyModelVersionnedViewSet):
......
from django.db import models
from backend_app.models.abstract.taggedItem import TaggedItem, TaggedItemSerializer, TaggedItemViewSet
from backend_app.models.abstract.taggedItem import (
TaggedItem,
TaggedItemSerializer,
TaggedItemViewSet,
)
from backend_app.models.city import City
from backend_app.utils import get_model_config, get_viewset_permissions
......@@ -8,20 +12,21 @@ class CityTaggedItem(TaggedItem):
model_config = get_model_config("CityTaggedItem")
city = models.ForeignKey(
City, on_delete=models.PROTECT, related_name='city_tagged_items')
City, on_delete=models.PROTECT, related_name="city_tagged_items"
)
@classmethod
def get_serializer(cls):
return CityTaggedItemSerializer
class Meta:
unique_together = ('city', 'tag', 'importance_level')
unique_together = ("city", "tag", "importance_level")
class CityTaggedItemSerializer(TaggedItemSerializer):
class Meta:
model = CityTaggedItem
fields = '__all__'
fields = "__all__"
class CityTaggedItemViewSet(TaggedItemViewSet):
......@@ -32,5 +37,5 @@ class CityTaggedItemViewSet(TaggedItemViewSet):
BYPASS_DICT_MODE = True
def extend_queryset(self):
city_id = self.kwargs['city_id']
city_id = self.kwargs["city_id"]
return self.my_model_queryset.filter(city=city_id).distinct()
from .country import Country, CountrySerializer, CountryViewSet # noqa: F401
from .countryScholarship import CountryScholarship, CountryScholarshipSerializer, CountryScholarshipViewSet # noqa: F401
from .countryDri import CountryDri, CountryDriSerializer, CountryDriViewSet # noqa: F401
from .countryTaggedItem import CountryTaggedItem, CountryTaggedItemSerializer, CountryTaggedItemViewSet # noqa: F401
from .country import Country, CountrySerializer, CountryViewSet
from .countryScholarship import (
CountryScholarship,
CountryScholarshipSerializer,
CountryScholarshipViewSet,
)
from .countryDri import CountryDri, CountryDriSerializer, CountryDriViewSet
from .countryTaggedItem import (
CountryTaggedItem,
CountryTaggedItemSerializer,
CountryTaggedItemViewSet,
)
__all__ = [
"Country",
"CountrySerializer",
"CountryViewSet",
"CountryScholarship",
"CountryScholarshipSerializer",
"CountryScholarshipViewSet",
"CountryDri",
"CountryDriSerializer",
"CountryDriViewSet",
"CountryTaggedItem",
"CountryTaggedItemSerializer",
"CountryTaggedItemViewSet",
]
from django.db import models
from backend_app.models.abstract.my_model import MyModel, MyModelSerializer, MyModelVersionnedViewSet
from backend_app.models.abstract.my_model import (
MyModel,
MyModelSerializer,
MyModelVersionnedViewSet,
)
from backend_app.utils import get_model_config, get_viewset_permissions
# Data model based on : https://unstats.un.org/unsd/methodology/m49/overview/
......@@ -10,22 +15,20 @@ class Country(MyModel):
name = models.CharField(max_length=200)
iso_alpha2_code = models.CharField(primary_key=True, max_length=2)
iso_alpha3_code = models.CharField(
unique=True, max_length=3, default='', blank=True)
unique=True, max_length=3, default="", blank=True
)
region_name = models.CharField(max_length=200)
region_un_code = models.CharField(max_length=3)
sub_region_name = models.CharField(max_length=200, default='', blank=True)
sub_region_un_code = models.CharField(max_length=3, default='', blank=True)
intermediate_region_name = models.CharField(
max_length=200, default='', blank=True)
intermediate_region_un_code = models.CharField(
max_length=3, default='', blank=True)
sub_region_name = models.CharField(max_length=200, default="", blank=True)
sub_region_un_code = models.CharField(max_length=3, default="", blank=True)
intermediate_region_name = models.CharField(max_length=200, default="", blank=True)
intermediate_region_un_code = models.CharField(max_length=3, default="", blank=True)
class CountrySerializer(MyModelSerializer):
class Meta:
model = Country
fields = '__all__'
fields = "__all__"
class CountryViewSet(MyModelVersionnedViewSet):
......
from django.db import models
from backend_app.models.country import Country
from backend_app.models.abstract.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend_app.models.abstract.basic_module import (
BasicModule,
BasicModuleSerializer,
BasicModuleViewSet,
)
from backend_app.utils import get_model_config, get_viewset_permissions
class CountryDri(BasicModule):
model_config = get_model_config("CountryDri")
countries = models.ManyToManyField(
Country, related_name="country_dri")
countries = models.ManyToManyField(Country, related_name="country_dri")
@classmethod
def get_serializer(cls):
......@@ -19,7 +22,7 @@ class CountryDriSerializer(BasicModuleSerializer):
class Meta:
model = CountryDri
fields = '__all__'
fields = "__all__"
class CountryDriViewSet(BasicModuleViewSet):
......@@ -30,5 +33,5 @@ class CountryDriViewSet(BasicModuleViewSet):
BYPASS_DICT_MODE = True
def extend_queryset(self):
country_id = self.kwargs['country_id']
country_id = self.kwargs["country_id"]
return self.my_model_queryset.filter(countries__pk=country_id).distinct()
from django.db import models
from backend_app.models.country import Country
from backend_app.models.abstract.scholarship import Scholarship, ScholarshipSerializer, ScholarshipViewSet
from backend_app.models.abstract.scholarship import (
Scholarship,
ScholarshipSerializer,
ScholarshipViewSet,
)
from backend_app.utils import get_model_config, get_viewset_permissions
class CountryScholarship(Scholarship):
model_config = get_model_config("CountryScholarship")
countries = models.ManyToManyField(
Country, related_name="country_scholarships")
countries = models.ManyToManyField(Country, related_name="country_scholarships")
@classmethod
def get_serializer(cls):
......@@ -15,10 +18,9 @@ class CountryScholarship(Scholarship):
class CountryScholarshipSerializer(ScholarshipSerializer):
class Meta:
model = CountryScholarship
fields = '__all__'
fields = "__all__"
class CountryScholarshipViewSet(ScholarshipViewSet):
......@@ -29,5 +31,5 @@ class CountryScholarshipViewSet(ScholarshipViewSet):
BYPASS_DICT_MODE = True
def extend_queryset(self):
country_id = self.kwargs['country_id']
country_id = self.kwargs["country_id"]
return self.my_model_queryset.filter(countries__pk=country_id).distinct()
from django.db import models
from backend_app.models.abstract.taggedItem import TaggedItem, TaggedItemSerializer, TaggedItemViewSet
from backend_app.models.abstract.taggedItem import (
TaggedItem,
TaggedItemSerializer,
TaggedItemViewSet,
)
from backend_app.models.country import Country
from backend_app.utils import get_model_config, get_viewset_permissions
......@@ -7,20 +11,21 @@ from backend_app.utils import get_model_config, get_viewset_permissions
class CountryTaggedItem(TaggedItem):
model_config = get_model_config("CountryTaggedItem")
country = models.ForeignKey(
Country, on_delete=models.PROTECT, related_name='country_tagged_items')
Country, on_delete=models.PROTECT, related_name="country_tagged_items"
)
@classmethod
def get_serializer(cls):
return CountryTaggedItemSerializer
class Meta:
unique_together = ('country', 'tag', 'importance_level')
unique_together = ("country", "tag", "importance_level")
class CountryTaggedItemSerializer(TaggedItemSerializer):
class Meta:
model = CountryTaggedItem
fields = '__all__'
fields = "__all__"
class CountryTaggedItemViewSet(TaggedItemViewSet):
......@@ -31,5 +36,5 @@ class CountryTaggedItemViewSet(TaggedItemViewSet):
BYPASS_DICT_MODE = True
def extend_queryset(self):
country_id = self.kwargs['country_id']
country_id = self.kwargs["country_id"]
return self.my_model_queryset.filter(country=country_id).distinct()
from .currency import Currency, CurrencyViewSet, CurrencySerializer # noqa: F401
from .currency import Currency, CurrencyViewSet, CurrencySerializer
__all__ = ["Currency", "CurrencyViewSet", "CurrencySerializer"]
from django.db import models
from django.core.validators import MinValueValidator
from backend_app.models.abstract.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend_app.models.abstract.my_model import (
MyModel,
MyModelSerializer,
MyModelViewSet,
)
from backend_app.utils import get_model_config, get_viewset_permissions
......@@ -9,18 +13,16 @@ class Currency(MyModel):
code = models.CharField(primary_key=True, max_length=3)
name = models.CharField(max_length=100)
symbol = models.CharField(default='', blank=True, max_length=30)
symbol = models.CharField(default="", blank=True, max_length=30)
one_EUR_in_this_currency = models.DecimalField(
max_digits=20,
decimal_places=6,
validators=[MinValueValidator(0)]
max_digits=20, decimal_places=6, validators=[MinValueValidator(0)]
)
class CurrencySerializer(MyModelSerializer):
class Meta:
model = Currency
fields = '__all__'
fields = "__all__"
class CurrencyViewSet(MyModelViewSet):
......
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 .semester import Semester, SemesterViewSet
from .department import Department, DepartmentViewSet
from .specialty import Specialty, SpecialtyViewSet
from .offer import Offer, OfferViewSet
__all__ = [
"Semester",
"SemesterViewSet",
"Department",
"DepartmentViewSet",
"Specialty",
"SpecialtyViewSet",
"Offer",
"OfferViewSet",
]
from django.db import models
from backend_app.models.abstract.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend_app.models.abstract.my_model import (
MyModel,
MyModelSerializer,
MyModelViewSet,
)
from backend_app.utils import get_model_config, get_viewset_permissions
......@@ -14,7 +18,7 @@ class Department(MyModel):
class DepartmentSerializer(MyModelSerializer):
class Meta:
model = Department
fields = '__all__'
fields = "__all__"
class DepartmentViewSet(MyModelViewSet):
......
from django.db import models
from backend_app.models.university import University
from backend_app.models.other_core import Semester, Specialty
from backend_app.models.abstract.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend_app.models.abstract.my_model import (
MyModel,
MyModelSerializer,
MyModelViewSet,
)
from backend_app.utils import get_model_config, get_viewset_permissions
......@@ -15,17 +19,16 @@ class Offer(MyModel):
nb_seats_offered_exchange = models.PositiveIntegerField(null=True)
nb_seats_offered_double_degree = models.PositiveIntegerField(null=True)
specialties = models.ManyToManyField(
Specialty, related_name="has_seats_at_univ")
specialties = models.ManyToManyField(Specialty, related_name="has_seats_at_univ")
class Meta:
unique_together = ('semester', 'university')
unique_together = ("semester", "university")
class OfferSerializer(MyModelSerializer):
class Meta:
model = Offer
fields = '__all__'
fields = "__all__"
class OfferViewSet(MyModelViewSet):
......
from django.db import models
from backend_app.models.abstract.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend_app.models.abstract.my_model import (
MyModel,
MyModelSerializer,
MyModelViewSet,
)
from backend_app.utils import get_model_config, get_viewset_permissions
......@@ -11,7 +15,7 @@ class Semester(MyModel):
class SemesterSerializer(MyModelSerializer):
class Meta:
model = Semester
fields = '__all__'
fields = "__all__"
class SemesterViewSet(MyModelViewSet):
......
from django.db import models
from backend_app.models.other_core import Department
from backend_app.models.abstract.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend_app.models.abstract.my_model import (
MyModel,
MyModelSerializer,
MyModelViewSet,
)
from backend_app.utils import get_model_config, get_viewset_permissions
......@@ -12,14 +16,15 @@ class Specialty(MyModel):
active = models.BooleanField()
class Meta:
unique_together = ('code', 'department')
unique_together = ("code", "department")
# TODO add documentation : you should add departement.
class SpecialtySerializer(MyModelSerializer):
class Meta:
model = Specialty
fields = '__all__'
fields = "__all__"
class SpecialtyViewSet(MyModelViewSet):
......
from .tag import Tag, TagSerializer, TagViewSet # noqa: F401
from .tag import Tag, TagSerializer, TagViewSet
__all__ = ["Tag", "TagSerializer", "TagViewSet"]
from django.db import models
from backend_app.models.abstract.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend_app.models.abstract.my_model import (
MyModel,
MyModelSerializer,
MyModelViewSet,
)
from backend_app.fields import JSONField
from backend_app.utils import get_viewset_permissions, get_model_config
......@@ -8,6 +12,7 @@ class Tag(MyModel):
"""
TODO description
"""
model_config = get_model_config("Tag")
name = models.CharField(max_length=100, unique=True)
......@@ -17,7 +22,7 @@ class Tag(MyModel):
class TagSerializer(MyModelSerializer):
class Meta:
model = Tag
fields = '__all__'
fields = "__all__"
class TagViewSet(MyModelViewSet):
......
from .university import University, UniversitySerializer, UniversityViewSet # noqa: F401
from .university import University, UniversitySerializer, UniversityViewSet
from .universityScholarship import UniversityScholarship, UniversityScholarshipSerializer, UniversityScholarshipViewSet # noqa: F401
from .universityDri import UniversityDri, UniversityDriSerializer, UniversityDriViewSet # noqa: F401
from .universityInfo import UniversityInfo, UniversityInfoSerializer, UniversityInfoViewSet # noqa: F401
from .universitySemestersDates import UniversitySemestersDates, UniversitySemestersDatesSerializer, UniversitySemestersDatesViewSet # noqa: F401
from .universityTaggedItem import UniversityTaggedItem, UniversityTaggedItemSerializer, UniversityTaggedItemViewSet # noqa: F401
from .universityScholarship import (
UniversityScholarship,
UniversityScholarshipSerializer,
UniversityScholarshipViewSet,
)
from .universityDri import UniversityDri, UniversityDriSerializer, UniversityDriViewSet
from .universityInfo import (
UniversityInfo,
UniversityInfoSerializer,
UniversityInfoViewSet,
)
from .universitySemestersDates import (
UniversitySemestersDates,
UniversitySemestersDatesSerializer,
UniversitySemestersDatesViewSet,
)
from .universityTaggedItem import (
UniversityTaggedItem,
UniversityTaggedItemSerializer,
UniversityTaggedItemViewSet,
)
__all__ = [
"University",
"UniversitySerializer",
"UniversityViewSet",
"UniversityScholarship",
"UniversityScholarshipSerializer",
"UniversityScholarshipViewSet",
"UniversityDri",
"UniversityDriSerializer",
"UniversityDriViewSet",
"UniversityInfo",
"UniversityInfoSerializer",
"UniversityInfoViewSet",
"UniversitySemestersDates",
"UniversitySemestersDatesSerializer",
"UniversitySemestersDatesViewSet",
"UniversityTaggedItem",
"UniversityTaggedItemSerializer",
"UniversityTaggedItemViewSet",
]
......@@ -13,29 +13,29 @@ def validate_extension_django(url):
try:
validate_extension(settings.ALLOWED_PHOTOS_EXTENSION, url)
except RFValidationError:
raise ValidationError(
"Extension in URL doesn't correspond to an image")
raise ValidationError("Extension in URL doesn't correspond to an image")
class University(MyModel):
"""
Model storing information about universities
"""
model_config = get_model_config("University")