Merge branch 'Aufinal/django2-urls' into 'master'

Passage à Django2

See merge request klub-dev-ens/gestioCOF!358
This commit is contained in:
Ludovic Stephan 2019-05-29 17:13:25 +02:00
commit 018865967d
19 changed files with 265 additions and 234 deletions

View file

@ -1,3 +1,4 @@
- Passage à Django2
- Dev : on peut désactiver la barre de debug avec une variable shell - Dev : on peut désactiver la barre de debug avec une variable shell
- Remplace les CSS de Google par des polices de proximité - Remplace les CSS de Google par des polices de proximité
- Passage du site du COF et de la K-Fêt en Wagtail 2.3 et Wagtail-modeltranslation 0.9 - Passage du site du COF et de la K-Fêt en Wagtail 2.3 et Wagtail-modeltranslation 0.9

View file

@ -69,7 +69,7 @@ class SpectacleReventeTests(TestCase):
revente = self.rev revente = self.rev
wanted_by = [self.p1, self.p2, self.p3] wanted_by = [self.p1, self.p2, self.p3]
revente.confirmed_entry = wanted_by revente.confirmed_entry.set(wanted_by)
with mock.patch("bda.models.random.choice") as mc: with mock.patch("bda.models.random.choice") as mc:
# Set winner to self.p1. # Set winner to self.p1.

View file

