Skip to content

Commit

Permalink
update sourcery and hopefully fix templating issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Sargent committed Feb 13, 2024
1 parent 08a4bf8 commit c29dc7d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
1 change: 1 addition & 0 deletions .sourcery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ignore: # A list of paths or files which Sourcery will ignore.
- env
- .env
- .tox
- approval_polls/static

rule_settings:
enable:
Expand Down
3 changes: 1 addition & 2 deletions approval_polls/templates/account/signup_closed.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
{% trans "Sign Up Closed" %}
{% endblock head_title %}
{% block content %}
{%
element h1 %} {% trans "Sign Up Closed" %} {% endelement %}
{% element h1 %} {% trans "Sign Up Closed" %} {% endelement %}
<p>{% trans "We are sorry, but the sign up is currently closed." %}</p>
{% endblock content %}
3 changes: 1 addition & 2 deletions approval_polls/templates/account/verification_sent.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
{% trans "Verify Your Email Address" %}
{% endblock head_title %}
{% block content %}
{% element h1 %} {% trans "Verify Your Email Address" %} {%
endelement %}
{% element h1 %} {% trans "Verify Your Email Address" %} {% endelement %}
<p>
{% blocktrans %}We have sent an email to you for verification. Follow the link
provided to finalize the signup process. If you do not see the verification
Expand Down
27 changes: 13 additions & 14 deletions approval_polls/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def get_context_data(self, **kwargs):
else:
if poll.id in polls_voted_list:
context["already_voted"] = True
if poll.vtype == 2 and user.is_authenticated():
if poll.vtype == 2 and user.is_authenticated:
for ballot in poll.ballot_set.all():
if ballot.user == user:
for option in ballot.vote_set.all():
Expand All @@ -223,17 +223,16 @@ def get_context_data(self, **kwargs):
allowed_emails = []
for invitation in invitations:
allowed_emails.append(invitation.email)
if user.is_authenticated():
# If the user is authenticated, the poll should be accessible from the home
# page, if it is public.
if user.email in allowed_emails or user == poll.user:
context["vote_authorized"] = True
# Get the checked choices.
for ballot in poll.ballot_set.all():
if ballot.user == user:
for option in ballot.vote_set.all():
checked_choices.append(option.choice)
permit_email = ballot.permit_email
if user.is_authenticated and (
user.email in allowed_emails or user == poll.user
):
context["vote_authorized"] = True
# Get the checked choices.
for ballot in poll.ballot_set.all():
if ballot.user == user:
for option in ballot.vote_set.all():
checked_choices.append(option.choice)
permit_email = ballot.permit_email
if "key" in self.request.GET and "email" in self.request.GET:
invitations = VoteInvitation.objects.filter(
key=self.request.GET["key"],
Expand Down Expand Up @@ -356,7 +355,7 @@ def vote(request, poll_id):
return HttpResponseRedirect(reverse("detail", args=(poll.id,)))
elif poll_vtype == 2:
# Type 2 poll - the user is required to login to vote.
if request.user.is_authenticated():
if request.user.is_authenticated:
# Check if a poll is closed
if not poll.is_closed():
# Check if a ballot exists under the users name.
Expand Down Expand Up @@ -438,7 +437,7 @@ def vote(request, poll_id):
if users:
auth_user = users[0]

elif request.user.is_authenticated():
elif request.user.is_authenticated:
auth_user = request.user
invitations = VoteInvitation.objects.filter(
email=request.user.email,
Expand Down

0 comments on commit c29dc7d

Please sign in to comment.