Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a view and an html for a citizen to update her/his popular pro…
…posal
- Loading branch information
Felipe Álvarez
committed
Apr 5, 2016
1 parent
235d865
commit 6c555d2
Showing
6 changed files
with
62 additions
and
3 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
from django.conf.urls import patterns, url | ||
from backend_citizen.views import IndexView | ||
from backend_citizen.views import IndexView, PopularProposalTemporaryDataUpdateView | ||
|
||
urlpatterns = patterns('', | ||
url(r'^index/?$', | ||
IndexView.as_view(), | ||
name='index'), | ||
url(r'^update_temporary_data/(?P<pk>[-\w]+)/?$', | ||
PopularProposalTemporaryDataUpdateView.as_view(), | ||
name='temporary_data_update'), | ||
) |
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 |
---|---|---|
@@ -1,7 +1,29 @@ | ||
from django.shortcuts import render | ||
from django.contrib.auth.mixins import LoginRequiredMixin | ||
from django.views.generic.base import TemplateView | ||
from django.views.generic.edit import FormView | ||
from popular_proposal.forms import ProposalTemporaryDataUpdateForm | ||
from popular_proposal.models import ProposalTemporaryData | ||
from django.shortcuts import get_object_or_404 | ||
|
||
|
||
class IndexView(LoginRequiredMixin, TemplateView): | ||
template_name='backend_citizen/index.html' | ||
|
||
|
||
class PopularProposalTemporaryDataUpdateView(LoginRequiredMixin, FormView): | ||
template_name = 'backend_citizen/temporary_data_update.html' | ||
form_class = ProposalTemporaryDataUpdateForm | ||
|
||
def get_form_kwargs(self): | ||
kwargs = super(PopularProposalTemporaryDataUpdateView, self).get_form_kwargs() | ||
pk = self.kwargs.pop('pk') | ||
self.temporary_data = get_object_or_404(ProposalTemporaryData, pk=pk) | ||
kwargs['temporary_data'] = self.temporary_data | ||
kwargs['proposer'] = self.request.user | ||
return kwargs | ||
|
||
def get_context_data(self, *args, **kwargs): | ||
context = super(PopularProposalTemporaryDataUpdateView, self).get_context_data(*args, **kwargs) | ||
context['temporary_data'] = self.temporary_data | ||
return context |
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
12 changes: 12 additions & 0 deletions
12
votai_general_theme/templates/backend_citizen/temporary_data_update.html
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,12 @@ | ||
{% load bootstrap_tags %} | ||
{% load staticfiles %} | ||
{% load i18n %} | ||
{% load thumbnail %} | ||
|
||
<form action="{% url 'backend_citizen:temporary_data_update' pk=temporary_data.id %}" method="POST" role="form"> | ||
{% csrf_token %} | ||
{{ form|as_bootstrap }} | ||
<div class="form-actions"> | ||
<button type="submit" class="btn btn-primary">{% trans 'Actualiza tu propuesta'%}</button> | ||
</div> | ||
</form> |