@ -112,7 +112,6 @@ MIDDLEWARE = [
"django.middleware.common.CommonMiddleware", "django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware", "django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.auth.middleware.SessionAuthenticationMiddleware",
"kfet.auth.middleware.TemporaryAuthMiddleware", "kfet.auth.middleware.TemporaryAuthMiddleware",
"django.contrib.messages.middleware.MessageMiddleware", "django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware",

View file

@ -44,8 +44,8 @@ def show_toolbar(request):
if not TESTING: if not TESTING:
INSTALLED_APPS += ["debug_toolbar", "debug_panel"] INSTALLED_APPS += ["debug_toolbar"]
MIDDLEWARE = ["debug_panel.middleware.DebugPanelMiddleware"] + MIDDLEWARE MIDDLEWARE = ["debug_toolbar.middleware.DebugToolbarMiddleware"] + MIDDLEWARE
DEBUG_TOOLBAR_CONFIG = {"SHOW_TOOLBAR_CALLBACK": show_toolbar} DEBUG_TOOLBAR_CONFIG = {"SHOW_TOOLBAR_CALLBACK": show_toolbar}

View file

@ -3,11 +3,11 @@ Fichier principal de configuration des urls du projet GestioCOF
""" """
from django.conf import settings from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.i18n import i18n_patterns from django.conf.urls.i18n import i18n_patterns
from django.conf.urls.static import static from django.conf.urls.static import static
from django.contrib import admin from django.contrib import admin
from django.contrib.auth import views as django_views from django.contrib.auth import views as django_auth_views
from django.urls import include, path
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from django_cas_ng import views as django_cas_views from django_cas_ng import views as django_cas_views
from wagtail.admin import urls as wagtailadmin_urls from wagtail.admin import urls as wagtailadmin_urls
@ -28,107 +28,105 @@ admin.autodiscover()
urlpatterns = [ urlpatterns = [
# Page d'accueil # Page d'accueil
url(r"^$", gestioncof_views.home, name="home"), path("", gestioncof_views.home, name="home"),
# Le BdA # Le BdA
url(r"^bda/", include("bda.urls")), path("bda/", include("bda.urls")),
# Les exports # Les exports
url(r"^export/", include(export_patterns)), path("export/", include(export_patterns)),
# Les petits cours # Les petits cours
url(r"^petitcours/", include("petitscours.urls")), path("petitcours/", include("petitscours.urls")),
# Les sondages # Les sondages
url(r"^survey/", include(surveys_patterns)), path("survey/", include(surveys_patterns)),
# Evenements # Evenements
url(r"^event/", include(events_patterns)), path("event/", include(events_patterns)),
# Calendrier # Calendrier
url(r"^calendar/", include(calendar_patterns)), path("calendar/", include(calendar_patterns)),
# Clubs # Clubs
url(r"^clubs/", include(clubs_patterns)), path("clubs/", include(clubs_patterns)),
# Authentification # Authentification
url( path(
r"^cof/denied$", "cof/denied",
TemplateView.as_view(template_name="cof-denied.html"), TemplateView.as_view(template_name="cof-denied.html"),
name="cof-denied", name="cof-denied",
), ),
url(r"^cas/login$", django_cas_views.LoginView.as_view(), name="cas_login_view"), path("cas/login", django_cas_views.LoginView.as_view(), name="cas_login_view"),
url(r"^cas/logout$", django_cas_views.LogoutView.as_view()), path("cas/logout", django_cas_views.LogoutView.as_view()),
url( path(
r"^outsider/login$", "outsider/login", gestioncof_views.LoginExtView.as_view(), name="ext_login_view"
gestioncof_views.LoginExtView.as_view(),
name="ext_login_view",
), ),
url(r"^outsider/logout$", django_views.LogoutView.as_view(), {"next_page": "home"}), path(
url(r"^login$", gestioncof_views.login, name="cof-login"), "outsider/logout", django_auth_views.LogoutView.as_view(), {"next_page": "home"}
url(r"^logout$", gestioncof_views.logout, name="cof-logout"), ),
path("login", gestioncof_views.login, name="cof-login"),
path("logout", gestioncof_views.logout, name="cof-logout"),
# Infos persos # Infos persos
url(r"^profile$", gestioncof_views.profile, name="profile"), path("profile", gestioncof_views.profile, name="profile"),
url( path(
r"^outsider/password-change$", "outsider/password-change",
django_views.password_change, django_auth_views.PasswordChangeView.as_view(),
name="password_change", name="password_change",
), ),
url( path(
r"^outsider/password-change-done$", "outsider/password-change-done",
django_views.password_change_done, django_auth_views.PasswordChangeDoneView.as_view(),
name="password_change_done", name="password_change_done",
), ),
# Inscription d'un nouveau membre # Inscription d'un nouveau membre
url(r"^registration$", gestioncof_views.registration, name="registration"), path("registration", gestioncof_views.registration, name="registration"),
url( path(
r"^registration/clipper/(?P<login_clipper>[\w-]+)/" r"(?P<fullname>.*)$", "registration/clipper/<slug:login_clipper>/<fullname>",
gestioncof_views.registration_form2, gestioncof_views.registration_form2,
name="clipper-registration", name="clipper-registration",
), ),
url( path(
r"^registration/user/(?P<username>.+)$", "registration/user/<username>",
gestioncof_views.registration_form2, gestioncof_views.registration_form2,
name="user-registration", name="user-registration",
), ),
url( path(
r"^registration/empty$", "registration/empty",
gestioncof_views.registration_form2, gestioncof_views.registration_form2,
name="empty-registration", name="empty-registration",
), ),
# Autocompletion # Autocompletion
url( path(
r"^autocomplete/registration$", "autocomplete/registration", autocomplete, name="cof.registration.autocomplete"
autocomplete,
name="cof.registration.autocomplete",
), ),
url( path(
r"^user/autocomplete$", "user/autocomplete",
gestioncof_views.user_autocomplete, gestioncof_views.user_autocomplete,
name="cof-user-autocomplete", name="cof-user-autocomplete",
), ),
# Interface admin # Interface admin
url(r"^admin/logout/", gestioncof_views.logout), path("admin/logout/", gestioncof_views.logout),
url(r"^admin/doc/", include("django.contrib.admindocs.urls")), path("admin/doc/", include("django.contrib.admindocs.urls")),
url( path(
r"^admin/(?P<app_label>[\d\w]+)/(?P<model_name>[\d\w]+)/csv/", "admin/<slug:app_label>/<slug:model_name>/csv/",
csv_views.admin_list_export, csv_views.admin_list_export,
{"fields": ["username"]}, {"fields": ["username"]},
), ),
url(r"^admin/", include(admin.site.urls)), path("admin/", admin.site.urls),
# Liens utiles du COF et du BdA # Liens utiles du COF et du BdA
url(r"^utile_cof$", gestioncof_views.utile_cof, name="utile_cof"), path("utile_cof", gestioncof_views.utile_cof, name="utile_cof"),
url(r"^utile_bda$", gestioncof_views.utile_bda, name="utile_bda"), path("utile_bda", gestioncof_views.utile_bda, name="utile_bda"),
url(r"^utile_bda/bda_diff$", gestioncof_views.liste_bdadiff, name="ml_diffbda"), path("utile_bda/bda_diff", gestioncof_views.liste_bdadiff, name="ml_diffbda"),
url(r"^utile_cof/diff_cof$", gestioncof_views.liste_diffcof, name="ml_diffcof"), path("utile_cof/diff_cof", gestioncof_views.liste_diffcof, name="ml_diffcof"),
url( path(
r"^utile_bda/bda_revente$", "utile_bda/bda_revente",
gestioncof_views.liste_bdarevente, gestioncof_views.liste_bdarevente,
name="ml_bda_revente", name="ml_bda_revente",
), ),
url(r"^k-fet/", include("kfet.urls")), path("k-fet/", include("kfet.urls")),
url(r"^cms/", include(wagtailadmin_urls)), path("cms/", include(wagtailadmin_urls)),
url(r"^documents/", include(wagtaildocs_urls)), path("documents/", include(wagtaildocs_urls)),
# djconfig # djconfig
url(r"^config", gestioncof_views.ConfigUpdate.as_view(), name="config.edit"), path("config", gestioncof_views.ConfigUpdate.as_view(), name="config.edit"),
] ]
if "debug_toolbar" in settings.INSTALLED_APPS: if "debug_toolbar" in settings.INSTALLED_APPS:
import debug_toolbar import debug_toolbar
urlpatterns += [url(r"^__debug__/", include(debug_toolbar.urls))] urlpatterns += [path("__debug__/", include(debug_toolbar.urls))]
if settings.DEBUG: if settings.DEBUG:
# Si on est en production, MEDIA_ROOT est servi par Apache. # Si on est en production, MEDIA_ROOT est servi par Apache.
@ -137,5 +135,5 @@ if settings.DEBUG:
# Wagtail for uncatched # Wagtail for uncatched
urlpatterns += i18n_patterns( urlpatterns += i18n_patterns(
url(r"", include(wagtail_urls)), prefix_default_language=False path("", include(wagtail_urls)), prefix_default_language=False
) )

View file

@ -0,0 +1,32 @@
# Generated by Django 2.2 on 2019-05-23 13:21
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [("cofcms", "0001_initial")]
operations = [
migrations.AlterField(
model_name="cofactupage",
name="all_day",
field=models.BooleanField(
blank=True, default=False, verbose_name="Toute la journée"
),
),
migrations.AlterField(
model_name="cofactupage",
name="is_event",
field=models.BooleanField(
blank=True, default=True, verbose_name="Évènement"
),
),
migrations.AlterField(
model_name="cofdirectorypage",
name="alphabetique",
field=models.BooleanField(
blank=True, default=True, verbose_name="Tri par ordre alphabétique ?"
),
),
]

View file

@ -38,9 +38,13 @@ def admin_list_export(
request, model_name, app_label, queryset=None, fields=None, list_display=True request, model_name, app_label, queryset=None, fields=None, list_display=True
): ):
""" """
Put the following line in your urls.py BEFORE your admin include Put the following line in your urls.py BEFORE your admin include:
(r'^admin/(?P<app_label>[\d\w]+)/(?P<model_name>[\d\w]+)/csv/',
'util.csv_view.admin_list_export'), path(
"admin/<slug:app_label>/<slug:model_name>/csv/",
csv_views.admin_list_export,
{"fields": ["username"]},
),
""" """
if not request.user.is_staff: if not request.user.is_staff:
return HttpResponseForbidden() return HttpResponseForbidden()

