-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apps/budgeting: add token form to proposal list view
- Loading branch information
rine
committed
Dec 2, 2021
1 parent
2ae96e9
commit 4830b0b
Showing
4 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from django import forms | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from meinberlin.apps.votes.models import VotingToken | ||
|
||
|
||
class TokenForm(forms.Form): | ||
|
||
token = forms.CharField(max_length=40) | ||
|
||
def __init__(self, *args, **kwargs): | ||
self.module_id = kwargs.pop('module_id') | ||
super().__init__(*args, **kwargs) | ||
|
||
def clean(self): | ||
cleaned_data = super().clean() | ||
if 'token' in self.cleaned_data: | ||
token_queryset = VotingToken.objects.filter( | ||
token=self.cleaned_data['token'], | ||
module_id=self.module_id | ||
) | ||
if not token_queryset: | ||
self.add_error('token', _('This token is not valid')) | ||
|
||
return cleaned_data |