Commit 5350a0b5 authored by Florent Chehab's avatar Florent Chehab
Browse files

Updated backend : many to many attibutes are now plurial

parent 18f683f8
...@@ -25,7 +25,7 @@ class LoadUniversityEx(LoadGeneric): ...@@ -25,7 +25,7 @@ class LoadUniversityEx(LoadGeneric):
univ_dri_1 = UniversityDri( univ_dri_1 = UniversityDri(
comment="Attention les cours de master sont 100% en anglais") comment="Attention les cours de master sont 100% en anglais")
univ_dri_1.save() univ_dri_1.save()
univ_dri_1.university.add(EPFL) univ_dri_1.universities.add(EPFL)
univ_dri_1.save() univ_dri_1.save()
self.add_info(univ_dri_1, self.admin) self.add_info(univ_dri_1, self.admin)
...@@ -54,7 +54,7 @@ class LoadUniversityEx(LoadGeneric): ...@@ -54,7 +54,7 @@ class LoadUniversityEx(LoadGeneric):
comment="Il n'y a rien à faire pour l'obtenir" comment="Il n'y a rien à faire pour l'obtenir"
) )
univ_scholarship_1.save() univ_scholarship_1.save()
univ_scholarship_1.university.add(EPFL) univ_scholarship_1.universities.add(EPFL)
univ_scholarship_1.save() univ_scholarship_1.save()
self.add_info(univ_scholarship_1, self.admin) self.add_info(univ_scholarship_1, self.admin)
......
# Generated by Django 2.0.3 on 2018-09-10 19:44
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('backend', '0005_auto_20180910_1846'),
]
operations = [
migrations.RenameField(
model_name='countrydri',
old_name='country',
new_name='countries',
),
migrations.RenameField(
model_name='countryscholarship',
old_name='country',
new_name='countries',
),
migrations.RenameField(
model_name='offer',
old_name='specialty',
new_name='specialties',
),
migrations.RenameField(
model_name='universitydri',
old_name='university',
new_name='universities',
),
migrations.RenameField(
model_name='universityscholarship',
old_name='university',
new_name='universities',
),
]
...@@ -27,3 +27,9 @@ class CampusTaggedItemViewSet(TaggedItemViewSet): ...@@ -27,3 +27,9 @@ class CampusTaggedItemViewSet(TaggedItemViewSet):
permission_classes = get_viewset_permissions("CampusTaggedItemViewSet") permission_classes = get_viewset_permissions("CampusTaggedItemViewSet")
queryset = CampusTaggedItem.objects.all() # pylint: disable=E1101 queryset = CampusTaggedItem.objects.all() # pylint: disable=E1101
serializer_class = CampusTaggedItemSerializer serializer_class = CampusTaggedItemSerializer
BYPASS_DICT_MODE = True
def extend_queryset(self):
campus_id = self.kwargs['campus_id']
return self.my_model_queryset.filter(campus=campus_id).distinct()
...@@ -28,3 +28,9 @@ class CityTaggedItemViewSet(TaggedItemViewSet): ...@@ -28,3 +28,9 @@ class CityTaggedItemViewSet(TaggedItemViewSet):
permission_classes = get_viewset_permissions("CityTaggedItemViewSet") permission_classes = get_viewset_permissions("CityTaggedItemViewSet")
queryset = CityTaggedItem.objects.all() # pylint: disable=E1101 queryset = CityTaggedItem.objects.all() # pylint: disable=E1101
serializer_class = CityTaggedItemSerializer serializer_class = CityTaggedItemSerializer
BYPASS_DICT_MODE = True
def extend_queryset(self):
city_id = self.kwargs['city_id']
return self.my_model_queryset.filter(city=city_id).distinct()
...@@ -6,7 +6,7 @@ from backend.utils import get_model_config, get_viewset_permissions ...@@ -6,7 +6,7 @@ from backend.utils import get_model_config, get_viewset_permissions
class CountryDri(BasicModule): class CountryDri(BasicModule):
model_config = get_model_config("CountryDri") model_config = get_model_config("CountryDri")
country = models.ManyToManyField( countries = models.ManyToManyField(
Country, related_name="country_dri") Country, related_name="country_dri")
@classmethod @classmethod
...@@ -25,3 +25,9 @@ class CountryDriViewSet(BasicModuleViewSet): ...@@ -25,3 +25,9 @@ class CountryDriViewSet(BasicModuleViewSet):
permission_classes = get_viewset_permissions("CountryDriViewSet") permission_classes = get_viewset_permissions("CountryDriViewSet")
queryset = CountryDri.objects.all() # pylint: disable=E1101 queryset = CountryDri.objects.all() # pylint: disable=E1101
serializer_class = CountryDriSerializer serializer_class = CountryDriSerializer
BYPASS_DICT_MODE = True
def extend_queryset(self):
country_id = self.kwargs['country_id']
return self.my_model_queryset.filter(countries__pk=country_id).distinct()
...@@ -6,7 +6,7 @@ from backend.utils import get_model_config, get_viewset_permissions ...@@ -6,7 +6,7 @@ from backend.utils import get_model_config, get_viewset_permissions
class CountryScholarship(Scholarship): class CountryScholarship(Scholarship):
model_config = get_model_config("CountryScholarship") model_config = get_model_config("CountryScholarship")
country = models.ManyToManyField( countries = models.ManyToManyField(
Country, related_name="country_scholarships") Country, related_name="country_scholarships")
@classmethod @classmethod
...@@ -25,3 +25,9 @@ class CountryScholarshipViewSet(ScholarshipViewSet): ...@@ -25,3 +25,9 @@ class CountryScholarshipViewSet(ScholarshipViewSet):
permission_classes = get_viewset_permissions("CountryScholarshipViewSet") permission_classes = get_viewset_permissions("CountryScholarshipViewSet")
queryset = CountryScholarship.objects.all() # pylint: disable=E1101 queryset = CountryScholarship.objects.all() # pylint: disable=E1101
serializer_class = CountryScholarshipSerializer serializer_class = CountryScholarshipSerializer
BYPASS_DICT_MODE = True
def extend_queryset(self):
country_id = self.kwargs['country_id']
return self.my_model_queryset.filter(countries__pk=country_id).distinct()
...@@ -27,3 +27,9 @@ class CountryTaggedItemViewSet(TaggedItemViewSet): ...@@ -27,3 +27,9 @@ class CountryTaggedItemViewSet(TaggedItemViewSet):
permission_classes = get_viewset_permissions("CountryTaggedItemViewSet") permission_classes = get_viewset_permissions("CountryTaggedItemViewSet")
queryset = CountryTaggedItem.objects.all() # pylint: disable=E1101 queryset = CountryTaggedItem.objects.all() # pylint: disable=E1101
serializer_class = CountryTaggedItemSerializer serializer_class = CountryTaggedItemSerializer
BYPASS_DICT_MODE = True
def extend_queryset(self):
country_id = self.kwargs['country_id']
return self.my_model_queryset.filter(country=country_id).distinct()
...@@ -15,7 +15,7 @@ class Offer(MyModel): ...@@ -15,7 +15,7 @@ class Offer(MyModel):
nb_seats_offered_exchange = models.PositiveIntegerField(null=True) nb_seats_offered_exchange = models.PositiveIntegerField(null=True)
nb_seats_offered_double_degree = models.PositiveIntegerField(null=True) nb_seats_offered_double_degree = models.PositiveIntegerField(null=True)
specialty = models.ManyToManyField( specialties = models.ManyToManyField(
Specialty, related_name="has_seats_at_univ") Specialty, related_name="has_seats_at_univ")
class Meta: class Meta:
......
...@@ -6,7 +6,7 @@ from backend.utils import get_model_config, get_viewset_permissions ...@@ -6,7 +6,7 @@ from backend.utils import get_model_config, get_viewset_permissions
class UniversityDri(BasicModule): class UniversityDri(BasicModule):
model_config = get_model_config("UniversityDri") model_config = get_model_config("UniversityDri")
university = models.ManyToManyField( universities = models.ManyToManyField(
University, related_name="university_dri") University, related_name="university_dri")
@classmethod @classmethod
...@@ -25,3 +25,9 @@ class UniversityDriViewSet(BasicModuleViewSet): ...@@ -25,3 +25,9 @@ class UniversityDriViewSet(BasicModuleViewSet):
permission_classes = get_viewset_permissions("UniversityDriViewSet") permission_classes = get_viewset_permissions("UniversityDriViewSet")
queryset = UniversityDri.objects.all() # pylint: disable=E1101 queryset = UniversityDri.objects.all() # pylint: disable=E1101
serializer_class = UniversityDriSerializer serializer_class = UniversityDriSerializer
BYPASS_DICT_MODE = True
def extend_queryset(self):
univ_id = self.kwargs['univ_id']
return self.my_model_queryset.filter(universities__pk=univ_id).distinct()
...@@ -26,7 +26,8 @@ class UniversityInfo(BasicModule): ...@@ -26,7 +26,8 @@ class UniversityInfo(BasicModule):
null=True null=True
) )
costs_currency = models.ForeignKey(Currency, on_delete=models.PROTECT, default='EUR') costs_currency = models.ForeignKey(
Currency, on_delete=models.PROTECT, default='EUR')
@classmethod @classmethod
def get_serializer(cls): def get_serializer(cls):
......
...@@ -6,7 +6,8 @@ from backend.utils import get_model_config, get_viewset_permissions ...@@ -6,7 +6,8 @@ from backend.utils import get_model_config, get_viewset_permissions
class UniversityScholarship(Scholarship): class UniversityScholarship(Scholarship):
model_config = get_model_config("UniversityScholarship") model_config = get_model_config("UniversityScholarship")
university = models.ManyToManyField(University, related_name="university_scholarships") universities = models.ManyToManyField(
University, related_name="university_scholarships")
@classmethod @classmethod
def get_serializer(cls): def get_serializer(cls):
...@@ -25,3 +26,9 @@ class UniversityScholarshipViewSet(ScholarshipViewSet): ...@@ -25,3 +26,9 @@ class UniversityScholarshipViewSet(ScholarshipViewSet):
"UniversityScholarshipViewSet") "UniversityScholarshipViewSet")
queryset = UniversityScholarship.objects.all() # pylint: disable=E1101 queryset = UniversityScholarship.objects.all() # pylint: disable=E1101
serializer_class = UniversityScholarshipSerializer serializer_class = UniversityScholarshipSerializer
BYPASS_DICT_MODE = True
def extend_queryset(self):
univ_id = self.kwargs['univ_id']
return self.my_model_queryset.filter(universities__pk=univ_id).distinct()
...@@ -27,3 +27,9 @@ class UniversityTaggedItemViewSet(TaggedItemViewSet): ...@@ -27,3 +27,9 @@ class UniversityTaggedItemViewSet(TaggedItemViewSet):
permission_classes = get_viewset_permissions("UniversityTaggedItemViewSet") permission_classes = get_viewset_permissions("UniversityTaggedItemViewSet")
queryset = UniversityTaggedItem.objects.all() # pylint: disable=E1101 queryset = UniversityTaggedItem.objects.all() # pylint: disable=E1101
serializer_class = UniversityTaggedItemSerializer serializer_class = UniversityTaggedItemSerializer
BYPASS_DICT_MODE = True
def extend_queryset(self):
univ_id = self.kwargs['univ_id']
return self.my_model_queryset.filter(university__pk=univ_id).distinct()
...@@ -222,9 +222,10 @@ class ModerationTestCase(WithUserTestCase): ...@@ -222,9 +222,10 @@ class ModerationTestCase(WithUserTestCase):
data = { data = {
"comment": "", "comment": "",
"usefull_links": [], "usefull_links": [],
"university": [c.pk] "universities": [c.pk]
} }
api_end_point = "/api/" + \ api_end_point = "/api/" + \
find_api_end_point_for_viewset("UniversityDriViewSet") + "/" find_api_end_point_for_viewset(
"UniversityDriViewSet") + "/" + str(c.pk) + '/'
self._submit_post_test(self.dri_client, self._submit_post_test(self.dri_client,
data, api_end_point) data, api_end_point)
...@@ -117,19 +117,22 @@ ...@@ -117,19 +117,22 @@
- model: CountryTaggedItem - model: CountryTaggedItem
viewset: CountryTaggedItemViewSet viewset: CountryTaggedItemViewSet
import_location: country import_location: country
api_end_point: countriesTaggedItems api_end_point: countryTaggedItems
api_attr: (?P<country_id>[a-zA-Z]+)
versionned: true versionned: true
- model: CountryScholarship - model: CountryScholarship
viewset: CountryScholarshipViewSet viewset: CountryScholarshipViewSet
import_location: country import_location: country
api_end_point: countriesScholarships api_end_point: countryScholarships
api_attr: (?P<country_id>[a-zA-Z]+)
versionned: true versionned: true
- model: CountryDri - model: CountryDri
viewset: CountryDriViewSet viewset: CountryDriViewSet
import_location: country import_location: country
api_end_point: countriesDri api_end_point: countryDri
api_attr: (?P<country_id>[a-zA-Z]+)
viewset_permission: IsDriOrReadOnly viewset_permission: IsDriOrReadOnly
versionned: true versionned: true
...@@ -138,7 +141,8 @@ ...@@ -138,7 +141,8 @@
- model: CityTaggedItem - model: CityTaggedItem
viewset: CityTaggedItemViewSet viewset: CityTaggedItemViewSet
import_location: city import_location: city
api_end_point: citiesTaggedItems api_end_point: cityTaggedItems
api_attr: (?P<city_id>[0-9]+)
versionned: true versionned: true
...@@ -146,13 +150,15 @@ ...@@ -146,13 +150,15 @@
- model: UniversityTaggedItem - model: UniversityTaggedItem
viewset: UniversityTaggedItemViewSet viewset: UniversityTaggedItemViewSet
import_location: university import_location: university
api_end_point: universitiesTaggedItems api_end_point: universityTaggedItems
api_attr: (?P<univ_id>[0-9]+)
versionned: true versionned: true
- model: UniversityScholarship - model: UniversityScholarship
viewset: UniversityScholarshipViewSet viewset: UniversityScholarshipViewSet
import_location: university import_location: university
api_end_point: universitiesScholarships api_end_point: universityScholarships
api_attr: (?P<univ_id>[0-9]+)
versionned: true versionned: true
- model: UniversityInfo - model: UniversityInfo
...@@ -170,7 +176,8 @@ ...@@ -170,7 +176,8 @@
- model: UniversityDri - model: UniversityDri
viewset: UniversityDriViewSet viewset: UniversityDriViewSet
import_location: university import_location: university
api_end_point: universitiesDri api_end_point: universityDri
api_attr: (?P<univ_id>[0-9]+)
viewset_permission: IsDriOrReadOnly viewset_permission: IsDriOrReadOnly
versionned: true versionned: true
...@@ -179,7 +186,8 @@ ...@@ -179,7 +186,8 @@
- model: CampusTaggedItem - model: CampusTaggedItem
viewset: CampusTaggedItemViewSet viewset: CampusTaggedItemViewSet
import_location: campus import_location: campus
api_end_point: campusesTaggedItems api_end_point: campusTaggedItems
api_attr: (?P<campus_id>[0-9]+)
versionned: true versionned: true
- model: null - model: null
......
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