diff --git a/openslides/agenda/forms.py b/openslides/agenda/forms.py index db33f8bbe..69f761e75 100644 --- a/openslides/agenda/forms.py +++ b/openslides/agenda/forms.py @@ -13,7 +13,7 @@ from django.forms import Form, ModelForm, IntegerField, ChoiceField, \ ModelChoiceField, HiddenInput, Select from django.utils.translation import ugettext as _ -from openslides.agenda.models import Item, ItemText, ItemApplication, ItemPoll, \ +from openslides.agenda.models import Item, ItemText, ItemApplication, \ ItemAssignment class ItemFormText(ModelForm): @@ -23,7 +23,7 @@ class ItemFormText(ModelForm): parent = ModelChoiceField(queryset=items, label=_("Parent item"), required=False) class Meta: model = ItemText - exclude = ('closed') + exclude = ('closed', 'weight') class ItemFormApplication(ModelForm): @@ -34,18 +34,7 @@ class ItemFormApplication(ModelForm): class Meta: model = ItemApplication - exclude = ('closed') - - -class ItemFormPoll(ModelForm): - error_css_class = 'error' - required_css_class = 'required' - items = Item.objects.all().filter(parent=None).order_by('weight') - parent = ModelChoiceField(queryset=items, label=_("Parent item"), required=False) - - class Meta: - model = ItemPoll - exclude = ('closed') + exclude = ('closed', 'weight') class ItemFormAssignment(ModelForm): @@ -56,7 +45,7 @@ class ItemFormAssignment(ModelForm): class Meta: model = ItemAssignment - exclude = ('closed') + exclude = ('closed', 'weight') def genweightchoices(): @@ -77,6 +66,5 @@ class ElementOrderForm(Form): MODELFORM = { 'ItemText': ItemFormText, 'ItemApplication': ItemFormApplication, - 'ItemPoll': ItemFormPoll, 'ItemAssignment': ItemFormAssignment, } diff --git a/openslides/agenda/templates/agenda/edit.html b/openslides/agenda/templates/agenda/edit.html index 190665d1a..6eeca7a33 100644 --- a/openslides/agenda/templates/agenda/edit.html +++ b/openslides/agenda/templates/agenda/edit.html @@ -27,7 +27,7 @@ {%trans 'Save' %} - {%trans 'Apply' %} + {%trans 'Apply' %} diff --git a/openslides/agenda/templates/agenda/overview.html b/openslides/agenda/templates/agenda/overview.html index 9ce74c3ef..a530e92b6 100644 --- a/openslides/agenda/templates/agenda/overview.html +++ b/openslides/agenda/templates/agenda/overview.html @@ -70,7 +70,7 @@ {% if perms.agenda.can_manage_agenda %} {% endif %} - + {% for item in items %} {% if not item.hidden or perms.agenda.can_manage_agenda %} @@ -124,7 +124,7 @@ {% endifequal %} {% endif %} - + {% if perms.agenda.can_manage_agenda %} diff --git a/openslides/agenda/views.py b/openslides/agenda/views.py index 7b0ccb6fe..f7e8d69be 100644 --- a/openslides/agenda/views.py +++ b/openslides/agenda/views.py @@ -234,12 +234,6 @@ def edit(request, item_id=None, form='ItemText', default=None): 'application': application, 'title': application.title, } - elif form == "ItemPoll": - poll = Poll.objects.get(pk=default) - initial = { - 'poll': poll, - 'title': poll.title, - } if item_id is None: form = MODELFORM[form](initial=initial) diff --git a/openslides/application/models.py b/openslides/application/models.py index 5158fcf3f..dedd847ec 100644 --- a/openslides/application/models.py +++ b/openslides/application/models.py @@ -346,7 +346,7 @@ class Application(models.Model): raise AttributeError(name) raise AttributeError(name) - def gen_poll(self, user=None, pollcount=None): + def gen_poll(self, user=None): """ Generates a poll object for the application """ diff --git a/openslides/application/templates/application/edit.html b/openslides/application/templates/application/edit.html index 015174f02..7cfd67889 100644 --- a/openslides/application/templates/application/edit.html +++ b/openslides/application/templates/application/edit.html @@ -16,6 +16,9 @@ {%trans 'Save' %} + + {%trans 'Apply' %} + {%trans 'Cancel' %} diff --git a/openslides/application/templates/application/poll_view.html b/openslides/application/templates/application/poll_view.html index 75246d0c8..ed9f67e7e 100644 --- a/openslides/application/templates/application/poll_view.html +++ b/openslides/application/templates/application/poll_view.html @@ -14,40 +14,49 @@ {% block content %} {%trans "Application" %} #{{ poll.application.number }} - {%trans "Vote" %} - {{ poll.application.title }} + {{ poll.application.title }} - {% if perms.poll.can_manage_poll %} - {% csrf_token %} - - {%trans "Results" %}: {{ ballot }}. {%trans "Vote" %} - {%trans "Votes in favour" %}: - {{ options.0.form.yes.errors }}{{ options.0.form.yes }} - - {%trans "Votes against" %}: - {{ options.0.form.no.errors }}{{ options.0.form.no }} - - {%trans "Abstentions" %}: - {{ options.0.form.undesided.errors }}{{ options.0.form.undesided }} - - {%trans "Invalid votes" %}: - {{ form.invalid.errors }}{{ form.invalid }} - - {%trans "Votes cast" %}: - {{ form.votescast.errors }}{{ form.votescast }} - - - - {%trans 'Apply' %} + {%trans "Results of" %} {{ ballot }}. {%trans "Vote" %} + + {% csrf_token %} + + + {%trans "Option" %} + {%trans "Votes" %} + + + {%trans "Yes" %} + {{ options.0.form.yes.errors }}{{ options.0.form.yes }} + + + {%trans "No" %} + {{ options.0.form.no.errors }}{{ options.0.form.no }} + + + {%trans "Abstentions" %} + {{ options.0.form.undesided.errors }}{{ options.0.form.undesided }} + + + {%trans "Invalid votes" %} + {{ form.invalid.errors }}{{ form.invalid }} + + + {%trans "Votes cast" %} + {{ form.votescast.errors }}{{ form.votescast }} + + + + + {%trans 'Save' %} + + + {%trans 'Apply' %} + + + + {%trans 'Cancel' %} - - - - - - {%trans 'Back to application' %} - - - - - {% endif %} + + + {% endblock %} diff --git a/openslides/application/views.py b/openslides/application/views.py index 8053ce6da..340d7c621 100644 --- a/openslides/application/views.py +++ b/openslides/application/views.py @@ -287,12 +287,11 @@ def gen_poll(request, application_id): gen a poll for this application. """ try: - count = Poll.objects.filter(application=application_id).count() - Application.objects.get(pk=application_id).gen_poll(user=request.user, pollcount=count+1) - messages.success(request, _("New poll was successfully created.") ) + poll = Application.objects.get(pk=application_id).gen_poll(user=request.user) + messages.success(request, _("New vote was successfully created.") ) except Application.DoesNotExist: pass - return redirect(reverse('application_view', args=[application_id])) + return redirect(reverse('application_poll_view', args=[poll.id])) @permission_required('application.can_manage_application') @@ -311,7 +310,7 @@ def delete_poll(request, poll_id): return redirect(reverse('application_view', args=[application.id])) -@permission_required('application.can_view_poll') +@permission_required('application.can_manage_application') @template('application/poll_view.html') def view_poll(request, poll_id): """ @@ -320,7 +319,7 @@ def view_poll(request, poll_id): poll = Poll.objects.get(pk=poll_id) ballot = poll.ballot options = poll.options - if request.user.has_perm('application.can_manage_applications'): + if request.user.has_perm('application.can_manage_application'): if request.method == 'POST': form = PollForm(request.POST, prefix="poll") if form.is_valid(): @@ -337,6 +336,9 @@ def view_poll(request, poll_id): option.voteundesided = option.form. \ cleaned_data['undesided'] or 0 option.save() + messages.success(request, _("Votes are successfully saved.") ) + if not 'apply' in request.POST: + return redirect(reverse('application_view', args=[poll.application.id])) else: form = PollForm(initial={'invalid': poll.votesinvalid, 'votescast': poll.votescast}, prefix="poll") for option in options: diff --git a/openslides/assignment/templates/assignment/edit.html b/openslides/assignment/templates/assignment/edit.html index 08a614377..b076aa02a 100644 --- a/openslides/assignment/templates/assignment/edit.html +++ b/openslides/assignment/templates/assignment/edit.html @@ -14,6 +14,9 @@ {%trans 'Save' %} + + {%trans 'Apply' %} + {%trans 'Cancel' %} diff --git a/openslides/assignment/templates/assignment/poll_view.html b/openslides/assignment/templates/assignment/poll_view.html index bd96cf983..33f6bd871 100644 --- a/openslides/assignment/templates/assignment/poll_view.html +++ b/openslides/assignment/templates/assignment/poll_view.html @@ -8,7 +8,7 @@ {% trans "Short description" %}: {{ poll.description }} {% csrf_token %} - + {%trans "Option" %} {% if poll.optiondecision %} @@ -20,7 +20,7 @@ {% endif %} {% for option in options %} - + {{ option }} {% if poll.optiondecision %} {{ option.form.yes.errors }}{{ option.form.yes }} @@ -31,31 +31,38 @@ {% endif %} {% endfor %} + + {% trans "Invalid votes" %} + {{ form.invalid.errors }}{{ form.invalid }} + + + {% trans "Votes cast" %} + {{ form.votescast.errors }}{{ form.votescast }} + - {% trans "Invalid votes" %}: - {{ form.invalid.errors }}{{ form.invalid }} - - {% trans "Votes cast" %}: - {{ form.votescast.errors }}{{ form.votescast }} - - {% if perms.poll.can_manage_poll %} + - - {%trans 'Apply' %} - - - - {%trans 'Back to election' %} - - {%trans 'Print ballot' %} - {% endif %} + + + + {%trans 'Save' %} + + + {%trans 'Apply' %} + + + + {%trans 'Cancel' %} + + + {% endblock %} diff --git a/openslides/assignment/templates/assignment/view.html b/openslides/assignment/templates/assignment/view.html index 3a22b53ca..c91786831 100644 --- a/openslides/assignment/templates/assignment/view.html +++ b/openslides/assignment/templates/assignment/view.html @@ -173,7 +173,7 @@ {%trans 'Invalid votes' %} {% for p in polls %} - {{ p.votesinvalid }} + {{ p.votesinvalid }} {% endfor %} {% if assignment.profile.count > 0 and perms.assignment.can_manage_assignment and assignment.status == "vot" %} @@ -182,7 +182,7 @@ {%trans 'Votes cast' %} {% for p in polls %} - {{ p.votescast }} + {{ p.votescast }} {% endfor %} {% if assignment.profile.count > 0 and perms.assignment.can_manage_assignment and assignment.status == "vot" %} diff --git a/openslides/assignment/views.py b/openslides/assignment/views.py index 4d7873769..4a41cae92 100644 --- a/openslides/assignment/views.py +++ b/openslides/assignment/views.py @@ -108,6 +108,7 @@ def edit(request, assignment_id=None): messages.success(request, _('New election was successfully created.')) else: messages.success(request, _('Election was successfully modified.')) + if not 'apply' in request.POST: return redirect(reverse("assignment_overview")) else: form = AssignmentForm(instance=assignment) @@ -188,7 +189,7 @@ def gen_poll(request, assignment_id): return redirect(reverse('assignment_poll_view', args=[poll.id])) -@permission_required('assignment.can_view_assignment') +@permission_required('assignment.can_manage_assignment') @template('assignment/poll_view.html') def poll_view(request, poll_id): poll = Poll.objects.get(pk=poll_id) @@ -214,6 +215,8 @@ def poll_view(request, poll_id): success = success + 1 if success == options.count(): messages.success(request, _("Votes are successfully saved.") ) + if not 'apply' in request.POST: + return redirect(reverse('assignment_view', args=[assignment.id])) else: form = PollForm(initial={'invalid': poll.votesinvalid, 'votescast': poll.votescast}, prefix="poll") for option in options: diff --git a/openslides/static/styles/base.css b/openslides/static/styles/base.css index 311bd0a16..d5e3f3540 100644 --- a/openslides/static/styles/base.css +++ b/openslides/static/styles/base.css @@ -252,6 +252,7 @@ table a.table_edit { } tr.total td { border-top: 1px solid #333333; + background-color: #e3e3e3; } @@ -344,7 +345,7 @@ button .cancel{ button .ok{ background:url(../images/icons/dialog-ok-apply.png) no-repeat 0px 0px; } -button .ok-blue{ +button .ok-blue, button .apply{ background:url(../images/icons/dialog-ok.png) no-repeat 0px 0px; } button .edit{ @@ -411,7 +412,7 @@ button .stop{ .errorlist { color:#DA3939; - font-size:10px; + font-size:9px; font-style:italic; height:16px; padding:0; diff --git a/openslides/templates/403.html b/openslides/templates/403.html index ebd1bb19e..99ea3fbdc 100644 --- a/openslides/templates/403.html +++ b/openslides/templates/403.html @@ -15,10 +15,6 @@ {%trans "Elections" %} {% endif %} - {% if perms.poll.can_view_poll or perms.poll.can_manage_poll %} - - {%trans "Polls" %} - {% endif %} {% if perms.participant.can_view_participants or perms.participant.can_manage_participants %} {%trans "Participants" %} diff --git a/openslides/templates/404.html b/openslides/templates/404.html index 972b12820..207553df0 100644 --- a/openslides/templates/404.html +++ b/openslides/templates/404.html @@ -15,10 +15,6 @@ {%trans "Elections" %} {% endif %} - {% if perms.poll.can_view_poll or perms.poll.can_manage_poll %} - - {%trans "Polls" %} - {% endif %} {% if perms.participant.can_view_participants or perms.participant.can_manage_participants %} {%trans "Participants" %} diff --git a/openslides/templates/500.html b/openslides/templates/500.html index 9c64131d7..fdb3fafc4 100644 --- a/openslides/templates/500.html +++ b/openslides/templates/500.html @@ -15,10 +15,6 @@ {%trans "Elections" %} {% endif %} - {% if perms.poll.can_view_poll or perms.poll.can_manage_poll %} - - {%trans "Polls" %} - {% endif %} {% if perms.participant.can_view_participants or perms.participant.can_manage_participants %} {%trans "Participants" %}
{%trans "Votes in favour" %}: - {{ options.0.form.yes.errors }}{{ options.0.form.yes }} -
{%trans "Votes against" %}: - {{ options.0.form.no.errors }}{{ options.0.form.no }} -
{%trans "Abstentions" %}: - {{ options.0.form.undesided.errors }}{{ options.0.form.undesided }} -
{%trans "Invalid votes" %}: - {{ form.invalid.errors }}{{ form.invalid }} -
{%trans "Votes cast" %}: - {{ form.votescast.errors }}{{ form.votescast }} -
- - {%trans 'Apply' %} + {%trans "Results of" %} {{ ballot }}. {%trans "Vote" %} + + {% csrf_token %} + + + {%trans "Option" %} + {%trans "Votes" %} + + + {%trans "Yes" %} + {{ options.0.form.yes.errors }}{{ options.0.form.yes }} + + + {%trans "No" %} + {{ options.0.form.no.errors }}{{ options.0.form.no }} + + + {%trans "Abstentions" %} + {{ options.0.form.undesided.errors }}{{ options.0.form.undesided }} + + + {%trans "Invalid votes" %} + {{ form.invalid.errors }}{{ form.invalid }} + + + {%trans "Votes cast" %} + {{ form.votescast.errors }}{{ form.votescast }} + + + + + {%trans 'Save' %} + + + {%trans 'Apply' %} + + + + {%trans 'Cancel' %} -
{%trans "Results of" %} {{ ballot }}. {%trans "Vote" %}
+ + {%trans 'Save' %} + + + {%trans 'Apply' %} + + + + {%trans 'Cancel' %} -
{% trans "Short description" %}: {{ poll.description }}
- - {%trans 'Apply' %} - - - - {%trans 'Back to election' %} - - {%trans 'Print ballot' %}
+ + {%trans 'Save' %} + + + {%trans 'Apply' %} + + + + {%trans 'Cancel' %} + + +