mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-25 18:44:23 +00:00
Merge branch 'django-3.2' into 'master'
Upgrade to django 3.2 * Upgrade dependencies * Fix ugettext * Fix bad urls See merge request ae-utbm/Sith!316
This commit is contained in:
commit
0c2494cb34
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,7 +5,6 @@ db.sqlite3
|
||||
*__pycache__*
|
||||
.DS_Store
|
||||
pyrightconfig.json
|
||||
poetry.lock
|
||||
dist/
|
||||
.vscode/
|
||||
env/
|
||||
|
@ -27,7 +27,7 @@ from django.core.exceptions import ValidationError
|
||||
from django.core import validators
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.template import defaultfilters
|
||||
|
||||
from phonenumber_field.modelfields import PhoneNumberField
|
||||
|
@ -25,7 +25,7 @@
|
||||
from django.views.generic import ListView, DetailView
|
||||
from django.views.generic.edit import UpdateView, CreateView, DeleteView, FormView
|
||||
from django.urls import reverse_lazy, reverse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.forms.models import modelform_factory
|
||||
from django.core.exceptions import PermissionDenied, ValidationError
|
||||
from django.forms import HiddenInput
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
from django.conf import settings
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from ajax_select.fields import AutoCompleteSelectField, AutoCompleteSelectMultipleField
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
from django.db import models
|
||||
from django.core import validators
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.core.exceptions import ValidationError, ObjectDoesNotExist
|
||||
from django.db import transaction
|
||||
from django.urls import reverse
|
||||
|
@ -45,7 +45,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for widget in form_mailing_removal.subwidgets %}
|
||||
{% set user = ms[widget.data.value][0] %}
|
||||
{% set user = ms[widget.data.value.value][0] %}
|
||||
<tr>
|
||||
<td>{{ user.get_username }}</td>
|
||||
<td>{{ user.get_email }}</td>
|
||||
|
@ -25,7 +25,7 @@
|
||||
from django.conf import settings
|
||||
from django.test import TestCase
|
||||
from django.utils import timezone, html
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import gettext as _
|
||||
from django.urls import reverse
|
||||
from django.core.management import call_command
|
||||
from django.core.exceptions import ValidationError, NON_FIELD_ERRORS
|
||||
@ -180,7 +180,7 @@ class ClubTest(TestCase):
|
||||
)
|
||||
self.assertTrue(response.status_code == 200)
|
||||
self.assertTrue(
|
||||
"<li>Vous n'avez pas la permission de faire cela</li>"
|
||||
"<li>Vous n'avez pas la permission de faire cela</li>"
|
||||
in str(response.content)
|
||||
)
|
||||
|
||||
|
@ -39,8 +39,8 @@ from django.http import (
|
||||
)
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext as _t
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import gettext as _t
|
||||
from django.core.exceptions import PermissionDenied, ValidationError, NON_FIELD_ERRORS
|
||||
from django.core.paginator import Paginator, InvalidPage
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
|
@ -26,11 +26,11 @@
|
||||
from django.shortcuts import render
|
||||
from django.db import models, transaction
|
||||
from django.db.models import Q
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils import timezone
|
||||
from django.urls import reverse
|
||||
from django.conf import settings
|
||||
from django.contrib.staticfiles.templatetags.staticfiles import static
|
||||
from django.templatetags.static import static
|
||||
from django.core.mail import EmailMultiAlternatives
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
|
10
com/tests.py
10
com/tests.py
@ -27,7 +27,7 @@ from django.conf import settings
|
||||
from django.urls import reverse
|
||||
from django.core.management import call_command
|
||||
from django.utils import html
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
|
||||
from core.models import User, RealGroup
|
||||
@ -40,8 +40,8 @@ class ComAlertTest(TestCase):
|
||||
def test_page_is_working(self):
|
||||
self.client.login(username="comunity", password="plop")
|
||||
response = self.client.get(reverse("com:alert_edit"))
|
||||
self.assertNotEquals(response.status_code, 500)
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assertNotEqual(response.status_code, 500)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
class ComInfoTest(TestCase):
|
||||
@ -51,8 +51,8 @@ class ComInfoTest(TestCase):
|
||||
def test_page_is_working(self):
|
||||
self.client.login(username="comunity", password="plop")
|
||||
response = self.client.get(reverse("com:info_edit"))
|
||||
self.assertNotEquals(response.status_code, 500)
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assertNotEqual(response.status_code, 500)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
class ComTest(TestCase):
|
||||
|
@ -28,7 +28,7 @@ from django.http import HttpResponseRedirect
|
||||
from django.views.generic import ListView, DetailView, View
|
||||
from django.views.generic.edit import UpdateView, CreateView, DeleteView
|
||||
from django.views.generic.detail import SingleObjectMixin
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils import timezone
|
||||
|
@ -21,5 +21,3 @@
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
#
|
||||
|
||||
default_app_config = "core.apps.SithConfig"
|
||||
|
@ -34,7 +34,7 @@ from django.contrib.auth.models import (
|
||||
GroupManager as AuthGroupManager,
|
||||
AnonymousUser as AuthAnonymousUser,
|
||||
)
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils import timezone
|
||||
from django.core import validators
|
||||
from django.core.exceptions import ValidationError, PermissionDenied
|
||||
|
@ -25,9 +25,9 @@
|
||||
|
||||
import os
|
||||
import sass
|
||||
from urllib.parse import urljoin
|
||||
from django.utils.encoding import force_bytes, iri_to_uri
|
||||
from django.core.files.base import ContentFile
|
||||
from django.utils.six.moves.urllib.parse import urljoin
|
||||
from django.templatetags.static import static
|
||||
from django.conf import settings
|
||||
from core.scss.storage import ScssFileStorage, find_file
|
||||
|
@ -402,32 +402,32 @@ class UserToolsTest(TestCase):
|
||||
|
||||
def test_anonymous_user_unauthorized(self):
|
||||
response = self.client.get(reverse("core:user_tools"))
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
def test_page_is_working(self):
|
||||
# Test for simple user
|
||||
self.client.login(username="guy", password="plop")
|
||||
response = self.client.get(reverse("core:user_tools"))
|
||||
self.assertNotEquals(response.status_code, 500)
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assertNotEqual(response.status_code, 500)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test for root
|
||||
self.client.login(username="root", password="plop")
|
||||
response = self.client.get(reverse("core:user_tools"))
|
||||
self.assertNotEquals(response.status_code, 500)
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assertNotEqual(response.status_code, 500)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test for skia
|
||||
self.client.login(username="skia", password="plop")
|
||||
response = self.client.get(reverse("core:user_tools"))
|
||||
self.assertNotEquals(response.status_code, 500)
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assertNotEqual(response.status_code, 500)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test for comunity
|
||||
self.client.login(username="comunity", password="plop")
|
||||
response = self.client.get(reverse("core:user_tools"))
|
||||
self.assertNotEquals(response.status_code, 500)
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assertNotEqual(response.status_code, 500)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
# TODO: many tests on the pages:
|
||||
|
@ -23,7 +23,7 @@
|
||||
#
|
||||
#
|
||||
|
||||
from django.urls import re_path
|
||||
from django.urls import re_path, path
|
||||
|
||||
from core.views import *
|
||||
|
||||
@ -60,8 +60,8 @@ urlpatterns = [
|
||||
SithPasswordResetDoneView.as_view(),
|
||||
name="password_reset_done",
|
||||
),
|
||||
re_path(
|
||||
r"^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$",
|
||||
path(
|
||||
r"reset/<str:uidb64>/<str:token>/",
|
||||
SithPasswordResetConfirmView.as_view(),
|
||||
name="password_reset_confirm",
|
||||
),
|
||||
|
@ -29,7 +29,7 @@ from django.views.generic.edit import UpdateView, FormMixin, DeleteView
|
||||
from django.views.generic.detail import SingleObjectMixin
|
||||
from django.forms.models import modelform_factory
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.http import HttpResponse
|
||||
from wsgiref.util import FileWrapper
|
||||
from django.urls import reverse
|
||||
@ -147,7 +147,7 @@ class FileListView(ListView):
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super(FileListView, self).get_context_data(**kwargs)
|
||||
kwargs["popup"] = ""
|
||||
if self.kwargs["popup"]:
|
||||
if self.kwargs.get("popup") is not None:
|
||||
kwargs["popup"] = "popup"
|
||||
return kwargs
|
||||
|
||||
@ -165,7 +165,7 @@ class FileEditView(CanEditMixin, UpdateView):
|
||||
return modelform_factory(SithFile, fields=fields)
|
||||
|
||||
def get_success_url(self):
|
||||
if self.kwargs["popup"]:
|
||||
if self.kwargs.get("popup") is not None:
|
||||
return reverse(
|
||||
"core:file_detail", kwargs={"file_id": self.object.id, "popup": "popup"}
|
||||
)
|
||||
@ -176,7 +176,7 @@ class FileEditView(CanEditMixin, UpdateView):
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super(FileEditView, self).get_context_data(**kwargs)
|
||||
kwargs["popup"] = ""
|
||||
if self.kwargs["popup"]:
|
||||
if self.kwargs.get("popup") is not None:
|
||||
kwargs["popup"] = "popup"
|
||||
return kwargs
|
||||
|
||||
@ -217,13 +217,13 @@ class FileEditPropView(CanEditPropMixin, UpdateView):
|
||||
def get_success_url(self):
|
||||
return reverse(
|
||||
"core:file_detail",
|
||||
kwargs={"file_id": self.object.id, "popup": self.kwargs["popup"] or ""},
|
||||
kwargs={"file_id": self.object.id, "popup": self.kwargs.get("popup", "")},
|
||||
)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super(FileEditPropView, self).get_context_data(**kwargs)
|
||||
kwargs["popup"] = ""
|
||||
if self.kwargs["popup"]:
|
||||
if self.kwargs.get("popup") is not None:
|
||||
kwargs["popup"] = "popup"
|
||||
return kwargs
|
||||
|
||||
@ -301,14 +301,14 @@ class FileView(CanViewMixin, DetailView, FormMixin):
|
||||
def get_success_url(self):
|
||||
return reverse(
|
||||
"core:file_detail",
|
||||
kwargs={"file_id": self.object.id, "popup": self.kwargs["popup"] or ""},
|
||||
kwargs={"file_id": self.object.id, "popup": self.kwargs.get("popup", "")},
|
||||
)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super(FileView, self).get_context_data(**kwargs)
|
||||
kwargs["popup"] = ""
|
||||
kwargs["form"] = self.form
|
||||
if self.kwargs["popup"]:
|
||||
if self.kwargs.get("popup") is not None:
|
||||
kwargs["popup"] = "popup"
|
||||
kwargs["clipboard"] = SithFile.objects.filter(
|
||||
id__in=self.request.session["clipboard"]
|
||||
@ -328,20 +328,20 @@ class FileDeleteView(CanEditPropMixin, DeleteView):
|
||||
return self.request.GET["next"]
|
||||
if self.object.parent is None:
|
||||
return reverse(
|
||||
"core:file_list", kwargs={"popup": self.kwargs["popup"] or ""}
|
||||
"core:file_list", kwargs={"popup": self.kwargs.get("popup", "")}
|
||||
)
|
||||
return reverse(
|
||||
"core:file_detail",
|
||||
kwargs={
|
||||
"file_id": self.object.parent.id,
|
||||
"popup": self.kwargs["popup"] or "",
|
||||
"popup": self.kwargs.get("popup", ""),
|
||||
},
|
||||
)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super(FileDeleteView, self).get_context_data(**kwargs)
|
||||
kwargs["popup"] = ""
|
||||
if self.kwargs["popup"]:
|
||||
if self.kwargs.get("popup") is not None:
|
||||
kwargs["popup"] = "popup"
|
||||
return kwargs
|
||||
|
||||
|
@ -37,8 +37,8 @@ from django.forms import (
|
||||
DateTimeInput,
|
||||
Textarea,
|
||||
)
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import gettext
|
||||
from phonenumber_field.widgets import PhoneNumberInternationalFallbackWidget
|
||||
from ajax_select.fields import AutoCompleteSelectField
|
||||
from ajax_select import make_ajax_field
|
||||
@ -130,7 +130,7 @@ class SelectFile(TextInput):
|
||||
'<span name="'
|
||||
+ name
|
||||
+ '" class="choose_file_button">'
|
||||
+ ugettext("Choose file")
|
||||
+ gettext("Choose file")
|
||||
+ "</span>"
|
||||
)
|
||||
return output
|
||||
@ -154,7 +154,7 @@ class SelectUser(TextInput):
|
||||
'<span name="'
|
||||
+ name
|
||||
+ '" class="choose_user_button">'
|
||||
+ ugettext("Choose user")
|
||||
+ gettext("Choose user")
|
||||
+ "</span>"
|
||||
)
|
||||
return output
|
||||
|
@ -31,7 +31,7 @@ from django.views.generic import ListView
|
||||
from django.views.generic.edit import FormView
|
||||
from django.urls import reverse_lazy
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django import forms
|
||||
|
||||
from ajax_select.fields import AutoCompleteSelectMultipleField
|
||||
|
@ -27,7 +27,7 @@
|
||||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.contrib.auth import views
|
||||
from django.contrib.auth.forms import PasswordChangeForm
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import gettext as _
|
||||
from django.urls import reverse
|
||||
from django.core.exceptions import PermissionDenied, ValidationError
|
||||
from django.http import Http404, HttpResponse
|
||||
|
@ -22,5 +22,3 @@
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
#
|
||||
|
||||
default_app_config = "counter.app.CounterConfig"
|
||||
|
@ -23,7 +23,7 @@
|
||||
#
|
||||
|
||||
from django.apps import AppConfig
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class CounterConfig(AppConfig):
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.db import migrations, models
|
||||
from django.conf import settings
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
from sith.settings import SITH_COUNTER_OFFICES, SITH_MAIN_CLUB
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils import timezone
|
||||
from django.conf import settings
|
||||
from django.urls import reverse
|
||||
|
@ -110,6 +110,7 @@ class CounterTest(TestCase):
|
||||
"bank": "OTHER",
|
||||
},
|
||||
)
|
||||
self.assertTrue(response.status_code == 200)
|
||||
|
||||
response = self.client.post(
|
||||
reverse("counter:login", kwargs={"counter_id": self.foyer.id}),
|
||||
@ -139,7 +140,7 @@ class CounterTest(TestCase):
|
||||
"bank": "OTHER",
|
||||
},
|
||||
)
|
||||
self.assertTrue(response.status_code == 403)
|
||||
self.assertTrue(response.status_code == 200)
|
||||
|
||||
|
||||
class CounterStatsTest(TestCase):
|
||||
|
@ -41,7 +41,7 @@ from django.urls import reverse_lazy, reverse
|
||||
from django.http import HttpResponseRedirect, HttpResponse, JsonResponse
|
||||
from django.utils import timezone
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.conf import settings
|
||||
from django.db import DataError, transaction, models
|
||||
|
||||
|
@ -12,7 +12,7 @@ Pour modifier les cotisations disponnibles, tout se gère dans la configuration
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
SITH_SUBSCRIPTIONS = {
|
||||
# Voici un échantillon de la véritable configuration à l'heure de l'écriture.
|
||||
|
@ -20,7 +20,7 @@ Nous allons présenter ici les deux techniques. Dans un premier temps nous allon
|
||||
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from core.views import *
|
||||
from core.models import User, Group
|
||||
@ -63,7 +63,7 @@ Voici maintenant comment faire en définissant des fonctions personnalisées. Ce
|
||||
.. code-block:: python
|
||||
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from core.views import *
|
||||
from core.models import User, Group
|
||||
|
@ -14,7 +14,7 @@ Si le mot est dans le code Python :
|
||||
|
||||
.. sourcecode:: python
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
# ...
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
#
|
||||
|
||||
from django.db import models, DataError
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.functional import cached_property
|
||||
from django.conf import settings
|
||||
|
||||
|
@ -59,7 +59,7 @@ class EbouticTest(TestCase):
|
||||
with open("./eboutic/tests/public_key.pem") as f:
|
||||
settings.SITH_EBOUTIC_PUB_KEY = f.read()
|
||||
privkey = crypto.load_privatekey(crypto.FILETYPE_PEM, PRIVKEY)
|
||||
sig = crypto.sign(privkey, query, "sha1")
|
||||
sig = crypto.sign(privkey, query.encode("utf-8"), "sha1")
|
||||
b64sig = base64.b64encode(sig).decode("ascii")
|
||||
|
||||
url = reverse("eboutic:etransation_autoanswer") + "?%s&Sig=%s" % (
|
||||
|
@ -14,11 +14,11 @@ with open("./private_key.pem") as f:
|
||||
with open("./public_key.pem") as f:
|
||||
PUBKEY = f.read()
|
||||
|
||||
string = "Amount=400&BasketID=4000&Auto=42&Error=00000\n"
|
||||
data = "Amount=400&BasketID=4000&Auto=42&Error=00000\n".encode("utf-8")
|
||||
|
||||
# Sign
|
||||
prvkey = crypto.load_privatekey(crypto.FILETYPE_PEM, PRVKEY)
|
||||
sig = crypto.sign(prvkey, string, "sha1")
|
||||
sig = crypto.sign(prvkey, data, "sha1")
|
||||
b64sig = base64.b64encode(sig)
|
||||
print(b64sig)
|
||||
|
||||
@ -28,7 +28,7 @@ cert = crypto.X509()
|
||||
cert.set_pubkey(pubkey)
|
||||
sig = base64.b64decode(b64sig)
|
||||
try:
|
||||
crypto.verify(cert, sig, string, "sha1")
|
||||
crypto.verify(cert, sig, data, "sha1")
|
||||
print("Verify OK")
|
||||
except:
|
||||
print("Verify failed")
|
||||
|
@ -33,7 +33,7 @@ from django.views.generic import TemplateView, View
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.core.exceptions import SuspiciousOperation
|
||||
from django.db import transaction, DataError
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import gettext as _
|
||||
from django.conf import settings
|
||||
|
||||
from counter.models import Customer, Counter, ProductType, Selling
|
||||
@ -264,7 +264,7 @@ class EtransactionAutoAnswer(View):
|
||||
crypto.verify(
|
||||
cert,
|
||||
sig,
|
||||
"&".join(request.META["QUERY_STRING"].split("&")[:-1]),
|
||||
"&".join(request.META["QUERY_STRING"].split("&")[:-1]).encode("utf-8"),
|
||||
"sha1",
|
||||
)
|
||||
except:
|
||||
|
@ -1,6 +1,6 @@
|
||||
from django.db import models
|
||||
from ordered_model.models import OrderedModel
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils import timezone
|
||||
|
||||
from core.models import User, Group
|
||||
|
@ -3,7 +3,7 @@ from django.views.generic import ListView, DetailView
|
||||
from django.views.generic.edit import UpdateView, CreateView
|
||||
from django.views.generic.edit import DeleteView, FormView
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.db import transaction
|
||||
from django.forms import CheckboxSelectMultiple
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
|
@ -27,7 +27,7 @@ from django.shortcuts import get_object_or_404
|
||||
from django.views.generic import ListView, DetailView, RedirectView
|
||||
from django.views.generic.edit import UpdateView, CreateView, DeleteView
|
||||
from django.views.generic.detail import SingleObjectMixin
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils import timezone, html
|
||||
from django.conf import settings
|
||||
|
@ -23,7 +23,7 @@
|
||||
#
|
||||
|
||||
from django.db import models, DataError
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.conf import settings
|
||||
from django.urls import reverse
|
||||
|
||||
|
@ -28,7 +28,7 @@ import pytz
|
||||
|
||||
from django.views.generic import ListView, DetailView, TemplateView
|
||||
from django.views.generic.edit import UpdateView, CreateView, DeleteView, BaseFormView
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils import dateparse, timezone
|
||||
from django.urls import reverse_lazy
|
||||
from django.conf import settings
|
||||
|
@ -26,7 +26,7 @@ from enum import Enum
|
||||
|
||||
from django.views.generic import ListView, View
|
||||
from django.views.generic.edit import FormView
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic.detail import SingleObjectMixin
|
||||
from django.http.response import HttpResponseRedirect
|
||||
from django.urls import reverse
|
||||
|
@ -23,7 +23,7 @@
|
||||
#
|
||||
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.forms.widgets import Widget
|
||||
from django.templatetags.static import static
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
#
|
||||
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils import timezone
|
||||
from django.core import validators
|
||||
from django.conf import settings
|
||||
|
@ -18,7 +18,7 @@
|
||||
<tbody>
|
||||
{% set queryset = form.accepted_reports.field.queryset %}
|
||||
{% for widget in form.accepted_reports.subwidgets %}
|
||||
{% set report = queryset.get(id=widget.data.value) %}
|
||||
{% set report = queryset.get(id=widget.data.value.value) %}
|
||||
<form action="{{ url('pedagogy:moderation') }}" method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
<tr>
|
||||
|
@ -25,7 +25,7 @@
|
||||
from django.conf import settings
|
||||
from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.core.management import call_command
|
||||
|
||||
from core.models import User, Notification
|
||||
@ -95,7 +95,7 @@ class UVCreation(TestCase):
|
||||
response = self.client.post(
|
||||
reverse("pedagogy:uv_create"), create_uv_template(self.bibou.id)
|
||||
)
|
||||
self.assertEquals(response.status_code, 302)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertTrue(UV.objects.filter(code="IFC1").exists())
|
||||
|
||||
def test_create_uv_pedagogy_admin_success(self):
|
||||
@ -103,7 +103,7 @@ class UVCreation(TestCase):
|
||||
response = self.client.post(
|
||||
reverse("pedagogy:uv_create"), create_uv_template(self.tutu.id)
|
||||
)
|
||||
self.assertEquals(response.status_code, 302)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertTrue(UV.objects.filter(code="IFC1").exists())
|
||||
|
||||
def test_create_uv_unauthorized_fail(self):
|
||||
@ -111,21 +111,21 @@ class UVCreation(TestCase):
|
||||
response = self.client.post(
|
||||
reverse("pedagogy:uv_create"), create_uv_template(0)
|
||||
)
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
# Test with subscribed user
|
||||
self.client.login(username="sli", password="plop")
|
||||
response = self.client.post(
|
||||
reverse("pedagogy:uv_create"), create_uv_template(self.sli.id)
|
||||
)
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
# Test with non subscribed user
|
||||
self.client.login(username="guy", password="plop")
|
||||
response = self.client.post(
|
||||
reverse("pedagogy:uv_create"), create_uv_template(self.guy.id)
|
||||
)
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
# Check that the UV has never been created
|
||||
self.assertFalse(UV.objects.filter(code="IFC1").exists())
|
||||
@ -137,16 +137,16 @@ class UVCreation(TestCase):
|
||||
response = self.client.post(
|
||||
reverse("pedagogy:uv_create"), create_uv_template(self.bibou.id)
|
||||
)
|
||||
self.assertNotEquals(response.status_code, 302)
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assertNotEqual(response.status_code, 302)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Remove a required field
|
||||
response = self.client.post(
|
||||
reverse("pedagogy:uv_create"),
|
||||
create_uv_template(self.tutu.id, exclude_list=["title"]),
|
||||
)
|
||||
self.assertNotEquals(response.status_code, 302)
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assertNotEqual(response.status_code, 302)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Check that the UV hase never been created
|
||||
self.assertFalse(UV.objects.filter(code="IFC1").exists())
|
||||
@ -179,12 +179,12 @@ class UVListTest(TestCase):
|
||||
def test_uv_list_display_fail(self):
|
||||
# Don't display for anonymous user
|
||||
response = self.client.get(reverse("pedagogy:guide"))
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
# Don't display for none subscribed users
|
||||
self.client.login(username="guy", password="plop")
|
||||
response = self.client.get(reverse("pedagogy:guide"))
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
|
||||
class UVDeleteTest(TestCase):
|
||||
@ -220,7 +220,7 @@ class UVDeleteTest(TestCase):
|
||||
"pedagogy:uv_delete", kwargs={"uv_id": UV.objects.get(code="PA00").id}
|
||||
)
|
||||
)
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
# Not subscribed user
|
||||
self.client.login(username="guy", password="plop")
|
||||
@ -229,7 +229,7 @@ class UVDeleteTest(TestCase):
|
||||
"pedagogy:uv_delete", kwargs={"uv_id": UV.objects.get(code="PA00").id}
|
||||
)
|
||||
)
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
# Simply subscribed user
|
||||
self.client.login(username="sli", password="plop")
|
||||
@ -238,7 +238,7 @@ class UVDeleteTest(TestCase):
|
||||
"pedagogy:uv_delete", kwargs={"uv_id": UV.objects.get(code="PA00").id}
|
||||
)
|
||||
)
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
# Check that the UV still exists
|
||||
self.assertTrue(UV.objects.filter(code="PA00").exists())
|
||||
@ -262,7 +262,7 @@ class UVUpdateTest(TestCase):
|
||||
create_uv_template(self.bibou.id, code="PA00"),
|
||||
)
|
||||
self.uv.refresh_from_db()
|
||||
self.assertEquals(self.uv.credit_type, "TM")
|
||||
self.assertEqual(self.uv.credit_type, "TM")
|
||||
|
||||
def test_uv_update_pedagogy_admin_success(self):
|
||||
self.client.login(username="tutu", password="plop")
|
||||
@ -271,7 +271,7 @@ class UVUpdateTest(TestCase):
|
||||
create_uv_template(self.bibou.id, code="PA00"),
|
||||
)
|
||||
self.uv.refresh_from_db()
|
||||
self.assertEquals(self.uv.credit_type, "TM")
|
||||
self.assertEqual(self.uv.credit_type, "TM")
|
||||
|
||||
def test_uv_update_original_author_does_not_change(self):
|
||||
self.client.login(username="tutu", password="plop")
|
||||
@ -281,8 +281,8 @@ class UVUpdateTest(TestCase):
|
||||
)
|
||||
|
||||
self.uv.refresh_from_db()
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assertEquals(self.uv.author, self.bibou)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(self.uv.author, self.bibou)
|
||||
|
||||
def test_uv_update_pedagogy_unauthorized_fail(self):
|
||||
# Anonymous user
|
||||
@ -290,7 +290,7 @@ class UVUpdateTest(TestCase):
|
||||
reverse("pedagogy:uv_update", kwargs={"uv_id": self.uv.id}),
|
||||
create_uv_template(self.bibou.id, code="PA00"),
|
||||
)
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
# Not subscribed user
|
||||
self.client.login(username="guy", password="plop")
|
||||
@ -298,7 +298,7 @@ class UVUpdateTest(TestCase):
|
||||
reverse("pedagogy:uv_update", kwargs={"uv_id": self.uv.id}),
|
||||
create_uv_template(self.bibou.id, code="PA00"),
|
||||
)
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
# Simply subscribed user
|
||||
self.client.login(username="sli", password="plop")
|
||||
@ -306,11 +306,11 @@ class UVUpdateTest(TestCase):
|
||||
reverse("pedagogy:uv_update", kwargs={"uv_id": self.uv.id}),
|
||||
create_uv_template(self.bibou.id, code="PA00"),
|
||||
)
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
# Check that the UV has not changed
|
||||
self.uv.refresh_from_db()
|
||||
self.assertEquals(self.uv.credit_type, "OM")
|
||||
self.assertEqual(self.uv.credit_type, "OM")
|
||||
|
||||
|
||||
# UVComment class tests
|
||||
@ -355,7 +355,7 @@ class UVCommentCreationAndDisplay(TestCase):
|
||||
reverse("pedagogy:uv_detail", kwargs={"uv_id": self.uv.id}),
|
||||
create_uv_comment_template(self.bibou.id),
|
||||
)
|
||||
self.assertEquals(response.status_code, 302)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
response = self.client.get(
|
||||
reverse("pedagogy:uv_detail", kwargs={"uv_id": self.uv.id})
|
||||
)
|
||||
@ -367,7 +367,7 @@ class UVCommentCreationAndDisplay(TestCase):
|
||||
reverse("pedagogy:uv_detail", kwargs={"uv_id": self.uv.id}),
|
||||
create_uv_comment_template(self.tutu.id),
|
||||
)
|
||||
self.assertEquals(response.status_code, 302)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
response = self.client.get(
|
||||
reverse("pedagogy:uv_detail", kwargs={"uv_id": self.uv.id})
|
||||
)
|
||||
@ -379,7 +379,7 @@ class UVCommentCreationAndDisplay(TestCase):
|
||||
reverse("pedagogy:uv_detail", kwargs={"uv_id": self.uv.id}),
|
||||
create_uv_comment_template(self.sli.id),
|
||||
)
|
||||
self.assertEquals(response.status_code, 302)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
response = self.client.get(
|
||||
reverse("pedagogy:uv_detail", kwargs={"uv_id": self.uv.id})
|
||||
)
|
||||
@ -391,7 +391,7 @@ class UVCommentCreationAndDisplay(TestCase):
|
||||
reverse("pedagogy:uv_detail", kwargs={"uv_id": self.uv.id}),
|
||||
create_uv_comment_template(0),
|
||||
)
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
# Test with non subscribed user
|
||||
self.client.login(username="guy", password="plop")
|
||||
@ -399,7 +399,7 @@ class UVCommentCreationAndDisplay(TestCase):
|
||||
reverse("pedagogy:uv_detail", kwargs={"uv_id": self.uv.id}),
|
||||
create_uv_comment_template(self.guy.id),
|
||||
)
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
# Check that the comment has never been created
|
||||
self.client.login(username="root", password="plop")
|
||||
@ -415,7 +415,7 @@ class UVCommentCreationAndDisplay(TestCase):
|
||||
create_uv_comment_template(self.bibou.id, exclude_list=["grade_global"]),
|
||||
)
|
||||
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
response = self.client.get(
|
||||
reverse("pedagogy:uv_detail", kwargs={"uv_id": self.uv.id})
|
||||
@ -442,7 +442,7 @@ class UVCommentCreationAndDisplay(TestCase):
|
||||
response = self.client.post(
|
||||
reverse("pedagogy:uv_detail", kwargs={"uv_id": self.uv.id}), comment
|
||||
)
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTrue(
|
||||
UVComment.objects.filter(comment__contains="Superbe UV").exists()
|
||||
)
|
||||
@ -459,12 +459,12 @@ class UVCommentCreationAndDisplay(TestCase):
|
||||
reverse("pedagogy:uv_detail", kwargs={"uv_id": self.uv.id}),
|
||||
create_uv_comment_template(self.bibou.id, exclude_list=["uv"]),
|
||||
)
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.client.post(
|
||||
reverse("pedagogy:uv_detail", kwargs={"uv_id": self.uv.id}),
|
||||
create_uv_comment_template(self.bibou.id, exclude_list=["author"]),
|
||||
)
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
class UVCommentDeleteTest(TestCase):
|
||||
@ -508,21 +508,21 @@ class UVCommentDeleteTest(TestCase):
|
||||
response = self.client.post(
|
||||
reverse("pedagogy:comment_delete", kwargs={"comment_id": self.comment.id})
|
||||
)
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
# Unsbscribed user
|
||||
self.client.login(username="guy", password="plop")
|
||||
response = self.client.post(
|
||||
reverse("pedagogy:comment_delete", kwargs={"comment_id": self.comment.id})
|
||||
)
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
# Subscribed user (not author of the comment)
|
||||
self.client.login(username="sli", password="plop")
|
||||
response = self.client.post(
|
||||
reverse("pedagogy:comment_delete", kwargs={"comment_id": self.comment.id})
|
||||
)
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
# Check that the comment still exists
|
||||
self.assertTrue(UVComment.objects.filter(id=self.comment.id).exists())
|
||||
@ -555,9 +555,9 @@ class UVCommentUpdateTest(TestCase):
|
||||
reverse("pedagogy:comment_update", kwargs={"comment_id": self.comment.id}),
|
||||
self.comment_edit,
|
||||
)
|
||||
self.assertEquals(response.status_code, 302)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.comment.refresh_from_db()
|
||||
self.assertEquals(self.comment.comment, self.comment_edit["comment"])
|
||||
self.assertEqual(self.comment.comment, self.comment_edit["comment"])
|
||||
|
||||
def test_uv_comment_update_pedagogy_admin_success(self):
|
||||
self.client.login(username="tutu", password="plop")
|
||||
@ -565,9 +565,9 @@ class UVCommentUpdateTest(TestCase):
|
||||
reverse("pedagogy:comment_update", kwargs={"comment_id": self.comment.id}),
|
||||
self.comment_edit,
|
||||
)
|
||||
self.assertEquals(response.status_code, 302)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.comment.refresh_from_db()
|
||||
self.assertEquals(self.comment.comment, self.comment_edit["comment"])
|
||||
self.assertEqual(self.comment.comment, self.comment_edit["comment"])
|
||||
|
||||
def test_uv_comment_update_author_success(self):
|
||||
self.client.login(username="krophil", password="plop")
|
||||
@ -575,9 +575,9 @@ class UVCommentUpdateTest(TestCase):
|
||||
reverse("pedagogy:comment_update", kwargs={"comment_id": self.comment.id}),
|
||||
self.comment_edit,
|
||||
)
|
||||
self.assertEquals(response.status_code, 302)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.comment.refresh_from_db()
|
||||
self.assertEquals(self.comment.comment, self.comment_edit["comment"])
|
||||
self.assertEqual(self.comment.comment, self.comment_edit["comment"])
|
||||
|
||||
def test_uv_comment_update_unauthorized_fail(self):
|
||||
# Anonymous user
|
||||
@ -585,25 +585,25 @@ class UVCommentUpdateTest(TestCase):
|
||||
reverse("pedagogy:comment_update", kwargs={"comment_id": self.comment.id}),
|
||||
self.comment_edit,
|
||||
)
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
# Unsbscribed user
|
||||
response = self.client.post(
|
||||
reverse("pedagogy:comment_update", kwargs={"comment_id": self.comment.id}),
|
||||
self.comment_edit,
|
||||
)
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
# Subscribed user (not author of the comment)
|
||||
response = self.client.post(
|
||||
reverse("pedagogy:comment_update", kwargs={"comment_id": self.comment.id}),
|
||||
self.comment_edit,
|
||||
)
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
# Check that the comment hasn't change
|
||||
self.comment.refresh_from_db()
|
||||
self.assertNotEquals(self.comment.comment, self.comment_edit["comment"])
|
||||
self.assertNotEqual(self.comment.comment, self.comment_edit["comment"])
|
||||
|
||||
def test_uv_comment_update_original_author_does_not_change(self):
|
||||
self.client.login(username="root", password="plop")
|
||||
@ -613,8 +613,8 @@ class UVCommentUpdateTest(TestCase):
|
||||
reverse("pedagogy:comment_update", kwargs={"comment_id": self.comment.id}),
|
||||
self.comment_edit,
|
||||
)
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assertEquals(self.comment.author, self.krophil)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(self.comment.author, self.krophil)
|
||||
|
||||
|
||||
class UVSearchTest(TestCase):
|
||||
@ -631,27 +631,27 @@ class UVSearchTest(TestCase):
|
||||
# Test with root user
|
||||
self.client.login(username="root", password="plop")
|
||||
response = self.client.get(reverse("pedagogy:guide"))
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test with pedagogy admin
|
||||
self.client.login(username="tutu", password="plop")
|
||||
response = self.client.get(reverse("pedagogy:guide"))
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test with subscribed user
|
||||
self.client.login(username="sli", password="plop")
|
||||
response = self.client.get(reverse("pedagogy:guide"))
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_get_page_unauthorized_fail(self):
|
||||
# Test with anonymous user
|
||||
response = self.client.get(reverse("pedagogy:guide"))
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
# Test with not subscribed user
|
||||
self.client.login(username="guy", password="plop")
|
||||
response = self.client.get(reverse("pedagogy:guide"))
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
def test_search_pa00_success(self):
|
||||
self.client.login(username="sli", password="plop")
|
||||
@ -833,32 +833,32 @@ class UVModerationFormTest(TestCase):
|
||||
# Test with root
|
||||
self.client.login(username="root", password="plop")
|
||||
response = self.client.get(reverse("pedagogy:moderation"))
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test with pedagogy admin
|
||||
self.client.login(username="tutu", password="plop")
|
||||
response = self.client.get(reverse("pedagogy:moderation"))
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_access_unauthorized_fail(self):
|
||||
# Test with anonymous user
|
||||
response = self.client.get(reverse("pedagogy:moderation"))
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
# Test with unsubscribed user
|
||||
self.client.login(username="guy", password="plop")
|
||||
response = self.client.get(reverse("pedagogy:moderation"))
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
# Test with subscribed user
|
||||
self.client.login(username="sli", password="plop")
|
||||
response = self.client.get(reverse("pedagogy:moderation"))
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
def test_do_nothing(self):
|
||||
self.client.login(username="root", password="plop")
|
||||
response = self.client.post(reverse("pedagogy:moderation"))
|
||||
self.assertEquals(response.status_code, 302)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
# Test that nothing has changed
|
||||
self.assertTrue(UVCommentReport.objects.filter(id=self.report_1.id).exists())
|
||||
@ -874,7 +874,7 @@ class UVModerationFormTest(TestCase):
|
||||
response = self.client.post(
|
||||
reverse("pedagogy:moderation"), {"accepted_reports": [self.report_1.id]}
|
||||
)
|
||||
self.assertEquals(response.status_code, 302)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
# Test that the comment and it's associated report has been deleted
|
||||
self.assertFalse(UVCommentReport.objects.filter(id=self.report_1.id).exists())
|
||||
@ -894,7 +894,7 @@ class UVModerationFormTest(TestCase):
|
||||
reverse("pedagogy:moderation"),
|
||||
{"accepted_reports": [self.report_1.id, self.report_2.id]},
|
||||
)
|
||||
self.assertEquals(response.status_code, 302)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
# Test that comments and their associated reports has been deleted
|
||||
self.assertFalse(UVCommentReport.objects.filter(id=self.report_1.id).exists())
|
||||
@ -913,7 +913,7 @@ class UVModerationFormTest(TestCase):
|
||||
reverse("pedagogy:moderation"),
|
||||
{"accepted_reports": [self.report_1.id, self.report_1_bis.id]},
|
||||
)
|
||||
self.assertEquals(response.status_code, 302)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
# Test that the comment and it's associated report has been deleted
|
||||
self.assertFalse(UVCommentReport.objects.filter(id=self.report_1.id).exists())
|
||||
@ -928,7 +928,7 @@ class UVModerationFormTest(TestCase):
|
||||
response = self.client.post(
|
||||
reverse("pedagogy:moderation"), {"denied_reports": [self.report_1.id]}
|
||||
)
|
||||
self.assertEquals(response.status_code, 302)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
# Test that the report has been deleted and that the comment still exists
|
||||
self.assertFalse(UVCommentReport.objects.filter(id=self.report_1.id).exists())
|
||||
@ -954,7 +954,7 @@ class UVModerationFormTest(TestCase):
|
||||
]
|
||||
},
|
||||
)
|
||||
self.assertEquals(response.status_code, 302)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
# Test that every reports has been deleted
|
||||
self.assertFalse(UVCommentReport.objects.filter(id=self.report_1.id).exists())
|
||||
@ -976,7 +976,7 @@ class UVModerationFormTest(TestCase):
|
||||
"denied_reports": [self.report_1.id],
|
||||
},
|
||||
)
|
||||
self.assertEquals(response.status_code, 302)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
# Test that report 2 and his comment has been deleted
|
||||
self.assertFalse(UVCommentReport.objects.filter(id=self.report_2.id).exists())
|
||||
@ -1000,7 +1000,7 @@ class UVModerationFormTest(TestCase):
|
||||
"denied_reports": [self.report_1_bis.id],
|
||||
},
|
||||
)
|
||||
self.assertEquals(response.status_code, 302)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
# Test that report 1 and 1 bis has been deleted
|
||||
self.assertFalse(
|
||||
@ -1047,10 +1047,10 @@ class UVCommentReportCreateTest(TestCase):
|
||||
},
|
||||
)
|
||||
if success:
|
||||
self.assertEquals(response.status_code, 302)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
else:
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEquals(UVCommentReport.objects.all().exists(), success)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
self.assertEqual(UVCommentReport.objects.all().exists(), success)
|
||||
|
||||
def test_create_report_root_success(self):
|
||||
self.create_report_test("root", True)
|
||||
@ -1069,7 +1069,7 @@ class UVCommentReportCreateTest(TestCase):
|
||||
reverse("pedagogy:comment_report", kwargs={"comment_id": self.comment.id}),
|
||||
{"comment": self.comment.id, "reporter": 0, "reason": "C'est moche"},
|
||||
)
|
||||
self.assertEquals(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
self.assertFalse(UVCommentReport.objects.all().exists())
|
||||
|
||||
def test_notifications(self):
|
||||
@ -1092,7 +1092,7 @@ class UVCommentReportCreateTest(TestCase):
|
||||
|
||||
# Check that notifications are not duplicated if not viewed
|
||||
self.create_report_test("tutu", True)
|
||||
self.assertEquals(
|
||||
self.assertEqual(
|
||||
self.tutu.notifications.filter(type="PEDAGOGY_MODERATION").count(), 1
|
||||
)
|
||||
|
||||
@ -1103,6 +1103,6 @@ class UVCommentReportCreateTest(TestCase):
|
||||
|
||||
self.create_report_test("tutu", True)
|
||||
|
||||
self.assertEquals(
|
||||
self.assertEqual(
|
||||
self.tutu.notifications.filter(type="PEDAGOGY_MODERATION").count(), 2
|
||||
)
|
||||
|
1271
poetry.lock
generated
Normal file
1271
poetry.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -20,29 +20,29 @@ license = "GPL-3.0-only"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.8"
|
||||
Django = "^2.2"
|
||||
Pillow = "^8.3.2"
|
||||
Django = "^3.2"
|
||||
Pillow = "^9.2"
|
||||
mistune = "^0.8.4"
|
||||
django-jinja = "^2.9.1"
|
||||
cryptography = "36.0.2"
|
||||
django-jinja = "^2.10"
|
||||
cryptography = "^37.0"
|
||||
pyOpenSSL = "^21.0.0"
|
||||
pytz = "^2021.1"
|
||||
djangorestframework = "^3.12.4"
|
||||
django-phonenumber-field = "^5.2.0"
|
||||
phonenumbers = "^8.12.33"
|
||||
djangorestframework = "^3.13"
|
||||
django-phonenumber-field = "^6.3"
|
||||
phonenumbers = "^8.12"
|
||||
django-ajax-selects = "^2.1.0"
|
||||
reportlab = "^3.6.1"
|
||||
django-haystack = "^3.1.1"
|
||||
xapian-haystack = "^2.1.1"
|
||||
reportlab = "^3.6"
|
||||
django-haystack = "^3.2.1"
|
||||
xapian-haystack = "^3.0.1"
|
||||
xapian-bindings = "^0.1.0"
|
||||
libsass = "^0.21.0"
|
||||
django-ordered-model = "^3.4.3"
|
||||
django-simple-captcha = "^0.5.14"
|
||||
libsass = "^0.21"
|
||||
django-ordered-model = "^3.6"
|
||||
django-simple-captcha = "^0.5.17"
|
||||
python-dateutil = "^2.8.2"
|
||||
psycopg2-binary = "2.8.6"
|
||||
psycopg2-binary = "2.9.3"
|
||||
sentry-sdk = "^1.4.3"
|
||||
pygraphviz = "^1.9"
|
||||
Jinja2 = "<=3.0.3"
|
||||
Jinja2 = "^3.1"
|
||||
|
||||
# Extra optional dependencies
|
||||
mysqlclient = { version = "^2.0.3", optional = true }
|
||||
@ -61,7 +61,7 @@ docs = ["Sphinx", "sphinx-rtd-theme", "sphinx-copybutton"]
|
||||
[tool.poetry.dev-dependencies]
|
||||
django-debug-toolbar = "^3.2.2"
|
||||
ipython = "^7.28.0"
|
||||
black = "^22.3.0"
|
||||
black = "^22.6.0"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
|
@ -23,7 +23,7 @@
|
||||
#
|
||||
#
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import gettext as _
|
||||
from django.views.generic.edit import FormView
|
||||
from django.views.generic import ListView
|
||||
from django.urls import reverse
|
||||
|
@ -26,7 +26,7 @@ from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.core.cache import cache
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils import timezone
|
||||
|
||||
from PIL import Image
|
||||
|
@ -28,7 +28,7 @@ from django.urls import reverse_lazy, reverse
|
||||
from core.views.forms import SelectDate
|
||||
from django.views.generic import DetailView, TemplateView
|
||||
from django.views.generic.edit import UpdateView, FormMixin, FormView
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.conf import settings
|
||||
from django import forms
|
||||
from django.core.exceptions import PermissionDenied
|
||||
|
@ -41,7 +41,7 @@ import sys
|
||||
import binascii
|
||||
import sentry_sdk
|
||||
from sentry_sdk.integrations.django import DjangoIntegration
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
@ -62,6 +62,8 @@ ALLOWED_HOSTS = ["*"]
|
||||
|
||||
# Application definition
|
||||
|
||||
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
|
||||
|
||||
SITE_ID = 4000
|
||||
|
||||
INSTALLED_APPS = (
|
||||
@ -132,9 +134,7 @@ TEMPLATES = [
|
||||
"extensions": [
|
||||
"jinja2.ext.do",
|
||||
"jinja2.ext.loopcontrols",
|
||||
"jinja2.ext.with_",
|
||||
"jinja2.ext.i18n",
|
||||
"jinja2.ext.autoescape",
|
||||
"django_jinja.builtins.extensions.CsrfExtension",
|
||||
"django_jinja.builtins.extensions.CacheExtension",
|
||||
"django_jinja.builtins.extensions.TimezoneExtension",
|
||||
@ -389,7 +389,7 @@ SITH_SUBSCRIPTION_LOCATIONS = [
|
||||
|
||||
SITH_COUNTER_BARS = [(1, "MDE"), (2, "Foyer"), (35, "La Gommette")]
|
||||
|
||||
SITH_COUNTER_OFFICES = {17: "BdF", 19: "AE"}
|
||||
SITH_COUNTER_OFFICES = {2: "BdF", 1: "AE"}
|
||||
|
||||
SITH_COUNTER_PAYMENT_METHOD = [
|
||||
("CHECK", _("Check")),
|
||||
|
62
sith/urls.py
62
sith/urls.py
@ -37,13 +37,15 @@ Including another URLconf
|
||||
1. Add an import: from blog import urls as blog_urls
|
||||
2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
|
||||
"""
|
||||
from django.urls import include, re_path
|
||||
from django.urls import include, path
|
||||
from django.contrib import admin
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
from django.views.i18n import JavaScriptCatalog
|
||||
from ajax_select import urls as ajax_select_urls
|
||||
|
||||
import core.urls
|
||||
|
||||
js_info_dict = {"packages": ("sith",)}
|
||||
|
||||
handler403 = "core.views.forbidden"
|
||||
@ -51,43 +53,37 @@ handler404 = "core.views.not_found"
|
||||
handler500 = "core.views.internal_servor_error"
|
||||
|
||||
urlpatterns = [
|
||||
re_path(r"^", include(("core.urls", "core"), namespace="core")),
|
||||
re_path(
|
||||
r"^rootplace/", include(("rootplace.urls", "rootplace"), namespace="rootplace")
|
||||
),
|
||||
re_path(
|
||||
r"^subscription/",
|
||||
path("", include(("core.urls", "core"), namespace="core")),
|
||||
path("rootplace/", include(("rootplace.urls", "rootplace"), namespace="rootplace")),
|
||||
path(
|
||||
"subscription/",
|
||||
include(("subscription.urls", "subscription"), namespace="subscription"),
|
||||
),
|
||||
re_path(r"^com/", include(("com.urls", "com"), namespace="com")),
|
||||
re_path(r"^club/", include(("club.urls", "club"), namespace="club")),
|
||||
re_path(r"^counter/", include(("counter.urls", "counter"), namespace="counter")),
|
||||
re_path(r"^stock/", include(("stock.urls", "stock"), namespace="stock")),
|
||||
re_path(
|
||||
r"^accounting/",
|
||||
path("com/", include(("com.urls", "com"), namespace="com")),
|
||||
path("club/", include(("club.urls", "club"), namespace="club")),
|
||||
path("counter/", include(("counter.urls", "counter"), namespace="counter")),
|
||||
path("stock/", include(("stock.urls", "stock"), namespace="stock")),
|
||||
path(
|
||||
"accounting/",
|
||||
include(("accounting.urls", "accounting"), namespace="accounting"),
|
||||
),
|
||||
re_path(r"^eboutic/", include(("eboutic.urls", "eboutic"), namespace="eboutic")),
|
||||
re_path(
|
||||
r"^launderette/",
|
||||
path("eboutic/", include(("eboutic.urls", "eboutic"), namespace="eboutic")),
|
||||
path(
|
||||
"launderette/",
|
||||
include(("launderette.urls", "launderette"), namespace="launderette"),
|
||||
),
|
||||
re_path(r"^sas/", include(("sas.urls", "sas"), namespace="sas")),
|
||||
re_path(r"^api/v1/", include(("api.urls", "api"), namespace="api")),
|
||||
re_path(
|
||||
r"^election/", include(("election.urls", "election"), namespace="election")
|
||||
),
|
||||
re_path(r"^forum/", include(("forum.urls", "forum"), namespace="forum")),
|
||||
re_path(r"^trombi/", include(("trombi.urls", "trombi"), namespace="trombi")),
|
||||
re_path(r"^matmatronch/", include(("matmat.urls", "matmat"), namespace="matmat")),
|
||||
re_path(
|
||||
r"^pedagogy/", include(("pedagogy.urls", "pedagogy"), namespace="pedagogy")
|
||||
),
|
||||
re_path(r"^admin/", admin.site.urls),
|
||||
re_path(r"^ajax_select/", include(ajax_select_urls)),
|
||||
re_path(r"^i18n/", include("django.conf.urls.i18n")),
|
||||
re_path(r"^jsi18n/$", JavaScriptCatalog.as_view(), name="javascript-catalog"),
|
||||
re_path(r"^captcha/", include("captcha.urls")),
|
||||
path("sas/", include(("sas.urls", "sas"), namespace="sas")),
|
||||
path("api/v1/", include(("api.urls", "api"), namespace="api")),
|
||||
path("election/", include(("election.urls", "election"), namespace="election")),
|
||||
path("forum/", include(("forum.urls", "forum"), namespace="forum")),
|
||||
path("trombi/", include(("trombi.urls", "trombi"), namespace="trombi")),
|
||||
path("matmatronch/", include(("matmat.urls", "matmat"), namespace="matmat")),
|
||||
path("pedagogy/", include(("pedagogy.urls", "pedagogy"), namespace="pedagogy")),
|
||||
path("admin/", admin.site.urls),
|
||||
path("ajax_select/", include(ajax_select_urls)),
|
||||
path("i18n/", include("django.conf.urls.i18n")),
|
||||
path("jsi18n/", JavaScriptCatalog.as_view(), name="javascript-catalog"),
|
||||
path("captcha/", include("captcha.urls")),
|
||||
]
|
||||
|
||||
if settings.DEBUG:
|
||||
@ -95,4 +91,4 @@ if settings.DEBUG:
|
||||
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||
import debug_toolbar
|
||||
|
||||
urlpatterns += [re_path(r"^__debug__/", include(debug_toolbar.urls))]
|
||||
urlpatterns += [path("__debug__/", include(debug_toolbar.urls))]
|
||||
|
@ -24,7 +24,7 @@
|
||||
#
|
||||
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.urls import reverse
|
||||
from django.conf import settings
|
||||
|
||||
|
@ -37,7 +37,7 @@ from django.views.generic.edit import (
|
||||
FormMixin,
|
||||
BaseFormView,
|
||||
)
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django import forms
|
||||
from django.http import HttpResponseRedirect, HttpResponse
|
||||
from django.forms.models import modelform_factory
|
||||
|
@ -25,7 +25,7 @@
|
||||
from datetime import date, timedelta
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.urls import reverse
|
||||
|
@ -23,7 +23,7 @@
|
||||
#
|
||||
|
||||
from django.views.generic.edit import CreateView, FormView
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.core.exceptions import PermissionDenied, ValidationError
|
||||
from django.urls import reverse_lazy
|
||||
from django import forms
|
||||
|
@ -23,7 +23,7 @@
|
||||
#
|
||||
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.urls import reverse
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ValidationError
|
||||
|
@ -28,7 +28,7 @@ from django.shortcuts import get_object_or_404, redirect
|
||||
from django.urls import reverse_lazy, reverse
|
||||
from django.views.generic import DetailView, RedirectView, TemplateView, View
|
||||
from django.views.generic.edit import UpdateView, CreateView, DeleteView
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.forms.models import modelform_factory
|
||||
|
Loading…
Reference in New Issue
Block a user