View file

@ -1,51 +1,43 @@
from django.conf.urls import url from django.urls import path
from gestioncof import views from gestioncof import views
from gestioncof.decorators import buro_required
export_patterns = [ export_patterns = [
url(r"^members$", views.export_members, name="cof.membres_export"), path("members", views.export_members, name="cof.membres_export"),
url( path(
r"^mega/avecremarques$", "mega/avecremarques",
views.export_mega_remarksonly, views.export_mega_remarksonly,
name="cof.mega_export_remarks", name="cof.mega_export_remarks",
), ),
url( path(
r"^mega/participants$", "mega/participants",
views.export_mega_participants, views.export_mega_participants,
name="cof.mega_export_participants", name="cof.mega_export_participants",
), ),
url(r"^mega/orgas$", views.export_mega_orgas, name="cof.mega_export_orgas"), path("mega/orgas", views.export_mega_orgas, name="cof.mega_export_orgas"),
# url(r'^mega/(?P<type>.+)$', views.export_mega_bytype), path("mega", views.export_mega, name="cof.mega_export"),
url(r"^mega$", views.export_mega, name="cof.mega_export"),
] ]
surveys_patterns = [ surveys_patterns = [
url( path("<int:survey_id>/status", views.survey_status, name="survey.details.status"),
r"^(?P<survey_id>\d+)/status$", path("<int:survey_id>", views.survey, name="survey.details"),
views.survey_status,
name="survey.details.status",
),
url(r"^(?P<survey_id>\d+)$", views.survey, name="survey.details"),
] ]
events_patterns = [ events_patterns = [
url(r"^(?P<event_id>\d+)$", views.event, name="event.details"), path("<int:event_id>", views.event, name="event.details"),
url(r"^(?P<event_id>\d+)/status$", views.event_status, name="event.details.status"), path("<int:event_id>/status", views.event_status, name="event.details.status"),
] ]
calendar_patterns = [ calendar_patterns = [
url(r"^subscription$", views.calendar, name="calendar"), path("subscription", views.calendar, name="calendar"),
url( path("<slug:token>/calendar.ics", views.calendar_ics, name="calendar.ics"),
r"^(?P<token>[a-z0-9-]+)/calendar.ics$", views.calendar_ics, name="calendar.ics"
),
] ]
clubs_patterns = [ clubs_patterns = [
url(r"^membres/(?P<name>\w+)", views.membres_club, name="membres-club"), path("membres/<slug:name>", views.membres_club, name="membres-club"),
url(r"^liste", views.liste_clubs, name="liste-clubs"), path("liste", views.liste_clubs, name="liste-clubs"),
url( path(
r"^change_respo/(?P<club_name>\w+)/(?P<user_id>\d+)", "change_respo/<slug:club_name>/<int:user_id>",
views.change_respo, views.change_respo,
name="change-respo", name="change-respo",
), ),

View file

@ -164,7 +164,7 @@ def survey(request, survey_id):
except SurveyAnswer.DoesNotExist: except SurveyAnswer.DoesNotExist:
current_answer = SurveyAnswer(user=request.user, survey=survey) current_answer = SurveyAnswer(user=request.user, survey=survey)
current_answer.save() current_answer.save()
current_answer.answers = all_answers current_answer.answers.set(all_answers)
current_answer.save() current_answer.save()
success = True success = True
else: else:
@ -234,7 +234,7 @@ def event(request, event_id):
(current_registration, _) = EventRegistration.objects.get_or_create( (current_registration, _) = EventRegistration.objects.get_or_create(
user=request.user, event=event user=request.user, event=event
) )
current_registration.options = all_choices current_registration.options.set(all_choices)
current_registration.save() current_registration.save()
success = True success = True
else: else:
@ -521,7 +521,7 @@ def registration(request):
user=member, event=form.event user=member, event=form.event
) )
update_event_form_comments(form.event, form, current_registration) update_event_form_comments(form.event, form, current_registration)
current_registration.options = all_choices current_registration.options.set(all_choices)
current_registration.paid = form.cleaned_data["status"] == "paid" current_registration.paid = form.cleaned_data["status"] == "paid"
current_registration.save() current_registration.save()
# if form.event.title == "Mega 15" and created_reg: # if form.event.title == "Mega 15" and created_reg:
@ -754,7 +754,7 @@ def export_mega_participants(request):
@buro_required @buro_required
def export_mega(request): def export_mega(request):
event = Event.objects.filter(title=MEGA_EVENT_NAME) event = Event.objects.get(title=MEGA_EVENT_NAME)
qs = EventRegistration.objects.filter(event=event).order_by("user__username") qs = EventRegistration.objects.filter(event=event).order_by("user__username")
return csv_export_mega("all_mega_{}.csv".format(MEGA_YEAR), qs) return csv_export_mega("all_mega_{}.csv".format(MEGA_YEAR), qs)

