diff --git a/multi_op/preferences/forms.py b/multi_op/preferences/forms.py index a58410c7..d425f33d 100644 --- a/multi_op/preferences/forms.py +++ b/multi_op/preferences/forms.py @@ -30,12 +30,12 @@ from django import forms from django.forms import ModelForm, Form from django.utils.translation import ugettext_lazy as _ -from .models import Preferences +from .models import MultiopOption class EditPreferencesForm(ModelForm): """Form used to edit the settings of multi_op.""" class Meta: - model = Preferences + model = MultiopOption fields = "__all__" diff --git a/multi_op/preferences/models.py b/multi_op/preferences/models.py index 8a185188..47544b47 100644 --- a/multi_op/preferences/models.py +++ b/multi_op/preferences/models.py @@ -28,7 +28,7 @@ from django.db import models from django.utils.translation import ugettext_lazy as _ -class Preferences(models.Model): +class MultiopOption(models.Model): """Definition of the settings of multi_op.""" enabled_dorm = models.ManyToManyField( diff --git a/multi_op/urls.py b/multi_op/urls.py index f1a6d941..45b144e2 100644 --- a/multi_op/urls.py +++ b/multi_op/urls.py @@ -28,6 +28,7 @@ each. from django.conf.urls import url from . import views +from .preferences.views import edit_options urlpatterns = [ url(r"^$", views.aff_state_global, name="aff-state-global"), @@ -36,6 +37,11 @@ urlpatterns = [ views.aff_state_dormitory, name="aff-state-dormitory", ), + url( + r"^edit_options/(?P
MultiopOption)$", + edit_options, + name="edit-options", + ), url( r"^pending-connection$", views.aff_pending_connection, diff --git a/multi_op/views.py b/multi_op/views.py index 729eae27..ad89bfae 100644 --- a/multi_op/views.py +++ b/multi_op/views.py @@ -45,7 +45,7 @@ from preferences.models import GeneralOption, AssoOption from .forms import DormitoryForm -from .preferences.models import Preferences +from .preferences.models import MultiopOption from topologie.models import Room, Dormitory diff --git a/preferences/views.py b/preferences/views.py index 129e17ff..3689fa99 100644 --- a/preferences/views.py +++ b/preferences/views.py @@ -128,6 +128,8 @@ def edit_options_template_function(request, section, forms, models): ) def display_options(request): """View used to display preferences sorted by model.""" + + # The mandatory options are loaded manually useroptions, _created = OptionalUser.objects.get_or_create() machineoptions, _created = OptionalMachine.objects.get_or_create() topologieoptions, _created = OptionalTopologie.objects.get_or_create() @@ -146,6 +148,7 @@ def display_options(request): cotisationsoptions, _created = CotisationsOption.objects.get_or_create() document_template_list = DocumentTemplate.objects.order_by("name") + # Then all the optionnal options (from optionnal apps) are loaded if they exists optionnal_apps = [import_module(app) for app in OPTIONNAL_APPS_RE2O] optionnal_templates_list = [ app.preferences.views.aff_preferences(request)