Skip to content

Commit

Permalink
apps/votes/dashboard: make naming more descriptive
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzzylogic2000 authored and Rineee committed Sep 28, 2022
1 parent 8dc4466 commit 931af16
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
44 changes: 22 additions & 22 deletions meinberlin/apps/votes/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
from . import views


class VotesComponent(DashboardComponent):
identifier = 'voting_token_export'
weight = 49
label = _('Code download')
class GenerateTokenComponent(DashboardComponent):
identifier = 'voting_token_generation'
weight = 48
label = _('Code generation')
for_superuser_only = True

def is_effective(self, module):
return module.blueprint_type == 'PB3'
Expand All @@ -19,26 +20,22 @@ def get_progress(self, module):
return 0, 0

def get_base_url(self, module):
return reverse('a4dashboard:voting-tokens', kwargs={
return reverse('a4dashboard:voting-token-generation', kwargs={
'module_slug': module.slug,
})

def get_urls(self):
return [
(r'^modules/(?P<module_slug>[-\w_]+)/download-codes/$',
views.VotingDashboardView.as_view(component=self),
'voting-tokens'),
(r'^modules/(?P<module_slug>[-\w_]+)/download-codes/export/$',
views.TokenExportView.as_view(),
'token-export'),
(r'^modules/(?P<module_slug>[-\w_]+)/generate-codes/$',
views.TokenGenerationDashboardView.as_view(component=self),
'voting-token-generation'),
]


class GenerateVotesComponent(DashboardComponent):
identifier = 'voting_token_generation'
weight = 48
label = _('Code generation')
for_superuser_only = True
class ExportTokenComponent(DashboardComponent):
identifier = 'voting_token_export'
weight = 49
label = _('Code download')

def is_effective(self, module):
return module.blueprint_type == 'PB3'
Expand All @@ -47,17 +44,20 @@ def get_progress(self, module):
return 0, 0

def get_base_url(self, module):
return reverse('a4dashboard:voting-token-generation', kwargs={
return reverse('a4dashboard:voting-tokens', kwargs={
'module_slug': module.slug,
})

def get_urls(self):
return [
(r'^modules/(?P<module_slug>[-\w_]+)/generate-codes/$',
views.VotingGenerationDashboardView.as_view(component=self),
'voting-token-generation'),
(r'^modules/(?P<module_slug>[-\w_]+)/download-codes/$',
views.ExportTokenDashboardView.as_view(component=self),
'voting-tokens'),
(r'^modules/(?P<module_slug>[-\w_]+)/download-codes/export/$',
views.TokenExportView.as_view(),
'token-export'),
]


components.register_module(VotesComponent())
components.register_module(GenerateVotesComponent())
components.register_module(GenerateTokenComponent())
components.register_module(ExportTokenComponent())
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h1 class="u-first-heading">{% translate 'Download voting codes' %}</h1>
{% for page in token_export_iterator %}
<li class="u-bottom-divider u-space-between">
<div class="" id="id-export-tokens-hint">
{% translate " code package no." %} - {{ page }}
{% translate " code package no." %} {{ page }}
</div>
<a class="btn btn--secondary" id="download-link" aria-labelledby="id-export-tokens-hint download-link" href="{{ token_export_url }}?page={{ page }}">
{% translate "Download" %}
Expand Down
14 changes: 7 additions & 7 deletions meinberlin/apps/votes/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
TOKENS_PER_MODULE = int(5e6)


class VotingDashboardView(ProjectMixin,
dashboard_mixins.DashboardBaseMixin,
dashboard_mixins.DashboardComponentMixin,
generic.TemplateView):
class ExportTokenDashboardView(ProjectMixin,
dashboard_mixins.DashboardBaseMixin,
dashboard_mixins.DashboardComponentMixin,
generic.TemplateView):
permission_required = 'a4projects.change_project'
template_name = 'meinberlin_votes/voting_dashboard.html'
template_name = 'meinberlin_votes/token_export_dashboard.html'

def _get_number_of_tokens(self):
return VotingToken.objects.filter(
Expand Down Expand Up @@ -99,7 +99,7 @@ def raise_exception(self):
return self.request.user.is_authenticated


class VotingGenerationDashboardView(
class TokenGenerationDashboardView(
ProjectMixin, dashboard_mixins.DashboardBaseMixin,
dashboard_mixins.DashboardComponentMixin,
generic.base.TemplateResponseMixin, generic.edit.FormMixin,
Expand All @@ -115,7 +115,7 @@ class VotingGenerationDashboardView(
_('Please adjust your number of codes. Per module you can '
'generate up to {} codes.'))
permission_required = 'is_superuser'
template_name = 'meinberlin_votes/voting_code_dashboard.html'
template_name = 'meinberlin_votes/token_generation_dashboard.html'

def _get_number_of_tokens(self):
return VotingToken.objects.filter(
Expand Down

0 comments on commit 931af16

Please sign in to comment.