View file

@ -11,7 +11,7 @@ class TriStateCheckbox(Widget):
# more than once. # more than once.
self.choices = list(choices) self.choices = list(choices)
def render(self, name, value, attrs=None, choices=()): def render(self, name, value, attrs=None, choices=(), renderer=None):
if value is None: if value is None:
value = "none" value = "none"
attrs["value"] = value attrs["value"] = value

View file

@ -202,7 +202,7 @@ class GenericLoginViewTests(TestCase):
cookie = client.cookies[key] cookie = client.cookies[key]
# It also can be emptied. # It also can be emptied.
self.assertEqual(cookie.value, "") self.assertEqual(cookie.value, "")
self.assertEqual(cookie["expires"], "Thu, 01-Jan-1970 00:00:00 GMT") self.assertEqual(cookie["expires"], "Thu, 01 Jan 1970 00:00:00 GMT")
self.assertEqual(cookie["max-age"], 0) self.assertEqual(cookie["max-age"], 0)
except AssertionError: except AssertionError:
raise AssertionError("The cookie '%s' still exists." % key) raise AssertionError("The cookie '%s' still exists." % key)

15
kfet/converters.py Normal file
View file

@ -0,0 +1,15 @@
"""
Les converters sont la méthode "clean" de faire les regex custom dans des URLs django.
Plus d'info dans la doc :
https://docs.djangoproject.com/en/2.2/topics/http/urls/#registering-custom-path-converters
"""
class TrigrammeConverter:
regex = ".{3}"
def to_python(self, value):
return str(value)
def to_url(self, value):
return str(value)

View file

