From f63e2e088ee79308071f7f2a95e0012c68958289 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sun, 20 Sep 2020 08:56:42 +0200 Subject: [PATCH 01/56] Don't log when the permission to lock a note is checked --- apps/member/views.py | 3 +++ apps/permission/models.py | 1 + 2 files changed, 4 insertions(+) diff --git a/apps/member/views.py b/apps/member/views.py index 42bf98e4..6c4673fe 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -166,6 +166,8 @@ class UserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): # Check permissions to see if the authenticated user can lock/unlock the note with transaction.atomic(): modified_note = NoteUser.objects.get(pk=user.note.pk) + # Don't log these tests + modified_note._no_signal = True modified_note.is_active = True modified_note.inactivity_reason = 'manual' context["can_lock_note"] = user.note.is_active and PermissionBackend\ @@ -178,6 +180,7 @@ class UserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): context["can_force_lock"] = user.note.is_active and PermissionBackend\ .check_perm(self.request.user, "note.change_note_is_active", modified_note) old_note._force_save = True + old_note._no_signal = True old_note.save() modified_note.refresh_from_db() modified_note.is_active = True diff --git a/apps/permission/models.py b/apps/permission/models.py index 48d1b19a..ee7d3ec4 100644 --- a/apps/permission/models.py +++ b/apps/permission/models.py @@ -62,6 +62,7 @@ class InstancedPermission: Model.save(obj, force_insert=True) ret = self.model.model_class().objects.filter(self.query & Q(pk=0)).exists() # Delete testing object + obj._no_signal = True obj._force_delete = True Model.delete(obj) From 7353348d7abd38fae661ef74db11591e5f5b420f Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sun, 20 Sep 2020 09:07:51 +0200 Subject: [PATCH 02/56] Rollback transaction when checking an add permission (experimental) --- apps/permission/models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/permission/models.py b/apps/permission/models.py index ee7d3ec4..17214894 100644 --- a/apps/permission/models.py +++ b/apps/permission/models.py @@ -43,6 +43,7 @@ class InstancedPermission: obj = copy(obj) obj.pk = 0 with transaction.atomic(): + sid = transaction.savepoint() for o in self.model.model_class().objects.filter(pk=0).all(): o._force_delete = True Model.delete(o) @@ -65,6 +66,7 @@ class InstancedPermission: obj._no_signal = True obj._force_delete = True Model.delete(obj) + transaction.savepoint_rollback(sid) return ret From 3ba61385a3eb99bed426f9af36494f5975634ec3 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sun, 20 Sep 2020 11:12:44 +0200 Subject: [PATCH 03/56] Debit is not credit --- apps/note/static/note/js/transfer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/note/static/note/js/transfer.js b/apps/note/static/note/js/transfer.js index db9cf9ac..f6b23b29 100644 --- a/apps/note/static/note/js/transfer.js +++ b/apps/note/static/note/js/transfer.js @@ -388,7 +388,7 @@ $('#btn_transfer').click(function () { alias = sources_notes_display[0].name source_id = user_note.id dest_id = special_note - reason = 'Retrait ' + $('#credit_type option:selected').text().toLowerCase() + reason = 'Retrait ' + $('#debit_type option:selected').text().toLowerCase() if (given_reason.length > 0) { reason += ' (' + given_reason + ')' } } $.post('/api/note/transaction/transaction/', From 70448db8e5a1e667a6100c3cf504f4541ff5eccf Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Mon, 21 Sep 2020 10:31:42 +0200 Subject: [PATCH 04/56] Remove Django CAS server and add oauth toolkit --- .gitlab-ci.yml | 4 +- Dockerfile | 2 +- README.md | 2 +- ansible/roles/1-apt-basic/tasks/main.yml | 2 +- note_kfet/admin.py | 6 -- note_kfet/fixtures/cas.json | 11 --- note_kfet/settings/__init__.py | 7 -- note_kfet/settings/secrets_example.py | 1 - note_kfet/templates/cas_server/base.html | 99 ------------------------ note_kfet/urls.py | 6 -- requirements.txt | 2 +- 11 files changed, 6 insertions(+), 136 deletions(-) delete mode 100644 note_kfet/fixtures/cas.json delete mode 100644 note_kfet/templates/cas_server/base.html diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cada9068..61d5988c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,7 @@ py37-django22: apt-get install --no-install-recommends -t buster-backports -y python3-django python3-django-crispy-forms python3-django-extensions python3-django-filters python3-django-polymorphic - python3-djangorestframework python3-django-cas-server python3-psycopg2 python3-pil + python3-djangorestframework python3-django-oauth-toolkit python3-psycopg2 python3-pil python3-babel python3-lockfile python3-pip python3-phonenumbers python3-bs4 python3-setuptools tox texlive-xetex script: tox -e py37-django22 @@ -33,7 +33,7 @@ py38-django22: apt-get install --no-install-recommends -y python3-django python3-django-crispy-forms python3-django-extensions python3-django-filters python3-django-polymorphic - python3-djangorestframework python3-django-cas-server python3-psycopg2 python3-pil + python3-djangorestframework python3-django-oauth-toolkit python3-psycopg2 python3-pil python3-babel python3-lockfile python3-pip python3-phonenumbers python3-bs4 python3-setuptools tox texlive-xetex script: tox -e py38-django22 diff --git a/Dockerfile b/Dockerfile index 0dd1ce8b..9696de7c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN apt-get update && \ apt-get install --no-install-recommends -t buster-backports -y \ python3-django python3-django-crispy-forms \ python3-django-extensions python3-django-filters python3-django-polymorphic \ - python3-djangorestframework python3-django-cas-server python3-psycopg2 python3-pil \ + python3-djangorestframework python3-django-oauth-toolkit python3-psycopg2 python3-pil \ python3-babel python3-lockfile python3-pip python3-phonenumbers ipython3 \ python3-bs4 python3-setuptools \ uwsgi uwsgi-plugin-python3 \ diff --git a/README.md b/README.md index f2ada2a8..910fd19a 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ Sinon vous pouvez suivre les étapes décrites ci-dessous. $ sudo apt install --no-install-recommends -t buster-backports -y \ python3-django python3-django-crispy-forms \ python3-django-extensions python3-django-filters python3-django-polymorphic \ - python3-djangorestframework python3-django-cas-server python3-psycopg2 python3-pil \ + python3-djangorestframework python3-django-oauth-toolkit python3-psycopg2 python3-pil \ python3-babel python3-lockfile python3-pip python3-phonenumbers ipython3 \ python3-bs4 python3-setuptools \ uwsgi uwsgi-plugin-python3 \ diff --git a/ansible/roles/1-apt-basic/tasks/main.yml b/ansible/roles/1-apt-basic/tasks/main.yml index 1ca1b3d6..95f6d40a 100644 --- a/ansible/roles/1-apt-basic/tasks/main.yml +++ b/ansible/roles/1-apt-basic/tasks/main.yml @@ -23,10 +23,10 @@ - python3-babel - python3-bs4 - python3-django - - python3-django-cas-server - python3-django-crispy-forms - python3-django-extensions - python3-django-filters + - python3-django-oauth-toolkit - python3-django-polymorphic - python3-djangorestframework - python3-lockfile diff --git a/note_kfet/admin.py b/note_kfet/admin.py index f128b237..1fa228fe 100644 --- a/note_kfet/admin.py +++ b/note_kfet/admin.py @@ -44,9 +44,3 @@ if "rest_framework" in settings.INSTALLED_APPS: from rest_framework.authtoken.admin import * from rest_framework.authtoken.models import * admin_site.register(Token, TokenAdmin) - -if "cas_server" in settings.INSTALLED_APPS: - from cas_server.admin import * - from cas_server.models import * - admin_site.register(ServicePattern, ServicePatternAdmin) - admin_site.register(FederatedIendityProvider, FederatedIendityProviderAdmin) diff --git a/note_kfet/fixtures/cas.json b/note_kfet/fixtures/cas.json deleted file mode 100644 index c3109d19..00000000 --- a/note_kfet/fixtures/cas.json +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "model": "cas_server.servicepattern", - "pk": 1, - "fields": { - "pos": 1, - "pattern": ".*", - "name": "REPLACEME" - } - } -] diff --git a/note_kfet/settings/__init__.py b/note_kfet/settings/__init__.py index dcfa88a8..0c76b6f4 100644 --- a/note_kfet/settings/__init__.py +++ b/note_kfet/settings/__init__.py @@ -49,13 +49,6 @@ try: except ImportError: pass -if "cas_server" in INSTALLED_APPS: - # CAS Settings - CAS_AUTO_CREATE_USER = False - CAS_LOGO_URL = "/static/img/Saperlistpopette.png" - CAS_FAVICON_URL = "/static/favicon/favicon-32x32.png" - CAS_SHOW_POWERED = False - if "logs" in INSTALLED_APPS: MIDDLEWARE += ('note_kfet.middlewares.SessionMiddleware',) diff --git a/note_kfet/settings/secrets_example.py b/note_kfet/settings/secrets_example.py index b1f9e399..656e558b 100644 --- a/note_kfet/settings/secrets_example.py +++ b/note_kfet/settings/secrets_example.py @@ -3,7 +3,6 @@ # CAS OPTIONAL_APPS = [ -# 'cas_server', # 'debug_toolbar' ] diff --git a/note_kfet/templates/cas_server/base.html b/note_kfet/templates/cas_server/base.html deleted file mode 100644 index 4e93cee0..00000000 --- a/note_kfet/templates/cas_server/base.html +++ /dev/null @@ -1,99 +0,0 @@ -{% load i18n %}{% load static %}{% get_current_language as LANGUAGE_CODE %} - - - - - - {% block title %}{% trans "Central Authentication Service" %}{% endblock %} - - - - - {% if settings.CAS_FAVICON_URL %}{% endif %} - - - -
-
- {% if auto_submit %}{% endif %} -
-
-
- {% if auto_submit %}{% endif %} - {% block content %}{% endblock %} -
-
-
-
-
-
- {% if settings.CAS_SHOW_POWERED %} - - {% endif %} - - - - - {% block javascript %}{% endblock %} - - - diff --git a/note_kfet/urls.py b/note_kfet/urls.py index ae6bf3db..74731a62 100644 --- a/note_kfet/urls.py +++ b/note_kfet/urls.py @@ -41,12 +41,6 @@ if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) -if "cas_server" in settings.INSTALLED_APPS: - urlpatterns += [ - # Include CAS Server routers - path('cas/', include('cas_server.urls', namespace="cas_server")), - ] - if "debug_toolbar" in settings.INSTALLED_APPS: import debug_toolbar urlpatterns = [ diff --git a/requirements.txt b/requirements.txt index dccb8988..f7aa0d8a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,13 +1,13 @@ beautifulsoup4~=4.7.1 Django~=2.2.15 django-bootstrap-datepicker-plus~=3.0.5 -django-cas-server>=1.2.0 django-colorfield~=0.3.2 django-crispy-forms~=1.7.2 django-extensions~=2.1.4 django-filter~=2.1.0 django-htcpcp-tea~=0.3.1 django-mailer~=2.0.1 +django-oauth-toolkit~=0.11.0 django-phonenumber-field~=5.0.0 django-polymorphic~=2.0.3 djangorestframework~=3.9.0 From 8052152ea589bbf148b4ce76b03e1273d781f000 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Mon, 21 Sep 2020 11:03:07 +0200 Subject: [PATCH 05/56] Add OAuth2 endpoints --- note.cron | 2 ++ note_kfet/settings/base.py | 1 + note_kfet/urls.py | 3 +++ 3 files changed, 6 insertions(+) diff --git a/note.cron b/note.cron index 078856ea..44db347a 100644 --- a/note.cron +++ b/note.cron @@ -20,3 +20,5 @@ 55 6 * * * root cd /var/www/note_kfet && env/bin/python manage.py send_reports # Mettre à jour les boutons mis en avant 00 9 * * * root cd /var/www/note_kfet && env/bin/python manage.py refresh_highlighted_buttons +# Vider les tokens Oauth2 + 00 6 * * * root cd /var/www/note_kfet && env/bin/python manage.py cleartokens diff --git a/note_kfet/settings/base.py b/note_kfet/settings/base.py index 27010fef..3c2cd4f9 100644 --- a/note_kfet/settings/base.py +++ b/note_kfet/settings/base.py @@ -35,6 +35,7 @@ INSTALLED_APPS = [ 'mailer', 'phonenumber_field', 'polymorphic', + 'oauth2_provider', # Django contrib 'django.contrib.admin', diff --git a/note_kfet/urls.py b/note_kfet/urls.py index 74731a62..6049bfde 100644 --- a/note_kfet/urls.py +++ b/note_kfet/urls.py @@ -32,6 +32,9 @@ urlpatterns = [ path('api/', include('api.urls')), path('permission/', include('permission.urls')), + # OAuth2 provider + path('o/', include('oauth2_provider.urls', namespace='oauth2_provider')), + # Make coffee path('coffee/', include('django_htcpcp_tea.urls')), ] From 6d54aae61488f17ebd9accf5ece835d324bcee57 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Mon, 21 Sep 2020 11:15:00 +0200 Subject: [PATCH 06/56] Fix django-oauth-toolkit version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index f7aa0d8a..33ba454a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ django-extensions~=2.1.4 django-filter~=2.1.0 django-htcpcp-tea~=0.3.1 django-mailer~=2.0.1 -django-oauth-toolkit~=0.11.0 +django-oauth-toolkit~=1.1.2 django-phonenumber-field~=5.0.0 django-polymorphic~=2.0.3 djangorestframework~=3.9.0 From 72bac75fbdae836005b3652868d2c91231f3e9c3 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Mon, 21 Sep 2020 12:15:40 +0200 Subject: [PATCH 07/56] Add Django OAuth toolkit admin --- note_kfet/admin.py | 8 ++++++++ note_kfet/settings/base.py | 4 +++- note_kfet/urls.py | 8 +++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/note_kfet/admin.py b/note_kfet/admin.py index 1fa228fe..fa192b57 100644 --- a/note_kfet/admin.py +++ b/note_kfet/admin.py @@ -26,6 +26,14 @@ admin_site = StrongAdminSite() admin_site.register(Site, SiteAdmin) # Add external apps model +if "oauth2_provider" in settings.INSTALLED_APPS: + from oauth2_provider.admin import Application, ApplicationAdmin, Grant, \ + GrantAdmin, AccessToken, AccessTokenAdmin, RefreshToken, RefreshTokenAdmin + admin_site.register(Application, ApplicationAdmin) + admin_site.register(Grant, GrantAdmin) + admin_site.register(AccessToken, AccessTokenAdmin) + admin_site.register(RefreshToken, RefreshTokenAdmin) + if "django_htcpcp_tea" in settings.INSTALLED_APPS: from django_htcpcp_tea.admin import * from django_htcpcp_tea.models import * diff --git a/note_kfet/settings/base.py b/note_kfet/settings/base.py index 3c2cd4f9..f393cab1 100644 --- a/note_kfet/settings/base.py +++ b/note_kfet/settings/base.py @@ -38,7 +38,9 @@ INSTALLED_APPS = [ 'oauth2_provider', # Django contrib - 'django.contrib.admin', + # We do not import Django Admin directly to disable autodiscover. + # Autodiscover does not work with custom admin sites. + 'django.contrib.admin.apps.SimpleAdminConfig', 'django.contrib.admindocs', 'django.contrib.auth', 'django.contrib.contenttypes', diff --git a/note_kfet/urls.py b/note_kfet/urls.py index 6049bfde..d9e51b63 100644 --- a/note_kfet/urls.py +++ b/note_kfet/urls.py @@ -32,9 +32,6 @@ urlpatterns = [ path('api/', include('api.urls')), path('permission/', include('permission.urls')), - # OAuth2 provider - path('o/', include('oauth2_provider.urls', namespace='oauth2_provider')), - # Make coffee path('coffee/', include('django_htcpcp_tea.urls')), ] @@ -43,6 +40,11 @@ urlpatterns = [ if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) +if "oauth2_provider" in settings.INSTALLED_APPS: + # OAuth2 provider + urlpatterns.append( + path('o/', include('oauth2_provider.urls', namespace='oauth2_provider')) + ) if "debug_toolbar" in settings.INSTALLED_APPS: import debug_toolbar From 4f188ca3e5161236d1d3452d4e551465a0f3f935 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Mon, 21 Sep 2020 12:34:34 +0200 Subject: [PATCH 08/56] Admin is autodiscovering partially --- note_kfet/settings/base.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/note_kfet/settings/base.py b/note_kfet/settings/base.py index f393cab1..ac9dd050 100644 --- a/note_kfet/settings/base.py +++ b/note_kfet/settings/base.py @@ -38,9 +38,8 @@ INSTALLED_APPS = [ 'oauth2_provider', # Django contrib - # We do not import Django Admin directly to disable autodiscover. - # Autodiscover does not work with custom admin sites. - 'django.contrib.admin.apps.SimpleAdminConfig', + # Django Admin will autodiscover our apps for our custom admin site. + 'django.contrib.admin', 'django.contrib.admindocs', 'django.contrib.auth', 'django.contrib.contenttypes', From 3d733ed6af9b208ce14451f9516dc632ad720a54 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Mon, 21 Sep 2020 15:13:43 +0200 Subject: [PATCH 09/56] Use memcached cache --- .gitlab-ci.yml | 4 ++-- Dockerfile | 2 +- README.md | 4 ++-- ansible/roles/1-apt-basic/tasks/main.yml | 4 ++++ note_kfet/settings/base.py | 10 ++++++++++ note_kfet/settings/development.py | 8 ++++++++ requirements.txt | 1 + 7 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 61d5988c..2181b4b5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ py37-django22: python3-django python3-django-crispy-forms python3-django-extensions python3-django-filters python3-django-polymorphic python3-djangorestframework python3-django-oauth-toolkit python3-psycopg2 python3-pil - python3-babel python3-lockfile python3-pip python3-phonenumbers + python3-babel python3-lockfile python3-pip python3-phonenumbers python3-memcache python3-bs4 python3-setuptools tox texlive-xetex script: tox -e py37-django22 @@ -34,7 +34,7 @@ py38-django22: python3-django python3-django-crispy-forms python3-django-extensions python3-django-filters python3-django-polymorphic python3-djangorestframework python3-django-oauth-toolkit python3-psycopg2 python3-pil - python3-babel python3-lockfile python3-pip python3-phonenumbers + python3-babel python3-lockfile python3-pip python3-phonenumbers python3-memcache python3-bs4 python3-setuptools tox texlive-xetex script: tox -e py38-django22 diff --git a/Dockerfile b/Dockerfile index 9696de7c..95a62437 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ RUN apt-get update && \ python3-django python3-django-crispy-forms \ python3-django-extensions python3-django-filters python3-django-polymorphic \ python3-djangorestframework python3-django-oauth-toolkit python3-psycopg2 python3-pil \ - python3-babel python3-lockfile python3-pip python3-phonenumbers ipython3 \ + python3-babel python3-lockfile python3-pip python3-phonenumbers python3-memcache ipython3 \ python3-bs4 python3-setuptools \ uwsgi uwsgi-plugin-python3 \ texlive-xetex gettext libjs-bootstrap4 fonts-font-awesome && \ diff --git a/README.md b/README.md index 910fd19a..77166649 100644 --- a/README.md +++ b/README.md @@ -94,9 +94,9 @@ Sinon vous pouvez suivre les étapes décrites ci-dessous. python3-django python3-django-crispy-forms \ python3-django-extensions python3-django-filters python3-django-polymorphic \ python3-djangorestframework python3-django-oauth-toolkit python3-psycopg2 python3-pil \ - python3-babel python3-lockfile python3-pip python3-phonenumbers ipython3 \ + python3-babel python3-lockfile python3-pip python3-phonenumbers python3-memcache ipython3 \ python3-bs4 python3-setuptools \ - uwsgi uwsgi-plugin-python3 \ + memcached uwsgi uwsgi-plugin-python3 \ texlive-xetex gettext libjs-bootstrap4 fonts-font-awesome \ nginx python3-venv git acl ``` diff --git a/ansible/roles/1-apt-basic/tasks/main.yml b/ansible/roles/1-apt-basic/tasks/main.yml index 95f6d40a..9c01dd97 100644 --- a/ansible/roles/1-apt-basic/tasks/main.yml +++ b/ansible/roles/1-apt-basic/tasks/main.yml @@ -30,6 +30,7 @@ - python3-django-polymorphic - python3-djangorestframework - python3-lockfile + - python3-memcache - python3-phonenumbers - python3-pil - python3-pip @@ -40,6 +41,9 @@ # LaTeX (PDF generation) - texlive-xetex + # Cache server + - memcached + # WSGI server - uwsgi - uwsgi-plugin-python3 diff --git a/note_kfet/settings/base.py b/note_kfet/settings/base.py index ac9dd050..f319b2db 100644 --- a/note_kfet/settings/base.py +++ b/note_kfet/settings/base.py @@ -216,6 +216,16 @@ EMAIL_HOST_PASSWORD = os.getenv('EMAIL_PASSWORD', None) SERVER_EMAIL = os.getenv("NOTE_MAIL", "notekfet@example.com") DEFAULT_FROM_EMAIL = "NoteKfet2020 <" + SERVER_EMAIL + ">" +# Cache +# https://docs.djangoproject.com/en/2.2/topics/cache/#setting-up-the-cache +cache_address = os.getenv("CACHE_ADDRESS", "127.0.0.1:11211") +CACHES = { + 'default': { + 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', + 'LOCATION': cache_address, + } +} + # Django REST Framework REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': [ diff --git a/note_kfet/settings/development.py b/note_kfet/settings/development.py index 282ee478..e4fc8826 100644 --- a/note_kfet/settings/development.py +++ b/note_kfet/settings/development.py @@ -24,6 +24,14 @@ if os.getenv("DJANGO_DEV_STORE_METHOD", "sqlite") != "postgresql": } } +# Dummy cache for development +# https://docs.djangoproject.com/en/2.2/topics/cache/#setting-up-the-cache +CACHES = { + 'default': { + 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', + } +} + # Break it, fix it! DEBUG = True diff --git a/requirements.txt b/requirements.txt index 33ba454a..bf0917cc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,5 +13,6 @@ django-polymorphic~=2.0.3 djangorestframework~=3.9.0 django-rest-polymorphic~=0.1.9 django-tables2~=2.3.1 +python-memcache~=1.59 phonenumbers~=8.9.10 Pillow>=5.4.1 From 74b26335d13e7685562135478d50347f19df32b0 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Mon, 21 Sep 2020 15:13:59 +0200 Subject: [PATCH 10/56] Cache ICS calendar --- apps/activity/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/activity/views.py b/apps/activity/views.py index 2f5c7e0b..4a152e07 100644 --- a/apps/activity/views.py +++ b/apps/activity/views.py @@ -12,8 +12,10 @@ from django.db.models import F, Q from django.http import HttpResponse from django.urls import reverse_lazy from django.utils import timezone +from django.utils.decorators import method_decorator from django.utils.translation import gettext_lazy as _ from django.views import View +from django.views.decorators.cache import cache_page from django.views.generic import DetailView, TemplateView, UpdateView from django_tables2.views import SingleTableView from note.models import Alias, NoteSpecial, NoteUser @@ -288,6 +290,8 @@ class ActivityEntryView(LoginRequiredMixin, TemplateView): return context +# Cache for 1 hour +@method_decorator(cache_page(60 * 60), name='dispatch') class CalendarView(View): """ Render an ICS calendar with all valid activities. From 439bf35b628fc6a8a9b29c0ffd453f7969f96057 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Mon, 21 Sep 2020 15:25:07 +0200 Subject: [PATCH 11/56] APT python memcache is PyPi memcached --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index bf0917cc..46ef2f63 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,6 +13,6 @@ django-polymorphic~=2.0.3 djangorestframework~=3.9.0 django-rest-polymorphic~=0.1.9 django-tables2~=2.3.1 -python-memcache~=1.59 +python-memcached~=1.59 phonenumbers~=8.9.10 Pillow>=5.4.1 From e48ef92137796bd5cb895c2c0c5724789e7d04df Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 23 Sep 2020 18:32:09 +0200 Subject: [PATCH 12/56] Revert commit that broke beta branch --- apps/note/static/note/js/consos.js | 2 +- apps/note/templates/note/conso_form.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/note/static/note/js/consos.js b/apps/note/static/note/js/consos.js index 691ddd6f..78909600 100644 --- a/apps/note/static/note/js/consos.js +++ b/apps/note/static/note/js/consos.js @@ -253,7 +253,7 @@ function consume (source, source_alias, dest, quantity, amount, reason, type, ca template: template }).done(function () { reset() - addMsg(gettext("La transaction n'a pas pu être validée pour cause de solde insuffisant."), 'danger', 10000) + addMsg("La transaction n'a pas pu être validée pour cause de solde insuffisant.", 'danger', 10000) }).fail(function () { reset() errMsg(e.responseJSON) diff --git a/apps/note/templates/note/conso_form.html b/apps/note/templates/note/conso_form.html index c8372e76..d6044b87 100644 --- a/apps/note/templates/note/conso_form.html +++ b/apps/note/templates/note/conso_form.html @@ -159,7 +159,7 @@ SPDX-License-Identifier: GPL-3.0-or-later {% endblock %} {% block extrajavascript %} - +