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

Updated backend : many to many attibutes are now plurial

parent 18f683f8
......@@ -25,7 +25,7 @@ class LoadUniversityEx(LoadGeneric):
univ_dri_1 = UniversityDri(
comment="Attention les cours de master sont 100% en anglais")
univ_dri_1.save()
univ_dri_1.university.add(EPFL)
univ_dri_1.universities.add(EPFL)
univ_dri_1.save()
self.add_info(univ_dri_1, self.admin)
......@@ -54,7 +54,7 @@ class LoadUniversityEx(LoadGeneric):
comment="Il n'y a rien à faire pour l'obtenir"
)
univ_scholarship_1.save()
univ_scholarship_1.university.add(EPFL)
univ_scholarship_1.universities.add(EPFL)
univ_scholarship_1.save()
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):
permission_classes = get_viewset_permissions("CampusTaggedItemViewSet")
queryset = CampusTaggedItem.objects.all() # pylint: disable=E1101
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):
permission_classes = get_viewset_permissions("CityTaggedItemViewSet")
queryset = CityTaggedItem.objects.all() # pylint: disable=E1101
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
class CountryDri(BasicModule):
model_config = get_model_config("CountryDri")
country = models.ManyToManyField(
countries = models.ManyToManyField(
Country, related_name="country_dri")
@classmethod
......@@ -25,3 +25,9 @@ class CountryDriViewSet(BasicModuleViewSet):
permission_classes = get_viewset_permissions("CountryDriViewSet")
queryset = CountryDri.objects.all() # pylint: disable=E1101
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
class CountryScholarship(Scholarship):
model_config = get_model_config("CountryScholarship")
country = models.ManyToManyField(
countries = models.ManyToManyField(
Country, related_name="country_scholarships")
@classmethod
......@@ -25,3 +25,9 @@ class CountryScholarshipViewSet(ScholarshipViewSet):
permission_classes = get_viewset_permissions("CountryScholarshipViewSet")
queryset = CountryScholarship.objects.all() # pylint: disable=E1101
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):
permission_classes = get_viewset_permissions("CountryTaggedItemViewSet")
queryset = CountryTaggedItem.objects.all() # pylint: disable=E1101
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):
nb_seats_offered_exchange = 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")
class Meta:
......
......@@ -6,7 +6,7 @@ from backend.utils import get_model_config, get_viewset_permissions
class UniversityDri(BasicModule):
model_config = get_model_config("UniversityDri")
university = models.ManyToManyField(
universities = models.ManyToManyField(
University, related_name="university_dri")
@classmethod
......@@ -25,3 +25,9 @@ class UniversityDriViewSet(BasicModuleViewSet):
permission_classes = get_viewset_permissions("UniversityDriViewSet")
queryset = UniversityDri.objects.all() # pylint: disable=E1101
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):
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
def get_serializer(cls):
......
......@@ -6,7 +6,8 @@ from backend.utils import get_model_config, get_viewset_permissions
class UniversityScholarship(Scholarship):
model_config = get_model_config("UniversityScholarship")
university = models.ManyToManyField(University, related_name="university_scholarships")
universities = models.ManyToManyField(
University, related_name="university_scholarships")
@classmethod
def get_serializer(cls):
......@@ -25,3 +26,9 @@ class UniversityScholarshipViewSet(ScholarshipViewSet):
"UniversityScholarshipViewSet")
queryset = UniversityScholarship.objects.all() # pylint: disable=E1101
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):
permission_classes = get_viewset_permissions("UniversityTaggedItemViewSet")
queryset = UniversityTaggedItem.objects.all() # pylint: disable=E1101
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):
data = {
"comment": "",
"usefull_links": [],
"university": [c.pk]
"universities": [c.pk]
}
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,
data, api_end_point)
......@@ -117,19 +117,22 @@
- model: CountryTaggedItem
viewset: CountryTaggedItemViewSet
import_location: country
api_end_point: countriesTaggedItems
api_end_point: countryTaggedItems
api_attr: (?P<country_id>[a-zA-Z]+)
versionned: true
- model: CountryScholarship
viewset: CountryScholarshipViewSet
import_location: country
api_end_point: countriesScholarships
api_end_point: countryScholarships
api_attr: (?P<country_id>[a-zA-Z]+)
versionned: true
- model: CountryDri
viewset: CountryDriViewSet
import_location: country
api_end_point: countriesDri
api_end_point: countryDri
api_attr: (?P<country_id>[a-zA-Z]+)
viewset_permission: IsDriOrReadOnly
versionned: true
......@@ -138,7 +141,8 @@
- model: CityTaggedItem
viewset: CityTaggedItemViewSet
import_location: city
api_end_point: citiesTaggedItems
api_end_point: cityTaggedItems
api_attr: (?P<city_id>[0-9]+)
versionned: true
......@@ -146,13 +150,15 @@
- model: UniversityTaggedItem
viewset: UniversityTaggedItemViewSet
import_location: university
api_end_point: universitiesTaggedItems
api_end_point: universityTaggedItems
api_attr: (?P<univ_id>[0-9]+)
versionned: true
- model: UniversityScholarship
viewset: UniversityScholarshipViewSet
import_location: university
api_end_point: universitiesScholarships
api_end_point: universityScholarships
api_attr: (?P<univ_id>[0-9]+)
versionned: true
- model: UniversityInfo
......@@ -170,7 +176,8 @@
- model: UniversityDri
viewset: UniversityDriViewSet
import_location: university
api_end_point: universitiesDri
api_end_point: universityDri
api_attr: (?P<univ_id>[0-9]+)
viewset_permission: IsDriOrReadOnly
versionned: true
......@@ -179,7 +186,8 @@
- model: CampusTaggedItem
viewset: CampusTaggedItemViewSet
import_location: campus
api_end_point: campusesTaggedItems
api_end_point: campusTaggedItems
api_attr: (?P<campus_id>[0-9]+)
versionned: true
- 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