From e752e05b0fd069b3b747eac9a23962983147cec7 Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Sat, 3 Sep 2011 01:40:06 +0200 Subject: [PATCH] Removed unnecessary parts from poll system. Needs new development in future. --- openslides/poll/templates/poll/base_poll.html | 13 -- openslides/poll/templates/poll/edit.html | 48 ----- .../poll/templates/poll/option_edit.html | 23 --- openslides/poll/templates/poll/overview.html | 30 --- openslides/poll/templates/poll/view.html | 63 ------ openslides/poll/urls.py | 26 --- openslides/poll/views.py | 179 ------------------ openslides/templates/base.html | 4 - openslides/urls.py | 1 - 9 files changed, 387 deletions(-) delete mode 100644 openslides/poll/templates/poll/base_poll.html delete mode 100644 openslides/poll/templates/poll/edit.html delete mode 100644 openslides/poll/templates/poll/option_edit.html delete mode 100644 openslides/poll/templates/poll/overview.html delete mode 100644 openslides/poll/templates/poll/view.html delete mode 100644 openslides/poll/urls.py delete mode 100644 openslides/poll/views.py diff --git a/openslides/poll/templates/poll/base_poll.html b/openslides/poll/templates/poll/base_poll.html deleted file mode 100644 index 2619ccce4..000000000 --- a/openslides/poll/templates/poll/base_poll.html +++ /dev/null @@ -1,13 +0,0 @@ -{% extends "base.html" %} -{% load tags %} - -{% block submenu %} - {% url poll_overview as url_polloverview %} -

{%trans "Polls" %}

- -{% endblock %} diff --git a/openslides/poll/templates/poll/edit.html b/openslides/poll/templates/poll/edit.html deleted file mode 100644 index 80a71d1a6..000000000 --- a/openslides/poll/templates/poll/edit.html +++ /dev/null @@ -1,48 +0,0 @@ -{% extends "poll/base_poll.html" %} -{% block title %}{{ block.super }} - {%trans "Poll" %}{% endblock %} - -{% block content %} - {% if poll %} -

{%trans "Edit poll" %}

- {% else %} -

{%trans "New poll" %}

- {% endif %} - -
{% csrf_token %} - {{ form.as_p }} - - - - - - - {% if poll %} -

{%trans "Options" %}

- - - - - - {% for option in options %} - - - - - {% endfor %} -
{%trans "Option" %}{%trans "Actions" %}
{{ option }} - -
-
- - - - {% endif %} -
- -{% endblock %} diff --git a/openslides/poll/templates/poll/option_edit.html b/openslides/poll/templates/poll/option_edit.html deleted file mode 100644 index 68b6e5de5..000000000 --- a/openslides/poll/templates/poll/option_edit.html +++ /dev/null @@ -1,23 +0,0 @@ -{% extends "poll/base_poll.html" %} -{% block title %}{{ block.super }} - {%trans "Poll" %}{% endblock %} - -{% block content %} - {% if option %} -

{%trans "Edit Poll Option" %}

- {% else %} -

{%trans "New Poll Option" %}

- {% endif %} - -
{% csrf_token %} - {{ form.as_p }} - - - - - -
-{% endblock %} diff --git a/openslides/poll/templates/poll/overview.html b/openslides/poll/templates/poll/overview.html deleted file mode 100644 index d6623c79d..000000000 --- a/openslides/poll/templates/poll/overview.html +++ /dev/null @@ -1,30 +0,0 @@ -{% extends "poll/base_poll.html" %} -{% block title %}{{ block.super }} - {%trans "Polls" %}{% endblock %} - -{% block content %} -

{%trans "Polls" %}

- - - - - {% if perms.poll.can_manage_poll %} - - {% endif %} - - {% for poll in polls %} - - - - {% if perms.poll.can_manage_poll %} - - {% endif %} - - {% empty %} - - - - {% endfor %} -
{%trans "Polls" %}{%trans "Options" %}{%trans "Actions" %}
{{ poll }}{{ poll.get_options|length }} - -
{%trans "No polls available." %}
-{% endblock %} diff --git a/openslides/poll/templates/poll/view.html b/openslides/poll/templates/poll/view.html deleted file mode 100644 index 2ce505b36..000000000 --- a/openslides/poll/templates/poll/view.html +++ /dev/null @@ -1,63 +0,0 @@ -{% extends app %} -{% block title %}{{ block.super }} - {%trans "Poll" %} "{{ poll.title }}"{% endblock %} - -{% block content %} -

