Merge branch 'skia/fix_eboutic' into 'master'

Multiple fixes

* Bump `black` and fix issues
* `club`: fix tests broken by inclusive translation
* `gitlab-ci`: use `poetry`, as `pip` was broken anyway
* `eboutic`: et_autoanswer: don't require 'Auto' to proceed checking the request: As described in the [doc](https://www.paybox.com/espace-integrateur-documentation/la-solution-paybox-system/gestion-de-la-reponse/), `Auto` may be missing if the payment failed. Thus, it's not required to proceed checking the bank's answer.

See merge request ae/Sith!296
This commit is contained in:
Skia 2022-03-02 16:21:10 +00:00
commit 234556a172
5 changed files with 39 additions and 30 deletions

View File

@ -7,13 +7,14 @@ test:
- env - env
- apt-get update - apt-get update
- apt-get install -y gettext libxapian-dev libgraphviz-dev - apt-get install -y gettext libxapian-dev libgraphviz-dev
- pip install .[testing] - pip install poetry
- poetry install -E testing
- mkdir -p /dev/shm/search_indexes - mkdir -p /dev/shm/search_indexes
- ln -s /dev/shm/search_indexes sith/search_indexes - ln -s /dev/shm/search_indexes sith/search_indexes
- ./manage.py compilemessages - poetry run ./manage.py compilemessages
- coverage run ./manage.py test - poetry run coverage run ./manage.py test
- coverage html - poetry run coverage html
- coverage report - poetry run coverage report
variables: variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip_tests" PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip_tests"
cache: cache:

View File

@ -161,10 +161,10 @@ class ClubTest(TestCase):
response = self.client.get( response = self.client.get(
reverse("club:club_members", kwargs={"club_id": self.bdf.id}) reverse("club:club_members", kwargs={"club_id": self.bdf.id})
) )
self.assertTrue(response.status_code == 200) self.assertEqual(response.status_code, 200)
self.assertTrue( self.assertIn(
"""Richard Batsbak</a></td>\\n <td>Vice-Pr\\xc3\\xa9sident</td>""" """Richard Batsbak</a></td>\n <td>Vice-Président⸱e</td>""",
in str(response.content) response.content.decode(),
) )
def test_create_add_user_to_club_from_richard_fail(self): def test_create_add_user_to_club_from_richard_fail(self):
@ -369,14 +369,15 @@ class ClubTest(TestCase):
response = self.client.get( response = self.client.get(
reverse("club:club_members", kwargs={"club_id": self.bdf.id}) reverse("club:club_members", kwargs={"club_id": self.bdf.id})
) )
self.assertTrue(response.status_code == 200) self.assertEqual(response.status_code, 200)
content = str(response.content) content = response.content.decode()
self.assertTrue( self.assertIn(
"Richard Batsbak</a></td>\\n <td>Curieux</td>" in content "Richard Batsbak</a></td>\n <td>Curieux⸱euse</td>",
content,
) )
self.assertTrue( self.assertIn(
"S&#39; Kia</a></td>\\n <td>Responsable info</td>" "S&#39; Kia</a></td>\n <td>Responsable info</td>",
in content content,
) )

View File

@ -118,11 +118,14 @@ class SelectFile(TextInput):
attrs["class"] = "select_file" attrs["class"] = "select_file"
else: else:
attrs = {"class": "select_file"} attrs = {"class": "select_file"}
output = '%(content)s<div name="%(name)s" class="choose_file_widget" title="%(title)s"></div>' % { output = (
"content": super(SelectFile, self).render(name, value, attrs, renderer), '%(content)s<div name="%(name)s" class="choose_file_widget" title="%(title)s"></div>'
"title": _("Choose file"), % {
"name": name, "content": super(SelectFile, self).render(name, value, attrs, renderer),
} "title": _("Choose file"),
"name": name,
}
)
output += ( output += (
'<span name="' '<span name="'
+ name + name
@ -139,11 +142,14 @@ class SelectUser(TextInput):
attrs["class"] = "select_user" attrs["class"] = "select_user"
else: else:
attrs = {"class": "select_user"} attrs = {"class": "select_user"}
output = '%(content)s<div name="%(name)s" class="choose_user_widget" title="%(title)s"></div>' % { output = (
"content": super(SelectUser, self).render(name, value, attrs, renderer), '%(content)s<div name="%(name)s" class="choose_user_widget" title="%(title)s"></div>'
"title": _("Choose user"), % {
"name": name, "content": super(SelectUser, self).render(name, value, attrs, renderer),
} "title": _("Choose user"),
"name": name,
}
)
output += ( output += (
'<span name="' '<span name="'
+ name + name

View File

@ -252,8 +252,6 @@ class EtransactionAutoAnswer(View):
if ( if (
not "Amount" in request.GET.keys() not "Amount" in request.GET.keys()
or not "BasketID" in request.GET.keys() or not "BasketID" in request.GET.keys()
or not "Auto"
in request.GET.keys() # If not in the request it means the payment has been refused
or not "Error" in request.GET.keys() or not "Error" in request.GET.keys()
or not "Sig" in request.GET.keys() or not "Sig" in request.GET.keys()
): ):
@ -271,7 +269,10 @@ class EtransactionAutoAnswer(View):
) )
except: except:
return HttpResponse("Bad signature", status=400) return HttpResponse("Bad signature", status=400)
if request.GET["Error"] == "00000": # Payment authorized:
# * 'Error' is '00000'
# * 'Auto' is in the request
if request.GET["Error"] == "00000" and "Auto" in request.GET.keys():
try: try:
with transaction.atomic(): with transaction.atomic():
b = ( b = (

View File

@ -58,7 +58,7 @@ docs = ["Sphinx", "sphinx-rtd-theme", "sphinx-copybutton"]
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
django-debug-toolbar = "^3.2.2" django-debug-toolbar = "^3.2.2"
ipython = "^7.28.0" ipython = "^7.28.0"
black = "^21.9b0" black = "^22.1.0"
[build-system] [build-system]
requires = ["poetry-core>=1.0.0"] requires = ["poetry-core>=1.0.0"]