From 209cb1fbe573909939028bd3b62ae93930925c0a Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Fri, 12 Apr 2019 17:03:20 +0200 Subject: [PATCH 01/15] Update requirements to Django 2.2 --- requirements.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index 87725d39..350328ea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ configparser==3.5.0 -# TODO: change to 2.2 when out -Django==1.11.* +Django==2.2.* django-autocomplete-light==3.3.* django-autoslug==1.9.3 django-cas-ng==3.6.* @@ -21,8 +20,7 @@ git+https://git.eleves.ens.fr/cof-geek/django_custommail.git#egg=django_customma ldap3 channels==1.1.5 python-dateutil -# TODO: change to 2.5 when out (2.4 is not explicitly compatible with Django 2.2) -wagtail==2.3.* +wagtail==2.4.* wagtailmenus==2.12.* wagtail-modeltranslation==0.10.* django-cors-headers==2.2.0 From f32e4a9b0de04af833f354ddda9e30c29dac6bc0 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Fri, 12 Apr 2019 17:03:42 +0200 Subject: [PATCH 02/15] Fix error --- kfet/migrations/0055_move_permissions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kfet/migrations/0055_move_permissions.py b/kfet/migrations/0055_move_permissions.py index 9db3f793..11cc9083 100644 --- a/kfet/migrations/0055_move_permissions.py +++ b/kfet/migrations/0055_move_permissions.py @@ -57,8 +57,8 @@ class Migration(migrations.Migration): dependencies = [ ("kfet", "0054_delete_settings"), - ("contenttypes", "__latest__"), - ("auth", "__latest__"), + ("contenttypes", "0001_initial"), + ("auth", "0001_initial"), ] operations = [ From 759b6d9489ae7bc151642b7717e7408c99ad816b Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Fri, 12 Apr 2019 17:04:33 +0200 Subject: [PATCH 03/15] Update settings ; remove debug_panel --- cof/settings/common.py | 1 - cof/settings/dev.py | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cof/settings/common.py b/cof/settings/common.py index 92263ba9..1b6f3bd1 100644 --- a/cof/settings/common.py +++ b/cof/settings/common.py @@ -112,7 +112,6 @@ MIDDLEWARE = [ "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", - "django.contrib.auth.middleware.SessionAuthenticationMiddleware", "kfet.auth.middleware.TemporaryAuthMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", diff --git a/cof/settings/dev.py b/cof/settings/dev.py index afc944e0..3bf2f4f9 100644 --- a/cof/settings/dev.py +++ b/cof/settings/dev.py @@ -44,8 +44,8 @@ def show_toolbar(request): 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} From 019acb90ac4891bf766d8090472419055d6c6d83 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Fri, 12 Apr 2019 17:05:18 +0200 Subject: [PATCH 04/15] Global urlconf file --- cof/urls.py | 114 ++++++++++++++++++++++++++-------------------------- 1 file changed, 56 insertions(+), 58 deletions(-) diff --git a/cof/urls.py b/cof/urls.py index dddf88a3..0a239c62 100644 --- a/cof/urls.py +++ b/cof/urls.py @@ -3,11 +3,11 @@ Fichier principal de configuration des urls du projet GestioCOF """ from django.conf import settings -from django.conf.urls import include, url from django.conf.urls.i18n import i18n_patterns from django.conf.urls.static import static 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_cas_ng import views as django_cas_views from wagtail.admin import urls as wagtailadmin_urls @@ -28,107 +28,105 @@ admin.autodiscover() urlpatterns = [ # Page d'accueil - url(r"^$", gestioncof_views.home, name="home"), + path("", gestioncof_views.home, name="home"), # Le BdA - url(r"^bda/", include("bda.urls")), + path("bda/", include("bda.urls")), # Les exports - url(r"^export/", include(export_patterns)), + path("export/", include(export_patterns)), # Les petits cours - url(r"^petitcours/", include("petitscours.urls")), + path("petitcours/", include("petitscours.urls")), # Les sondages - url(r"^survey/", include(surveys_patterns)), + path("survey/", include(surveys_patterns)), # Evenements - url(r"^event/", include(events_patterns)), + path("event/", include(events_patterns)), # Calendrier - url(r"^calendar/", include(calendar_patterns)), + path("calendar/", include(calendar_patterns)), # Clubs - url(r"^clubs/", include(clubs_patterns)), + path("clubs/", include(clubs_patterns)), # Authentification - url( - r"^cof/denied$", + path( + "cof/denied", TemplateView.as_view(template_name="cof-denied.html"), name="cof-denied", ), - url(r"^cas/login$", django_cas_views.LoginView.as_view(), name="cas_login_view"), - url(r"^cas/logout$", django_cas_views.LogoutView.as_view()), - url( - r"^outsider/login$", - gestioncof_views.LoginExtView.as_view(), - name="ext_login_view", + path("cas/login", django_cas_views.LoginView.as_view(), name="cas_login_view"), + path("cas/logout", django_cas_views.LogoutView.as_view()), + path( + "outsider/login", gestioncof_views.LoginExtView.as_view(), name="ext_login_view" ), - url(r"^outsider/logout$", django_views.LogoutView.as_view(), {"next_page": "home"}), - url(r"^login$", gestioncof_views.login, name="cof-login"), - url(r"^logout$", gestioncof_views.logout, name="cof-logout"), + path( + "outsider/logout", django_auth_views.LogoutView.as_view(), {"next_page": "home"} + ), + path("login", gestioncof_views.login, name="cof-login"), + path("logout", gestioncof_views.logout, name="cof-logout"), # Infos persos - url(r"^profile$", gestioncof_views.profile, name="profile"), - url( - r"^outsider/password-change$", - django_views.password_change, + path("profile", gestioncof_views.profile, name="profile"), + path( + "outsider/password-change", + django_auth_views.PasswordChangeView.as_view(), name="password_change", ), - url( - r"^outsider/password-change-done$", - django_views.password_change_done, + path( + "outsider/password-change-done", + django_auth_views.PasswordChangeDoneView.as_view(), name="password_change_done", ), # Inscription d'un nouveau membre - url(r"^registration$", gestioncof_views.registration, name="registration"), - url( - r"^registration/clipper/(?P[\w-]+)/" r"(?P.*)$", + path("registration", gestioncof_views.registration, name="registration"), + path( + "registration/clipper//", gestioncof_views.registration_form2, name="clipper-registration", ), - url( - r"^registration/user/(?P.+)$", + path( + "registration/user/", gestioncof_views.registration_form2, name="user-registration", ), - url( - r"^registration/empty$", + path( + "registration/empty", gestioncof_views.registration_form2, name="empty-registration", ), # Autocompletion - url( - r"^autocomplete/registration$", - autocomplete, - name="cof.registration.autocomplete", + path( + "autocomplete/registration", autocomplete, name="cof.registration.autocomplete" ), - url( - r"^user/autocomplete$", + path( + "user/autocomplete", gestioncof_views.user_autocomplete, name="cof-user-autocomplete", ), # Interface admin - url(r"^admin/logout/", gestioncof_views.logout), - url(r"^admin/doc/", include("django.contrib.admindocs.urls")), - url( - r"^admin/(?P[\d\w]+)/(?P[\d\w]+)/csv/", + path("admin/logout/", gestioncof_views.logout), + path("admin/doc/", include("django.contrib.admindocs.urls")), + path( + "admin///csv/", csv_views.admin_list_export, {"fields": ["username"]}, ), - url(r"^admin/", include(admin.site.urls)), + path("admin/", admin.site.urls), # Liens utiles du COF et du BdA - url(r"^utile_cof$", gestioncof_views.utile_cof, name="utile_cof"), - url(r"^utile_bda$", gestioncof_views.utile_bda, name="utile_bda"), - url(r"^utile_bda/bda_diff$", gestioncof_views.liste_bdadiff, name="ml_diffbda"), - url(r"^utile_cof/diff_cof$", gestioncof_views.liste_diffcof, name="ml_diffcof"), - url( - r"^utile_bda/bda_revente$", + path("utile_cof", gestioncof_views.utile_cof, name="utile_cof"), + path("utile_bda", gestioncof_views.utile_bda, name="utile_bda"), + path("utile_bda/bda_diff", gestioncof_views.liste_bdadiff, name="ml_diffbda"), + path("utile_cof/diff_cof", gestioncof_views.liste_diffcof, name="ml_diffcof"), + path( + "utile_bda/bda_revente", gestioncof_views.liste_bdarevente, name="ml_bda_revente", ), - url(r"^k-fet/", include("kfet.urls")), - url(r"^cms/", include(wagtailadmin_urls)), - url(r"^documents/", include(wagtaildocs_urls)), + path("k-fet/", include("kfet.urls")), + path("cms/", include(wagtailadmin_urls)), + path("documents/", include(wagtaildocs_urls)), # 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: import debug_toolbar - urlpatterns += [url(r"^__debug__/", include(debug_toolbar.urls))] + urlpatterns += [path("__debug__/", include(debug_toolbar.urls))] if settings.DEBUG: # Si on est en production, MEDIA_ROOT est servi par Apache. @@ -137,5 +135,5 @@ if settings.DEBUG: # Wagtail for uncatched urlpatterns += i18n_patterns( - url(r"", include(wagtail_urls)), prefix_default_language=False + path("", include(wagtail_urls)), prefix_default_language=False ) From 271732f40d561622dc153124a2a70640a0328184 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Fri, 12 Apr 2019 17:06:53 +0200 Subject: [PATCH 05/15] =?UTF-8?q?K-F=C3=AAt=20urlconf=20file=20+=20convert?= =?UTF-8?q?er?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kfet/converters.py | 8 ++ kfet/open/urls.py | 6 +- kfet/urls.py | 216 ++++++++++++++++++++++----------------------- 3 files changed, 116 insertions(+), 114 deletions(-) create mode 100644 kfet/converters.py diff --git a/kfet/converters.py b/kfet/converters.py new file mode 100644 index 00000000..4b0842fe --- /dev/null +++ b/kfet/converters.py @@ -0,0 +1,8 @@ +class TrigrammeConverter: + regex = ".{3}" + + def to_python(self, value): + return str(value) + + def to_url(self, value): + return str(value) diff --git a/kfet/open/urls.py b/kfet/open/urls.py index c38b9ce4..8510adc4 100644 --- a/kfet/open/urls.py +++ b/kfet/open/urls.py @@ -1,8 +1,8 @@ -from django.conf.urls import url +from django.urls import path from . import views urlpatterns = [ - url(r"^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("raw_open", views.raw_open, name="kfet.open.edit_raw_open"), + path("force_close", views.force_close, name="kfet.open.edit_force_close"), ] diff --git a/kfet/urls.py b/kfet/urls.py index 531e0cc9..e3e3ad2d 100644 --- a/kfet/urls.py +++ b/kfet/urls.py @@ -1,95 +1,97 @@ -from django.conf.urls import include, url 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 +register_converter(converters.TrigrammeConverter, "trigramme") + urlpatterns = [ - url(r"^login/generic$", views.login_generic, name="kfet.login.generic"), - url(r"^history$", views.history, name="kfet.history"), + path("login/generic", views.login_generic, name="kfet.login.generic"), + path("history", views.history, name="kfet.history"), # ----- # Account urls # ----- # Account - General - url(r"^accounts/$", views.account, name="kfet.account"), - url( - r"^accounts/is_validandfree$", + path("accounts/", views.account, name="kfet.account"), + path( + "accounts/is_validandfree", views.account_is_validandfree_ajax, name="kfet.account.is_validandfree.ajax", ), # Account - Create - url(r"^accounts/new$", views.account_create, name="kfet.account.create"), - url( - r"^accounts/new/user/(?P.+)$", + path("accounts/new", views.account_create, name="kfet.account.create"), + path( + "accounts/new/user/", views.account_create_ajax, name="kfet.account.create.fromuser", ), - url( - r"^accounts/new/clipper/(?P[\w-]+)/(?P.*)$", + path( + "accounts/new/clipper//", views.account_create_ajax, name="kfet.account.create.fromclipper", ), - url( - r"^accounts/new/empty$", + path( + "accounts/new/empty", views.account_create_ajax, name="kfet.account.create.empty", ), - url( - r"^autocomplete/account_new$", + path( + "autocomplete/account_new", autocomplete.account_create, name="kfet.account.create.autocomplete", ), # Account - Search - url( - r"^autocomplete/account_search$", + path( + "autocomplete/account_search", autocomplete.account_search, name="kfet.account.search.autocomplete", ), # Account - Read - url( - r"^accounts/(?P.{3})$", views.account_read, name="kfet.account.read" + path( + "accounts/", views.account_read, name="kfet.account.read" ), # Account - Update - url( - r"^accounts/(?P.{3})/edit$", + path( + "accounts//edit", views.account_update, name="kfet.account.update", ), # Account - Groups - url(r"^accounts/groups$", views.account_group, name="kfet.account.group"), - url( - r"^accounts/groups/new$", + path("accounts/groups", views.account_group, name="kfet.account.group"), + path( + "accounts/groups/new", permission_required("kfet.manage_perms")(views.AccountGroupCreate.as_view()), name="kfet.account.group.create", ), - url( - r"^accounts/groups/(?P\d+)/edit$", + path( + "accounts/groups//edit", permission_required("kfet.manage_perms")(views.AccountGroupUpdate.as_view()), name="kfet.account.group.update", ), - url( - r"^accounts/negatives$", + path( + "accounts/negatives", permission_required("kfet.view_negs")(views.AccountNegativeList.as_view()), name="kfet.account.negative", ), # Account - Statistics - url( - r"^accounts/(?P.{3})/stat/operations/list$", + path( + "accounts//stat/operations/list", views.AccountStatOperationList.as_view(), name="kfet.account.stat.operation.list", ), - url( - r"^accounts/(?P.{3})/stat/operations$", + path( + "accounts//stat/operations", views.AccountStatOperation.as_view(), name="kfet.account.stat.operation", ), - url( - r"^accounts/(?P.{3})/stat/balance/list$", + path( + "accounts//stat/balance/list", views.AccountStatBalanceList.as_view(), name="kfet.account.stat.balance.list", ), - url( - r"^accounts/(?P.{3})/stat/balance$", + path( + "accounts//stat/balance", views.AccountStatBalance.as_view(), name="kfet.account.stat.balance", ), @@ -97,26 +99,26 @@ urlpatterns = [ # Checkout urls # ----- # Checkout - General - url( - "^checkouts/$", + path( + "checkouts/", teamkfet_required(views.CheckoutList.as_view()), name="kfet.checkout", ), # Checkout - Create - url( - "^checkouts/new$", + path( + "checkouts/new", teamkfet_required(views.CheckoutCreate.as_view()), name="kfet.checkout.create", ), # Checkout - Read - url( - "^checkouts/(?P\d+)$", + path( + "checkouts/", teamkfet_required(views.CheckoutRead.as_view()), name="kfet.checkout.read", ), # Checkout - Update - url( - "^checkouts/(?P\d+)/edit$", + path( + "checkouts//edit", teamkfet_required(views.CheckoutUpdate.as_view()), name="kfet.checkout.update", ), @@ -124,20 +126,20 @@ urlpatterns = [ # Checkout Statement urls # ----- # Checkout Statement - General - url( - "^checkouts/statements/$", + path( + "checkouts/statements/", teamkfet_required(views.CheckoutStatementList.as_view()), name="kfet.checkoutstatement", ), # Checkout Statement - Create - url( - "^checkouts/(?P\d+)/statements/add", + path( + "checkouts//statements/add", teamkfet_required(views.CheckoutStatementCreate.as_view()), name="kfet.checkoutstatement.create", ), # Checkout Statement - Update - url( - "^checkouts/(?P\d+)/statements/(?P\d+)/edit", + path( + "checkouts//statements//edit", teamkfet_required(views.CheckoutStatementUpdate.as_view()), name="kfet.checkoutstatement.update", ), @@ -145,140 +147,132 @@ urlpatterns = [ # Article urls # ----- # Category - General - url( - "^categories/$", + path( + "categories/", teamkfet_required(views.CategoryList.as_view()), name="kfet.category", ), # Category - Update - url( - "^categories/(?P\d+)/edit$", + path( + "categories//edit", teamkfet_required(views.CategoryUpdate.as_view()), name="kfet.category.update", ), # Article - General - url( - "^articles/$", - teamkfet_required(views.ArticleList.as_view()), - name="kfet.article", + path( + "articles/", teamkfet_required(views.ArticleList.as_view()), name="kfet.article" ), # Article - Create - url( - "^articles/new$", + path( + "articles/new", teamkfet_required(views.ArticleCreate.as_view()), name="kfet.article.create", ), # Article - Read - url( - "^articles/(?P\d+)$", + path( + "articles/", teamkfet_required(views.ArticleRead.as_view()), name="kfet.article.read", ), # Article - Update - url( - "^articles/(?P\d+)/edit$", + path( + "articles//edit", teamkfet_required(views.ArticleUpdate.as_view()), name="kfet.article.update", ), # Article - Statistics - url( - r"^articles/(?P\d+)/stat/sales/list$", + path( + "articles//stat/sales/list", views.ArticleStatSalesList.as_view(), name="kfet.article.stat.sales.list", ), - url( - r"^articles/(?P\d+)/stat/sales$", + path( + "articles//stat/sales", views.ArticleStatSales.as_view(), name="kfet.article.stat.sales", ), # ----- # K-Psul urls # ----- - url("^k-psul/$", views.kpsul, name="kfet.kpsul"), - url( - "^k-psul/checkout_data$", + path("k-psul/", views.kpsul, name="kfet.kpsul"), + path( + "k-psul/checkout_data", views.kpsul_checkout_data, name="kfet.kpsul.checkout_data", ), - url( - "^k-psul/perform_operations$", + path( + "k-psul/perform_operations", views.kpsul_perform_operations, name="kfet.kpsul.perform_operations", ), - url( - "^k-psul/cancel_operations$", + path( + "k-psul/cancel_operations", views.kpsul_cancel_operations, name="kfet.kpsul.cancel_operations", ), - url( - "^k-psul/articles_data", + path( + "k-psul/articles_data", views.kpsul_articles_data, name="kfet.kpsul.articles_data", ), - url( - "^k-psul/update_addcost$", + path( + "k-psul/update_addcost", views.kpsul_update_addcost, name="kfet.kpsul.update_addcost", ), - url( - "^k-psul/get_settings$", - views.kpsul_get_settings, - name="kfet.kpsul.get_settings", + path( + "k-psul/get_settings", views.kpsul_get_settings, name="kfet.kpsul.get_settings" ), # ----- # JSON urls # ----- - url(r"^history.json$", views.history_json, name="kfet.history.json"), - url( - r"^accounts/read.json$", views.account_read_json, name="kfet.account.read.json" - ), + path("history.json", views.history_json, name="kfet.history.json"), + path("accounts/read.json", views.account_read_json, name="kfet.account.read.json"), # ----- # Settings urls # ----- - url(r"^settings/$", views.config_list, name="kfet.settings"), - url(r"^settings/edit$", views.config_update, name="kfet.settings.update"), + path("settings/", views.config_list, name="kfet.settings"), + path("settings/edit", views.config_update, name="kfet.settings.update"), # ----- # Transfers urls # ----- - url(r"^transfers/$", views.transfers, name="kfet.transfers"), - url(r"^transfers/new$", views.transfers_create, name="kfet.transfers.create"), - url(r"^transfers/perform$", views.perform_transfers, name="kfet.transfers.perform"), - url(r"^transfers/cancel$", views.cancel_transfers, name="kfet.transfers.cancel"), + path("transfers/", views.transfers, name="kfet.transfers"), + path("transfers/new", views.transfers_create, name="kfet.transfers.create"), + path("transfers/perform", views.perform_transfers, name="kfet.transfers.perform"), + path("transfers/cancel", views.cancel_transfers, name="kfet.transfers.cancel"), # ----- # Inventories urls # ----- - url( - r"^inventaires/$", + path( + "inventaires/", teamkfet_required(views.InventoryList.as_view()), name="kfet.inventory", ), - url(r"^inventaires/new$", views.inventory_create, name="kfet.inventory.create"), - url( - r"^inventaires/(?P\d+)$", + path("inventaires/new", views.inventory_create, name="kfet.inventory.create"), + path( + "inventaires/", teamkfet_required(views.InventoryRead.as_view()), name="kfet.inventory.read", ), # ----- # Order urls # ----- - url(r"^orders/$", teamkfet_required(views.OrderList.as_view()), name="kfet.order"), - url( - r"^orders/(?P\d+)$", + path("orders/", teamkfet_required(views.OrderList.as_view()), name="kfet.order"), + path( + "orders/", teamkfet_required(views.OrderRead.as_view()), name="kfet.order.read", ), - url( - r"^orders/suppliers/(?P\d+)/edit$", + path( + "orders/suppliers//edit", teamkfet_required(views.SupplierUpdate.as_view()), name="kfet.order.supplier.update", ), - url( - r"^orders/suppliers/(?P\d+)/new-order$", - views.order_create, - name="kfet.order.new", + path( + "orders/suppliers//new-order", views.order_create, name="kfet.order.new" ), - url( - r"^orders/(?P\d+)/to_inventory$", + path( + "orders//to_inventory", views.order_to_inventory, name="kfet.order.to_inventory", ), @@ -286,5 +280,5 @@ urlpatterns = [ urlpatterns += [ # K-Fêt Open urls - url("^open/", include("kfet.open.urls")) + path("open/", include("kfet.open.urls")) ] From 8fc6f96324a3a3c5afa5fd965dd8e37b602296f8 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Fri, 12 Apr 2019 17:07:03 +0200 Subject: [PATCH 06/15] Misc urlconf files --- gestioncof/csv_views.py | 5 ----- gestioncof/urls.py | 45 +++++++++++++++++------------------------ petitscours/urls.py | 26 ++++++++++++------------ 3 files changed, 32 insertions(+), 44 deletions(-) diff --git a/gestioncof/csv_views.py b/gestioncof/csv_views.py index e85c78b0..2b66d495 100644 --- a/gestioncof/csv_views.py +++ b/gestioncof/csv_views.py @@ -37,11 +37,6 @@ def export(qs, fields=None): def admin_list_export( request, model_name, app_label, queryset=None, fields=None, list_display=True ): - """ - Put the following line in your urls.py BEFORE your admin include - (r'^admin/(?P[\d\w]+)/(?P[\d\w]+)/csv/', - 'util.csv_view.admin_list_export'), - """ if not request.user.is_staff: return HttpResponseForbidden() if not queryset: diff --git a/gestioncof/urls.py b/gestioncof/urls.py index e1e36a17..e35f9c32 100644 --- a/gestioncof/urls.py +++ b/gestioncof/urls.py @@ -1,51 +1,44 @@ -from django.conf.urls import url +from django.urls import path from gestioncof import views -from gestioncof.decorators import buro_required export_patterns = [ - url(r"^members$", views.export_members, name="cof.membres_export"), - url( - r"^mega/avecremarques$", + path("members", views.export_members, name="cof.membres_export"), + path( + "mega/avecremarques", views.export_mega_remarksonly, name="cof.mega_export_remarks", ), - url( - r"^mega/participants$", + path( + "mega/participants", views.export_mega_participants, name="cof.mega_export_participants", ), - url(r"^mega/orgas$", views.export_mega_orgas, name="cof.mega_export_orgas"), - # url(r'^mega/(?P.+)$', views.export_mega_bytype), - url(r"^mega$", views.export_mega, name="cof.mega_export"), + path("mega/orgas", views.export_mega_orgas, name="cof.mega_export_orgas"), + # path(r'^mega/(?P.+)$', views.export_mega_bytype), + path("mega", views.export_mega, name="cof.mega_export"), ] surveys_patterns = [ - url( - r"^(?P\d+)/status$", - views.survey_status, - name="survey.details.status", - ), - url(r"^(?P\d+)$", views.survey, name="survey.details"), + path("/status", views.survey_status, name="survey.details.status"), + path("", views.survey, name="survey.details"), ] events_patterns = [ - url(r"^(?P\d+)$", views.event, name="event.details"), - url(r"^(?P\d+)/status$", views.event_status, name="event.details.status"), + path("", views.event, name="event.details"), + path("/status", views.event_status, name="event.details.status"), ] calendar_patterns = [ - url(r"^subscription$", views.calendar, name="calendar"), - url( - r"^(?P[a-z0-9-]+)/calendar.ics$", views.calendar_ics, name="calendar.ics" - ), + path("subscription", views.calendar, name="calendar"), + path("/calendar.ics", views.calendar_ics, name="calendar.ics"), ] clubs_patterns = [ - url(r"^membres/(?P\w+)", views.membres_club, name="membres-club"), - url(r"^liste", views.liste_clubs, name="liste-clubs"), - url( - r"^change_respo/(?P\w+)/(?P\d+)", + path("membres/", views.membres_club, name="membres-club"), + path("liste", views.liste_clubs, name="liste-clubs"), + path( + "change_respo//", views.change_respo, name="change-respo", ), diff --git a/petitscours/urls.py b/petitscours/urls.py index f230846e..b4bf1538 100644 --- a/petitscours/urls.py +++ b/petitscours/urls.py @@ -1,35 +1,35 @@ -from django.conf.urls import url +from django.urls import path from gestioncof.decorators import buro_required from petitscours import views from petitscours.views import DemandeDetailView, DemandeListView urlpatterns = [ - url(r"^inscription$", views.inscription, name="petits-cours-inscription"), - url(r"^demande$", views.demande, name="petits-cours-demande"), - url( - r"^demande-raw$", + path("inscription", views.inscription, name="petits-cours-inscription"), + path("demande", views.demande, name="petits-cours-demande"), + path( + "demande-raw", views.demande, kwargs={"raw": True}, name="petits-cours-demande-raw", ), - url( - r"^demandes$", + path( + "demandes", buro_required(DemandeListView.as_view()), name="petits-cours-demandes-list", ), - url( - r"^demandes/(?P\d+)$", + path( + "demandes/", buro_required(DemandeDetailView.as_view()), name="petits-cours-demande-details", ), - url( - r"^demandes/(?P\d+)/traitement$", + path( + "demandes//traitement", views.traitement, name="petits-cours-demande-traitement", ), - url( - r"^demandes/(?P\d+)/retraitement$", + path( + "demandes//retraitement", views.traitement, kwargs={"redo": True}, name="petits-cours-demande-retraitement", From a2fcc05672ecec82c76651eb134b2c97e8f46f52 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Fri, 12 Apr 2019 18:30:03 +0200 Subject: [PATCH 07/15] Test fix : freeze psycopg2 version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 350328ea..0f0b5cc3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ django-djconfig==0.8.0 django-recaptcha==1.4.0 django-redis-cache==1.8.1 icalendar -psycopg2 +psycopg2<2.8 Pillow unicodecsv django-bootstrap-form==3.3 From 4064218010654a612510ca35c6f07a8566497d17 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Wed, 17 Apr 2019 18:21:15 +0200 Subject: [PATCH 08/15] Forgot one import --- shared/tests/testcases.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/tests/testcases.py b/shared/tests/testcases.py index 11de06fb..35d697e7 100644 --- a/shared/tests/testcases.py +++ b/shared/tests/testcases.py @@ -4,9 +4,9 @@ from urllib.parse import parse_qs, urlparse import icalendar from django.contrib.auth import get_user_model -from django.core.urlresolvers import reverse from django.http import QueryDict from django.test import Client +from django.urls import reverse from django.utils import timezone from django.utils.functional import cached_property From 413a9cddb1878a4afb5c9f36a5be64447a3e0590 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Wed, 17 Apr 2019 18:21:59 +0200 Subject: [PATCH 09/15] Backwards-incompatible changes : manytomany set --- bda/tests/test_models.py | 2 +- gestioncof/views.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bda/tests/test_models.py b/bda/tests/test_models.py index b8a23ba7..ba96238a 100644 --- a/bda/tests/test_models.py +++ b/bda/tests/test_models.py @@ -69,7 +69,7 @@ class SpectacleReventeTests(TestCase): revente = self.rev 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: # Set winner to self.p1. diff --git a/gestioncof/views.py b/gestioncof/views.py index f5000456..fe9013de 100644 --- a/gestioncof/views.py +++ b/gestioncof/views.py @@ -164,7 +164,7 @@ def survey(request, survey_id): except SurveyAnswer.DoesNotExist: current_answer = SurveyAnswer(user=request.user, survey=survey) current_answer.save() - current_answer.answers = all_answers + current_answer.answers.set(all_answers) current_answer.save() success = True else: @@ -234,7 +234,7 @@ def event(request, event_id): (current_registration, _) = EventRegistration.objects.get_or_create( user=request.user, event=event ) - current_registration.options = all_choices + current_registration.options.set(all_choices) current_registration.save() success = True else: @@ -521,7 +521,7 @@ def registration(request): user=member, event=form.event ) 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.save() # if form.event.title == "Mega 15" and created_reg: From 72560397a2cf8c8f90c4aca68793f73f235e64f0 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Wed, 17 Apr 2019 18:27:14 +0200 Subject: [PATCH 10/15] Backwards-incompatible changes : renderer argument --- gestioncof/widgets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gestioncof/widgets.py b/gestioncof/widgets.py index 49125896..9206d441 100644 --- a/gestioncof/widgets.py +++ b/gestioncof/widgets.py @@ -11,7 +11,7 @@ class TriStateCheckbox(Widget): # more than once. 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: value = "none" attrs["value"] = value From 7717d1ed34e0ab5994b867a9a149a911fa2efb8c Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Wed, 17 Apr 2019 18:33:43 +0200 Subject: [PATCH 11/15] Backwards-incompatible changes : queryset in filter --- gestioncof/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gestioncof/views.py b/gestioncof/views.py index fe9013de..bd397ed6 100644 --- a/gestioncof/views.py +++ b/gestioncof/views.py @@ -754,7 +754,7 @@ def export_mega_participants(request): @buro_required 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") return csv_export_mega("all_mega_{}.csv".format(MEGA_YEAR), qs) From 03c74a7940754e70393db8461679e0318e099dbb Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Wed, 17 Apr 2019 20:50:49 +0200 Subject: [PATCH 12/15] Misc fixes --- kfet/auth/tests.py | 2 +- kfet/tests/test_tests_utils.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/kfet/auth/tests.py b/kfet/auth/tests.py index 5e284648..71fe945b 100644 --- a/kfet/auth/tests.py +++ b/kfet/auth/tests.py @@ -202,7 +202,7 @@ class GenericLoginViewTests(TestCase): cookie = client.cookies[key] # It also can be emptied. 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) except AssertionError: raise AssertionError("The cookie '%s' still exists." % key) diff --git a/kfet/tests/test_tests_utils.py b/kfet/tests/test_tests_utils.py index 25046abb..49661e23 100644 --- a/kfet/tests/test_tests_utils.py +++ b/kfet/tests/test_tests_utils.py @@ -107,8 +107,6 @@ class OperationHelpersTest(TestCase): self.assertDictEqual( operation_group.__dict__, { - "_checkout_cache": checkout, - "_on_acc_cache": on_acc, "_state": mock.ANY, "amount": 0, "at": mock.ANY, From 198658f5f9caf498f3adbc3ee45ba27b66fc7994 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Tue, 21 May 2019 15:30:51 +0200 Subject: [PATCH 13/15] Misc fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - on vire un commentaire obsolète, et on en remet un à jour - un peu de doc sur les converters --- gestioncof/csv_views.py | 9 +++++++++ gestioncof/urls.py | 1 - kfet/converters.py | 7 +++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gestioncof/csv_views.py b/gestioncof/csv_views.py index 2b66d495..3c163091 100644 --- a/gestioncof/csv_views.py +++ b/gestioncof/csv_views.py @@ -37,6 +37,15 @@ def export(qs, fields=None): def admin_list_export( request, model_name, app_label, queryset=None, fields=None, list_display=True ): + """ + Put the following line in your urls.py BEFORE your admin include: + + path( + "admin///csv/", + csv_views.admin_list_export, + {"fields": ["username"]}, + ), + """ if not request.user.is_staff: return HttpResponseForbidden() if not queryset: diff --git a/gestioncof/urls.py b/gestioncof/urls.py index e35f9c32..6a07eac9 100644 --- a/gestioncof/urls.py +++ b/gestioncof/urls.py @@ -15,7 +15,6 @@ export_patterns = [ name="cof.mega_export_participants", ), path("mega/orgas", views.export_mega_orgas, name="cof.mega_export_orgas"), - # path(r'^mega/(?P.+)$', views.export_mega_bytype), path("mega", views.export_mega, name="cof.mega_export"), ] diff --git a/kfet/converters.py b/kfet/converters.py index 4b0842fe..94400587 100644 --- a/kfet/converters.py +++ b/kfet/converters.py @@ -1,3 +1,10 @@ +""" +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}" From f03e708280818675ae01012513b338b767b435c2 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Thu, 23 May 2019 15:21:40 +0200 Subject: [PATCH 14/15] Tiens, une migration Wagtail --- .../cms/migrations/0002_auto_20190523_1521.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 gestioncof/cms/migrations/0002_auto_20190523_1521.py diff --git a/gestioncof/cms/migrations/0002_auto_20190523_1521.py b/gestioncof/cms/migrations/0002_auto_20190523_1521.py new file mode 100644 index 00000000..35e50b8e --- /dev/null +++ b/gestioncof/cms/migrations/0002_auto_20190523_1521.py @@ -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 ?" + ), + ), + ] From 8dd003f81f7d5bf2e3493a24d749a8aa723b666c Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Fri, 24 May 2019 09:36:14 +0200 Subject: [PATCH 15/15] Changelog --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index c2039d56..ec8f6077 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +- Passage à Django2 - Dev : on peut désactiver la barre de debug avec une variable shell - 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