from django.views.decorators.http import require_POST from django.db.models import Count from django.utils.decorators import method_decorator from django.views.generic.create_update import update_object from django.db.models import F from django.http import HttpResponse from apps.ecidadania.proposals.models import Proposal, ProposalSet from apps.ecidadania.proposals.forms import ProposalForm, VoteProposal, \ ProposalSetForm from apps.thirdparty.userroles.decorators import role_required from apps.thirdparty.userroles import roles from core.spaces.models import Space m_role_required = method_decorator(role_required(roles.space_admin)) class AddProposal(FormView): """ Create a new proposal. :parameters: space_url :rtype: HTML Form :context: form, get_place """ form_class = ProposalForm template_name = 'proposals/proposal_add.html' def get_success_url(self): return '/spaces/' + self.kwargs['space_url']
from apps.thirdparty.userroles.decorators import role_required from apps.thirdparty.userroles import roles urlpatterns = patterns('apps.ecidadania.proposals.views', url(_(r'^$'), ListProposals.as_view(), name='list-proposals'), url(_(r'^psets/(?P<set_id>\w+)/edit/'), EditProposalSet.as_view(), name='edit-proposalset'), url(_(r'^psets/(?P<set_id>\w+)/delete/'), DeleteProposalSet.as_view(), name='delete-proposalset'), url(_(r'^psets/(?P<set_id>\w+)/'), ViewProposalSet.as_view(), name='view-proposalset'), url(_(r'^psets/'), ListProposalSet.as_view(), name='list-proposalset'), url(_(r'^addset/'), role_required(roles.space_admin)(AddProposalSet.as_view()), name='add-proposalset'), url(_(r'^add/'), AddProposal.as_view(), name='add-proposal'), url(_(r'^add_support_vote/'),'vote_proposal'), url(_(r'^(?P<prop_id>\w+)/$'), ViewProposal.as_view(), name='view-proposal'), url(_(r'^(?P<prop_id>\w+)/edit/$'), EditProposal.as_view(), name='edit-proposal'), url(_(r'^(?P<prop_id>\w+)/delete/$'), DeleteProposal.as_view(), name='delete-proposal'), )