@ -57,8 +57,8 @@ class Migration(migrations.Migration):
dependencies = [ dependencies = [
("kfet", "0054_delete_settings"), ("kfet", "0054_delete_settings"),
("contenttypes", "__latest__"), ("contenttypes", "0001_initial"),
("auth", "__latest__"), ("auth", "0001_initial"),
] ]
operations = [ operations = [

View file

@ -1,8 +1,8 @@
from django.conf.urls import url from django.urls import path
from . import views from . import views
urlpatterns = [ urlpatterns = [
url(r"^raw_open$", views.raw_open, name="kfet.open.edit_raw_open"), path("raw_open", views.raw_open, name="kfet.open.edit_raw_open"),
url(r"^force_close$", views.force_close, name="kfet.open.edit_force_close"), path("force_close", views.force_close, name="kfet.open.edit_force_close"),
] ]

View file

@ -107,8 +107,6 @@ class OperationHelpersTest(TestCase):
self.assertDictEqual( self.assertDictEqual(
operation_group.__dict__, operation_group.__dict__,
{ {
"_checkout_cache": checkout,
"_on_acc_cache": on_acc,
"_state": mock.ANY, "_state": mock.ANY,
"amount": 0, "amount": 0,
"at": mock.ANY, "at": mock.ANY,

View file

@ -1,95 +1,97 @@
from django.conf.urls import include, url
from django.contrib.auth.decorators import permission_required from django.contrib.auth.decorators import permission_required
from django.urls import include, path, register_converter
from kfet import autocomplete, views from kfet import autocomplete, converters, views
from kfet.decorators import teamkfet_required from kfet.decorators import teamkfet_required
register_converter(converters.TrigrammeConverter, "trigramme")
urlpatterns = [ urlpatterns = [
url(r"^login/generic$", views.login_generic, name="kfet.login.generic"), path("login/generic", views.login_generic, name="kfet.login.generic"),
url(r"^history$", views.history, name="kfet.history"), path("history", views.history, name="kfet.history"),
# ----- # -----
# Account urls # Account urls
# ----- # -----
# Account - General # Account - General
url(r"^accounts/$", views.account, name="kfet.account"), path("accounts/", views.account, name="kfet.account"),
url( path(
r"^accounts/is_validandfree$", "accounts/is_validandfree",
views.account_is_validandfree_ajax, views.account_is_validandfree_ajax,
name="kfet.account.is_validandfree.ajax", name="kfet.account.is_validandfree.ajax",
), ),
# Account - Create # Account - Create
url(r"^accounts/new$", views.account_create, name="kfet.account.create"), path("accounts/new", views.account_create, name="kfet.account.create"),
url( path(
r"^accounts/new/user/(?P<username>.+)$", "accounts/new/user/<username>",
views.account_create_ajax, views.account_create_ajax,
name="kfet.account.create.fromuser", name="kfet.account.create.fromuser",
), ),
url( path(
r"^accounts/new/clipper/(?P<login_clipper>[\w-]+)/(?P<fullname>.*)$", "accounts/new/clipper/<slug:login_clipper>/<fullname>",
views.account_create_ajax, views.account_create_ajax,
name="kfet.account.create.fromclipper", name="kfet.account.create.fromclipper",
), ),
url( path(
r"^accounts/new/empty$", "accounts/new/empty",
views.account_create_ajax, views.account_create_ajax,
name="kfet.account.create.empty", name="kfet.account.create.empty",
), ),
url( path(
r"^autocomplete/account_new$", "autocomplete/account_new",
autocomplete.account_create, autocomplete.account_create,
name="kfet.account.create.autocomplete", name="kfet.account.create.autocomplete",
), ),
# Account - Search # Account - Search
url( path(
r"^autocomplete/account_search$", "autocomplete/account_search",
autocomplete.account_search, autocomplete.account_search,
name="kfet.account.search.autocomplete", name="kfet.account.search.autocomplete",
), ),
# Account - Read # Account - Read
url( path(
r"^accounts/(?P<trigramme>.{3})$", views.account_read, name="kfet.account.read" "accounts/<trigramme:trigramme>", views.account_read, name="kfet.account.read"
), ),
# Account - Update # Account - Update
url( path(
r"^accounts/(?P<trigramme>.{3})/edit$", "accounts/<trigramme:trigramme>/edit",
views.account_update, views.account_update,
name="kfet.account.update", name="kfet.account.update",
), ),
# Account - Groups # Account - Groups
url(r"^accounts/groups$", views.account_group, name="kfet.account.group"), path("accounts/groups", views.account_group, name="kfet.account.group"),
url( path(
r"^accounts/groups/new$", "accounts/groups/new",
permission_required("kfet.manage_perms")(views.AccountGroupCreate.as_view()), permission_required("kfet.manage_perms")(views.AccountGroupCreate.as_view()),
name="kfet.account.group.create", name="kfet.account.group.create",
), ),
url( path(
r"^accounts/groups/(?P<pk>\d+)/edit$", "accounts/groups/<int:pk>/edit",
permission_required("kfet.manage_perms")(views.AccountGroupUpdate.as_view()), permission_required("kfet.manage_perms")(views.AccountGroupUpdate.as_view()),
name="kfet.account.group.update", name="kfet.account.group.update",
), ),
url( path(
r"^accounts/negatives$", "accounts/negatives",
permission_required("kfet.view_negs")(views.AccountNegativeList.as_view()), permission_required("kfet.view_negs")(views.AccountNegativeList.as_view()),
name="kfet.account.negative", name="kfet.account.negative",
), ),
# Account - Statistics # Account - Statistics
url( path(
r"^accounts/(?P<trigramme>.{3})/stat/operations/list$", "accounts/<trigramme:trigramme>/stat/operations/list",
views.AccountStatOperationList.as_view(), views.AccountStatOperationList.as_view(),
name="kfet.account.stat.operation.list", name="kfet.account.stat.operation.list",
), ),
url( path(
r"^accounts/(?P<trigramme>.{3})/stat/operations$", "accounts/<trigramme:trigramme>/stat/operations",
views.AccountStatOperation.as_view(), views.AccountStatOperation.as_view(),
name="kfet.account.stat.operation", name="kfet.account.stat.operation",
), ),
url( path(
r"^accounts/(?P<trigramme>.{3})/stat/balance/list$", "accounts/<trigramme:trigramme>/stat/balance/list",
views.AccountStatBalanceList.as_view(), views.AccountStatBalanceList.as_view(),
name="kfet.account.stat.balance.list", name="kfet.account.stat.balance.list",
), ),
url( path(
r"^accounts/(?P<trigramme>.{3})/stat/balance$", "accounts/<trigramme:trigramme>/stat/balance",
views.AccountStatBalance.as_view(), views.AccountStatBalance.as_view(),
name="kfet.account.stat.balance", name="kfet.account.stat.balance",
), ),
@ -97,26 +99,26 @@ urlpatterns = [
# Checkout urls # Checkout urls
# ----- # -----
# Checkout - General # Checkout - General
url( path(
"^checkouts/$", "checkouts/",
teamkfet_required(views.CheckoutList.as_view()), teamkfet_required(views.CheckoutList.as_view()),
name="kfet.checkout", name="kfet.checkout",
), ),
# Checkout - Create # Checkout - Create
url( path(
"^checkouts/new$", "checkouts/new",
teamkfet_required(views.CheckoutCreate.as_view()), teamkfet_required(views.CheckoutCreate.as_view()),
name="kfet.checkout.create", name="kfet.checkout.create",
), ),
# Checkout - Read # Checkout - Read
url( path(
"^checkouts/(?P<pk>\d+)$", "checkouts/<int:pk>",
teamkfet_required(views.CheckoutRead.as_view()), teamkfet_required(views.CheckoutRead.as_view()),
name="kfet.checkout.read", name="kfet.checkout.read",
), ),
# Checkout - Update # Checkout - Update
url( path(
"^checkouts/(?P<pk>\d+)/edit$", "checkouts/<int:pk>/edit",
teamkfet_required(views.CheckoutUpdate.as_view()), teamkfet_required(views.CheckoutUpdate.as_view()),
name="kfet.checkout.update", name="kfet.checkout.update",
), ),
@ -124,20 +126,20 @@ urlpatterns = [
# Checkout Statement urls # Checkout Statement urls
# ----- # -----
# Checkout Statement - General # Checkout Statement - General
url( path(
"^checkouts/statements/$", "checkouts/statements/",
teamkfet_required(views.CheckoutStatementList.as_view()), teamkfet_required(views.CheckoutStatementList.as_view()),
name="kfet.checkoutstatement", name="kfet.checkoutstatement",
), ),
# Checkout Statement - Create # Checkout Statement - Create
url( path(
"^checkouts/(?P<pk_checkout>\d+)/statements/add", "checkouts/<int:pk_checkout>/statements/add",
teamkfet_required(views.CheckoutStatementCreate.as_view()), teamkfet_required(views.CheckoutStatementCreate.as_view()),
name="kfet.checkoutstatement.create", name="kfet.checkoutstatement.create",
), ),
# Checkout Statement - Update # Checkout Statement - Update
url( path(
"^checkouts/(?P<pk_checkout>\d+)/statements/(?P<pk>\d+)/edit", "checkouts/<int:pk_checkout>/statements/<int:pk>/edit",
teamkfet_required(views.CheckoutStatementUpdate.as_view()), teamkfet_required(views.CheckoutStatementUpdate.as_view()),
name="kfet.checkoutstatement.update", name="kfet.checkoutstatement.update",
), ),
@ -145,140 +147,132 @@ urlpatterns = [
# Article urls # Article urls
# ----- # -----
# Category - General # Category - General
url( path(
"^categories/$", "categories/",
teamkfet_required(views.CategoryList.as_view()), teamkfet_required(views.CategoryList.as_view()),
name="kfet.category", name="kfet.category",
), ),
# Category - Update # Category - Update
url( path(
"^categories/(?P<pk>\d+)/edit$", "categories/<int:pk>/edit",
teamkfet_required(views.CategoryUpdate.as_view()), teamkfet_required(views.CategoryUpdate.as_view()),
name="kfet.category.update", name="kfet.category.update",
), ),
# Article - General # Article - General
url( path(
"^articles/$", "articles/", teamkfet_required(views.ArticleList.as_view()), name="kfet.article"
teamkfet_required(views.ArticleList.as_view()),
name="kfet.article",
), ),
# Article - Create # Article - Create
url( path(
"^articles/new$", "articles/new",
teamkfet_required(views.ArticleCreate.as_view()), teamkfet_required(views.ArticleCreate.as_view()),
name="kfet.article.create", name="kfet.article.create",
), ),
# Article - Read # Article - Read
url( path(
"^articles/(?P<pk>\d+)$", "articles/<int:pk>",
teamkfet_required(views.ArticleRead.as_view()), teamkfet_required(views.ArticleRead.as_view()),
name="kfet.article.read", name="kfet.article.read",
), ),
# Article - Update # Article - Update
url( path(
"^articles/(?P<pk>\d+)/edit$", "articles/<int:pk>/edit",
teamkfet_required(views.ArticleUpdate.as_view()), teamkfet_required(views.ArticleUpdate.as_view()),
name="kfet.article.update", name="kfet.article.update",
), ),
# Article - Statistics # Article - Statistics
url( path(
r"^articles/(?P<pk>\d+)/stat/sales/list$", "articles/<int:pk>/stat/sales/list",
views.ArticleStatSalesList.as_view(), views.ArticleStatSalesList.as_view(),
name="kfet.article.stat.sales.list", name="kfet.article.stat.sales.list",
), ),
url( path(
r"^articles/(?P<pk>\d+)/stat/sales$", "articles/<int:pk>/stat/sales",
views.ArticleStatSales.as_view(), views.ArticleStatSales.as_view(),
name="kfet.article.stat.sales", name="kfet.article.stat.sales",
), ),
# ----- # -----
# K-Psul urls # K-Psul urls
# ----- # -----
url("^k-psul/$", views.kpsul, name="kfet.kpsul"), path("k-psul/", views.kpsul, name="kfet.kpsul"),
url( path(
"^k-psul/checkout_data$", "k-psul/checkout_data",
views.kpsul_checkout_data, views.kpsul_checkout_data,
name="kfet.kpsul.checkout_data", name="kfet.kpsul.checkout_data",
), ),
url( path(
"^k-psul/perform_operations$", "k-psul/perform_operations",
views.kpsul_perform_operations, views.kpsul_perform_operations,
name="kfet.kpsul.perform_operations", name="kfet.kpsul.perform_operations",
), ),
url( path(
"^k-psul/cancel_operations$", "k-psul/cancel_operations",
views.kpsul_cancel_operations, views.kpsul_cancel_operations,
name="kfet.kpsul.cancel_operations", name="kfet.kpsul.cancel_operations",
), ),
url( path(
"^k-psul/articles_data", "k-psul/articles_data",
views.kpsul_articles_data, views.kpsul_articles_data,
name="kfet.kpsul.articles_data", name="kfet.kpsul.articles_data",
), ),
url( path(
"^k-psul/update_addcost$", "k-psul/update_addcost",
views.kpsul_update_addcost, views.kpsul_update_addcost,
name="kfet.kpsul.update_addcost", name="kfet.kpsul.update_addcost",
), ),
url( path(
"^k-psul/get_settings$", "k-psul/get_settings", views.kpsul_get_settings, name="kfet.kpsul.get_settings"
views.kpsul_get_settings,
name="kfet.kpsul.get_settings",
), ),
# ----- # -----
# JSON urls # JSON urls
# ----- # -----
url(r"^history.json$", views.history_json, name="kfet.history.json"), path("history.json", views.history_json, name="kfet.history.json"),
url( path("accounts/read.json", views.account_read_json, name="kfet.account.read.json"),
r"^accounts/read.json$", views.account_read_json, name="kfet.account.read.json"
),
# ----- # -----
# Settings urls # Settings urls
# ----- # -----
url(r"^settings/$", views.config_list, name="kfet.settings"), path("settings/", views.config_list, name="kfet.settings"),
url(r"^settings/edit$", views.config_update, name="kfet.settings.update"), path("settings/edit", views.config_update, name="kfet.settings.update"),
# ----- # -----
# Transfers urls # Transfers urls
# ----- # -----
url(r"^transfers/$", views.transfers, name="kfet.transfers"), path("transfers/", views.transfers, name="kfet.transfers"),
url(r"^transfers/new$", views.transfers_create, name="kfet.transfers.create"), path("transfers/new", views.transfers_create, name="kfet.transfers.create"),
url(r"^transfers/perform$", views.perform_transfers, name="kfet.transfers.perform"), path("transfers/perform", views.perform_transfers, name="kfet.transfers.perform"),
url(r"^transfers/cancel$", views.cancel_transfers, name="kfet.transfers.cancel"), path("transfers/cancel", views.cancel_transfers, name="kfet.transfers.cancel"),
# ----- # -----
# Inventories urls # Inventories urls
# ----- # -----
url( path(
r"^inventaires/$", "inventaires/",
teamkfet_required(views.InventoryList.as_view()), teamkfet_required(views.InventoryList.as_view()),
name="kfet.inventory", name="kfet.inventory",
), ),
url(r"^inventaires/new$", views.inventory_create, name="kfet.inventory.create"), path("inventaires/new", views.inventory_create, name="kfet.inventory.create"),
url( path(
r"^inventaires/(?P<pk>\d+)$", "inventaires/<int:pk>",
teamkfet_required(views.InventoryRead.as_view()), teamkfet_required(views.InventoryRead.as_view()),
name="kfet.inventory.read", name="kfet.inventory.read",
), ),
# ----- # -----
# Order urls # Order urls
# ----- # -----
url(r"^orders/$", teamkfet_required(views.OrderList.as_view()), name="kfet.order"), path("orders/", teamkfet_required(views.OrderList.as_view()), name="kfet.order"),
url( path(
r"^orders/(?P<pk>\d+)$", "orders/<int:pk>",
teamkfet_required(views.OrderRead.as_view()), teamkfet_required(views.OrderRead.as_view()),
name="kfet.order.read", name="kfet.order.read",
), ),
url( path(
r"^orders/suppliers/(?P<pk>\d+)/edit$", "orders/suppliers/<int:pk>/edit",
teamkfet_required(views.SupplierUpdate.as_view()), teamkfet_required(views.SupplierUpdate.as_view()),
name="kfet.order.supplier.update", name="kfet.order.supplier.update",
), ),
url( path(
r"^orders/suppliers/(?P<pk>\d+)/new-order$", "orders/suppliers/<int:pk>/new-order", views.order_create, name="kfet.order.new"
views.order_create,
name="kfet.order.new",
), ),
url( path(
r"^orders/(?P<pk>\d+)/to_inventory$", "orders/<int:pk>/to_inventory",
views.order_to_inventory, views.order_to_inventory,
name="kfet.order.to_inventory", name="kfet.order.to_inventory",
), ),
@ -286,5 +280,5 @@ urlpatterns = [
urlpatterns += [ urlpatterns += [
# K-Fêt Open urls # K-Fêt Open urls
url("^open/", include("kfet.open.urls")) path("open/", include("kfet.open.urls"))
] ]

View file

@ -1,35 +1,35 @@
from django.conf.urls import url from django.urls import path
from gestioncof.decorators import buro_required from gestioncof.decorators import buro_required
from petitscours import views from petitscours import views
from petitscours.views import DemandeDetailView, DemandeListView from petitscours.views import DemandeDetailView, DemandeListView
urlpatterns = [ urlpatterns = [
url(r"^inscription$", views.inscription, name="petits-cours-inscription"), path("inscription", views.inscription, name="petits-cours-inscription"),
url(r"^demande$", views.demande, name="petits-cours-demande"), path("demande", views.demande, name="petits-cours-demande"),
url( path(
r"^demande-raw$", "demande-raw",
views.demande, views.demande,
kwargs={"raw": True}, kwargs={"raw": True},
name="petits-cours-demande-raw", name="petits-cours-demande-raw",
), ),
url( path(
r"^demandes$", "demandes",
buro_required(DemandeListView.as_view()), buro_required(DemandeListView.as_view()),
name="petits-cours-demandes-list", name="petits-cours-demandes-list",
), ),
url( path(
r"^demandes/(?P<pk>\d+)$", "demandes/<int:pk>",
buro_required(DemandeDetailView.as_view()), buro_required(DemandeDetailView.as_view()),
name="petits-cours-demande-details", name="petits-cours-demande-details",
), ),
url( path(
r"^demandes/(?P<demande_id>\d+)/traitement$", "demandes/<int:demande_id>/traitement",
views.traitement, views.traitement,
name="petits-cours-demande-traitement", name="petits-cours-demande-traitement",
), ),
url( path(
r"^demandes/(?P<demande_id>\d+)/retraitement$", "demandes/<int:demande_id>/retraitement",
views.traitement, views.traitement,
kwargs={"redo": True}, kwargs={"redo": True},
name="petits-cours-demande-retraitement", name="petits-cours-demande-retraitement",

View file

@ -1,6 +1,5 @@
configparser==3.5.0 configparser==3.5.0
# TODO: change to 2.2 when out Django==2.2.*
Django==1.11.*
django-autocomplete-light==3.3.* django-autocomplete-light==3.3.*
django-autoslug==1.9.3 django-autoslug==1.9.3
django-cas-ng==3.6.* django-cas-ng==3.6.*
@ -8,7 +7,7 @@ django-djconfig==0.8.0
django-recaptcha==1.4.0 django-recaptcha==1.4.0
django-redis-cache==1.8.1 django-redis-cache==1.8.1
icalendar icalendar
psycopg2 psycopg2<2.8
Pillow Pillow
unicodecsv unicodecsv
django-bootstrap-form==3.3 django-bootstrap-form==3.3
@ -21,8 +20,7 @@ git+https://git.eleves.ens.fr/cof-geek/django_custommail.git#egg=django_customma
ldap3 ldap3
channels==1.1.5 channels==1.1.5
python-dateutil python-dateutil
# TODO: change to 2.5 when out (2.4 is not explicitly compatible with Django 2.2) wagtail==2.4.*
wagtail==2.3.*
wagtailmenus==2.12.* wagtailmenus==2.12.*
wagtail-modeltranslation==0.10.* wagtail-modeltranslation==0.10.*
django-cors-headers==2.2.0 django-cors-headers==2.2.0

View file

@ -4,9 +4,9 @@ from urllib.parse import parse_qs, urlparse
import icalendar import icalendar
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.core.urlresolvers import reverse
from django.http import QueryDict from django.http import QueryDict
from django.test import Client from django.test import Client
from django.urls import reverse
from django.utils import timezone from django.utils import timezone
from django.utils.functional import cached_property from django.utils.functional import cached_property