{{ poll.title }}

-

{{ poll.description }}

-
{% csrf_token %} - - - - {% if poll.optiondecision %} - - - - {% else %} - - {% endif %} - {% if perms.poll.can_manage_poll %} - - {% endif %} - - {% for option in options %} - - - {% if poll.optiondecision %} - - - - {% else %} - - {% endif %} - {% if perms.poll.can_manage_poll %} - - {% endif %} - - {% endfor %} -
{%trans "Option" %}{%trans "Yes" %}{%trans "No" %}{%trans "Abstention" %}{%trans "Votes" %}{% trans "Actions" %}
{{ option }}{{ option.form.yes.errors }}{{ option.form.yes }}{{ option.form.no.errors }}{{ option.form.no }}{{ option.form.undesided.errors }}{{ option.form.undesided }}{{ option.form.yes.errors }}{{ option.form.yes }}
- - {% if perms.poll.can_manage_poll %} -

- - - {% if not poll.application and not poll.assignment %} - - - - {% endif %} - - -

- {% endif %} -
- -{% endblock %} diff --git a/openslides/poll/urls.py b/openslides/poll/urls.py deleted file mode 100644 index e0c6c5bfd..000000000 --- a/openslides/poll/urls.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -""" - openslides.poll.urls - ~~~~~~~~~~~~~~~~~~~~ - - URL list for the poll app. - - :copyright: 2011 by the OpenSlides team, see AUTHORS. - :license: GNU GPL, see LICENSE for more details. -""" - -from django.conf.urls.defaults import * - -urlpatterns = patterns('poll.views', - url(r'^poll/$', 'get_overview', name='poll_overview'), - url(r'^poll/(?P\d+)$', 'view', name='poll_view'), - url(r'^poll/new$', 'edit', name='poll_new'), - url(r'^poll/(?P\d+)/edit$', 'edit', name='poll_edit'), - url(r'^poll/(?P\d+)/del$', 'delete', name='poll_delete'), - url(r'^poll/option/new$', 'option_edit', name='option_new'), - url(r'^poll/(?P\d+)/option/new$', 'option_edit', name='option_new_fixpoll'), - url(r'^poll/option/(?P\d+)/edit$', 'option_edit', name='option_edit'), - url(r'^poll/option/(?P\d+)/del$', 'option_delete', name='option_delete'), - # url(r'^poll/pdf/(?P\d+)$', 'print_poll', name='poll_print'), -) diff --git a/openslides/poll/views.py b/openslides/poll/views.py deleted file mode 100644 index 4211a8eb6..000000000 --- a/openslides/poll/views.py +++ /dev/null @@ -1,179 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -""" - openslides.poll.views - ~~~~~~~~~~~~~~~~~~~~~ - - Views for the poll app. - - :copyright: 2011 by the OpenSlides team, see AUTHORS. - :license: GNU GPL, see LICENSE for more details. -""" - -from django.shortcuts import render_to_response, redirect -from django.template import RequestContext -from django.core.urlresolvers import reverse -from django.contrib import messages -from django.utils.translation import ugettext as _ - -from poll.models import Poll, Option -from poll.forms import PollForm, OptionForm, OptionResultForm -from utils.utils import template, permission_required, gen_confirm_form -#from utils.pdf import print_poll - - -@permission_required('poll.can_view_poll') -@template('poll/overview.html') -def get_overview(request): - query = Poll.objects.filter(assignment=None).filter(application=None) - try: - sort = request.GET['sort'] - if sort in ['title']: - query = query.order_by(sort) - except KeyError: - pass - if 'reverse' in request.GET: - query = query.reverse() - - polls = query.all() - return { - 'polls': polls, - } - - -@template('poll/view.html') -@permission_required('poll.can_view_poll') -def view(request, poll_id): - poll = Poll.objects.get(pk=poll_id) - if poll.application and not request.path.startswith('/application'): - return redirect(reverse('application_poll_view', args=[poll_id])) - if poll.assignment and not request.path.startswith('/assignment'): - return redirect(reverse('assignment_poll_view', args=[poll_id, 0])) - if not (poll.application or poll.assignment) and not request.path.startswith('/poll'): - return redirect(reverse('poll_view', args=[poll_id])) - - options = poll.option_set.all() - if request.user.has_perm('poll.can_manage_poll'): - success = 0 - for option in options: - if request.method == 'POST': - option.form = OptionResultForm(request.POST, prefix="o%d" % option.id) - if option.form.is_valid(): - option.voteyes = option.form.cleaned_data['yes'] - option.voteno = option.form.cleaned_data['no'] or 0 - option.voteundesided = option.form.cleaned_data['undesided'] or 0 - option.save() - success = success + 1 - else: - messages.error(request, _('Please check the form for errors.')) - else: - option.form = OptionResultForm(initial={ - 'yes': option.voteyes, - 'no': option.voteno, - 'undesided': option.voteundesided, - }, prefix="o%d" % option.id) - if request.method == 'POST' and success == options.count(): - messages.success(request, _("Votes are successfully saved.") ) - - return { - 'poll': poll, - 'options': options, - } - - -@permission_required('poll.can_manage_poll') -@template('poll/edit.html') -def edit(request, poll_id=None): - """ - View to create and edit a poll object. - """ - if poll_id is not None: - poll = Poll.objects.get(id=poll_id) - else: - poll = None - - if request.method == 'POST': - if poll_id is None: - form = PollForm(request.POST) - else: - form = PollForm(request.POST, instance=poll) - - if form.is_valid(): - poll = form.save() - if poll_id is None: - messages.success(request, _('New poll was successfully created.')) - else: - messages.success(request, _('Poll was successfully modified.')) - return redirect(reverse("poll_overview")) - messages.error(request, _('Please check the form for errors.')) - else: - if poll_id is None: - form = PollForm() - else: - form = PollForm(instance=poll) - return { - 'form': form, - 'poll': poll, - } - - -@permission_required('poll.can_manage_poll') -def delete(request, poll_id): - poll = Poll.objects.get(id=poll_id) - if request.method == 'POST': - poll.delete() - messages.success(request, _('Poll %s was successfully deleted.') % poll) - else: - gen_confirm_form(request, _('Do you really want to delete %s?') % poll, reverse('poll_delete', args=[poll_id])) - return redirect(reverse('poll_overview')) - - -@permission_required('poll.can_manage_poll') -@template('poll/option_edit.html') -def option_edit(request, poll_id=None, option_id=None): - """ - View to create and edit options of a poll object. - """ - if option_id is not None: - option = Option.objects.get(id=option_id) - else: - option = None - - if request.method == 'POST': - if option_id is None: - form = OptionForm(request.POST) - else: - form = OptionForm(request.POST, instance=option) - - if form.is_valid(): - option = form.save() - if option_id is None: - messages.success(request, _('New option was successfully created.')) - else: - messages.success(request, _('Option was successfully modified.')) - return redirect(reverse("poll_overview")) - messages.error(request, _('Please check the form for errors.')) - else: - if option_id is None: - if poll_id is None: - form = OptionForm() - else: - poll = Poll.objects.get(id=poll_id) - form = OptionForm(initial={'poll': poll}) - else: - form = OptionForm(instance=option) - return { - 'form': form, - 'option': option, - } - - -@permission_required('poll.can_manage_poll') -def option_delete(request, option_id): - option = Option.objects.get(id=option_id) - if request.method == 'POST': - option.delete() - messages.success(request, _('Option %s was successfully deleted.') % option) - else: - gen_confirm_form(request, _('Do you really want to delete the option %s?') % option_id, reverse('option_delete', args=[option_id])) - return redirect(reverse('poll_overview')) diff --git a/openslides/templates/base.html b/openslides/templates/base.html index e76cc8f3d..6fb26b447 100644 --- a/openslides/templates/base.html +++ b/openslides/templates/base.html @@ -55,10 +55,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/urls.py b/openslides/urls.py index 7da6d1a0f..ee6cb8130 100644 --- a/openslides/urls.py +++ b/openslides/urls.py @@ -21,7 +21,6 @@ urlpatterns = patterns('', (r'', include('openslides.agenda.urls')), (r'', include('openslides.application.urls')), (r'', include('openslides.participant.urls')), - (r'', include('openslides.poll.urls')), (r'', include('openslides.assignment.urls')), (r'', include('openslides.system.urls')), (r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_DOC_ROOT}),