Compare commits

...

2 Commits

Author SHA1 Message Date
8cb0554696 Add pre-commit config
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-17 15:21:26 +01:00
947d9f740c fix after changing null -> blank 2023-02-17 15:21:04 +01:00
4 changed files with 44 additions and 6 deletions

40
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,40 @@
repos:
- repo: local
hooks:
- id: poetry
name: poetry
language: system
entry: poetry check
files: '^(pyproject.toml|poetry.lock)$'
pass_filenames: false
# - id: black
# name: black
# language: system
# entry: poetry run black --target-version py39
# types_or: [python, pyi]
# require_serial: true
# - id: isort
# name: isort
# language: system
# entry: poetry run isort --profile black --python-version 39
# types_or: [cython, pyi, python]
# require_serial: true
# - id: flake8
# name: flake8
# language: system
# entry: poetry run flake8
# types_or: [python]
# files: "^.*\\.py$"
# - id: mypy
# name: mypy
# language: system
# entry: poetry run mypy --strict --python-version 3.9
# types_or: [python, pyi]
# files: "^.*\\.pyi?$"
- id: test
name: test
language: system
entry: poetry run ./manage.py test
types_or: [python]
files: "^.*\\.py$"
pass_filenames: false

View File

@ -14,7 +14,7 @@
<p>Total score: {{ movie.score }}, seen by: {{ movie.seen_score }}.
<ul>
{% for vote in votes %}
<li>{{vote.user.username}} {% if vote.seen %}(seen){% endif %} &ndash; {% if vote.vote == 1 %}👍{% elif vote.vote == 0 %}No opinion{% elif vote.vote == -1 %}👎{%endif%}{% if vote.comment is not None %} &ndash; {{vote.comment}}{% endif %}</li>
<li>{{vote.user.username}} {% if vote.seen %}(seen){% endif %} &ndash; {% if vote.vote == 1 %}👍{% elif vote.vote == 0 %}No opinion{% elif vote.vote == -1 %}👎{%endif%}{% if vote.comment != "" %} &ndash; {{vote.comment}}{% endif %}</li>
{% endfor %}
</ul>
{% endif %}

View File

@ -166,10 +166,10 @@ class VoteTests(TestCase):
with self.subTest(comment=comment):
response = self.client.post(reverse('watchlist:vote', args=(m.id,)), data={"vote": "0", "comment": comment})
mv = m.movievote_set.get(user=self.user)
self.assertEqual(mv.comment, None if comment == "" else comment)
self.assertEqual(mv.comment, comment)
with self.subTest(comment=None):
response = self.client.post(reverse('watchlist:vote', args=(m.id,)), data={"vote": "0"})
mv = m.movievote_set.get(user=self.user)
self.assertEqual(mv.comment, None)
self.assertEqual(mv.comment, "")

View File

@ -56,9 +56,7 @@ def vote(request, pk):
user_vote.vote = request.POST['vote']
user_vote.seen = request.POST.get('seen', False) == "on"
comment = request.POST.get('comment', '').strip()
if comment != '' or user_vote.comment is not None:
if comment == '':
comment = None
if comment != '' or user_vote.comment != "":
user_vote.comment = comment
user_vote.save()
return HttpResponseRedirect(reverse('watchlist:index'))