Removed unnecessary parts from poll system. Needs new development in future.

This commit is contained in:
Emanuel Schuetze 2011-09-03 01:40:06 +02:00
parent ed40977403
commit e752e05b0f
9 changed files with 0 additions and 387 deletions

View File

@ -1,13 +0,0 @@
{% extends "base.html" %}
{% load tags %}
{% block submenu %}
{% url poll_overview as url_polloverview %}
<h4 class="sectiontitle">{%trans "Polls" %}</h4>
<ul>
<li class="{% if request.path == url_polloverview %}selected{% endif %}"><a href="{% url poll_overview %}">{%trans "All polls" %}</a></li>
{% if perms.poll.can_manage_poll %}
<li class="{% active request '/poll/new' %}"><a href="{% url poll_new %}">{%trans "New poll" %}</a></li>
{% endif %}
</ul>
{% endblock %}

View File

@ -1,48 +0,0 @@
{% extends "poll/base_poll.html" %}
{% block title %}{{ block.super }} - {%trans "Poll" %}{% endblock %}
{% block content %}
{% if poll %}
<h1>{%trans "Edit poll" %}</h1>
{% else %}
<h1>{%trans "New poll" %}</h1>
{% endif %}
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
<button type="submit">
<span class="icon ok">{%trans 'Save' %}</span>
</button>
<a href='{% url poll_overview %}'>
<button type="button">
<span class="icon cancel">{%trans 'Cancel' %}</span>
</button>
</a>
{% if poll %}
<h3>{%trans "Options" %}</h3>
<table class="table">
<tr>
<th>{%trans "Option" %}</th>
<th>{%trans "Actions" %}</th>
</tr>
{% for option in options %}
<tr>
<td>{{ option }}</td>
<td><a href="{% url option_edit option.id %}"><img src="/static/images/icons/document-edit.png" title="{%trans 'Edit option' %}"></a>
<a href="{% url option_delete option.id %}"><img src="/static/images/icons/edit-delete.png" title="{%trans 'Delete option' %}"></a>
</td>
</tr>
{% endfor %}
</table>
<br>
<a href='{% url option_new_fixpoll poll.id %}'>
<button type="button">
<span class="icon add">{%trans 'Add new Option' %}</span>
</button>
</a>
{% endif %}
</form>
{% endblock %}

View File

@ -1,23 +0,0 @@
{% extends "poll/base_poll.html" %}
{% block title %}{{ block.super }} - {%trans "Poll" %}{% endblock %}
{% block content %}
{% if option %}
<h1>{%trans "Edit Poll Option" %}</h1>
{% else %}
<h1>{%trans "New Poll Option" %}</h1>
{% endif %}
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
<button type="submit">
<span class="icon ok">{%trans 'Save' %}</span>
</button>
<a href='{% url poll_overview %}'>
<button type="button">
<span class="icon cancel">{%trans 'Cancel' %}</span>
</button>
</a>
</form>
{% endblock %}

View File

@ -1,30 +0,0 @@
{% extends "poll/base_poll.html" %}
{% block title %}{{ block.super }} - {%trans "Polls" %}{% endblock %}
{% block content %}
<h1>{%trans "Polls" %}</h1>
<table>
<tr>
<th><a href="?sort=title{% if 'title' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{%trans "Polls" %}</a></th>
<th>{%trans "Options" %}</th>
{% if perms.poll.can_manage_poll %}
<th>{%trans "Actions" %}</th>
{% endif %}
</tr>
{% for poll in polls %}
<tr class="{% cycle '' 'odd' %}">
<td><a href="{% url poll_view poll.id %}">{{ poll }}</a></td>
<td>{{ poll.get_options|length }}</td>
{% if perms.poll.can_manage_poll %}
<td><a href="{% url poll_edit poll.id %}"><img src="/static/images/icons/document-edit.png" title="{%trans 'Edit poll' %}"></a>
<a href="{% url poll_delete poll.id %}"><img src="/static/images/icons/edit-delete.png" title="{%trans 'Delete poll' %}"></a>
</td>
{% endif %}
</tr>
{% empty %}
<tr>
<td colspan="4"><i>{%trans "No polls available." %}</i></td>
</tr>
{% endfor %}
</table>
{% endblock %}

View File

@ -1,63 +0,0 @@
{% extends app %}
{% block title %}{{ block.super }} - {%trans "Poll" %} "{{ poll.title }}"{% endblock %}
{% block content %}
<h1>{{ poll.title }}</h1>
<p>{{ poll.description }}</p>
<form action="" method="post">{% csrf_token %}
<table class="table">
<tr>
<th>{%trans "Option" %}</th>
{% if poll.optiondecision %}
<th>{%trans "Yes" %}</th>
<th>{%trans "No" %}</th>
<th>{%trans "Abstention" %}</th>
{% else %}
<th>{%trans "Votes" %}</th>
{% endif %}
{% if perms.poll.can_manage_poll %}
<th>{% trans "Actions" %}</th>
{% endif %}
</tr>
{% for option in options %}
<tr>
<td>{{ option }}</td>
{% if poll.optiondecision %}
<td>{{ option.form.yes.errors }}{{ option.form.yes }}</td>
<td>{{ option.form.no.errors }}{{ option.form.no }}</td>
<td>{{ option.form.undesided.errors }}{{ option.form.undesided }}</td>
{% else %}
<td>{{ option.form.yes.errors }}{{ option.form.yes }}</td>
{% endif %}
{% if perms.poll.can_manage_poll %}
<td><a href="{% url option_delete option.id %}"><img src="/static/images/icons/edit-delete.png" title="{%trans 'Delete option' %}"></a></td>
{% endif %}
</tr>
{% endfor %}
</table>
{% if perms.poll.can_manage_poll %}
<p>
<button type="submit">
<span class="icon ok">{%trans 'Apply' %}</span>
</button>
{% if not poll.application and not poll.assignment %}
<a href='{% url option_new_fixpoll poll.id %}'>
<button type="button">
<span class="icon add">{%trans 'Add new Option' %}</span>
</button>
</a>
{% endif %}
<!--print pdf
<a href=' url poll_print poll.id '>
<button type="button">
<span class="icon pdf">{%trans 'Print Poll' %}</span>
</button>
</a>-->
</p>
{% endif %}
</form>
{% endblock %}

View File

@ -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<poll_id>\d+)$', 'view', name='poll_view'),
url(r'^poll/new$', 'edit', name='poll_new'),
url(r'^poll/(?P<poll_id>\d+)/edit$', 'edit', name='poll_edit'),
url(r'^poll/(?P<poll_id>\d+)/del$', 'delete', name='poll_delete'),
url(r'^poll/option/new$', 'option_edit', name='option_new'),
url(r'^poll/(?P<poll_id>\d+)/option/new$', 'option_edit', name='option_new_fixpoll'),
url(r'^poll/option/(?P<option_id>\d+)/edit$', 'option_edit', name='option_edit'),
url(r'^poll/option/(?P<option_id>\d+)/del$', 'option_delete', name='option_delete'),
# url(r'^poll/pdf/(?P<poll_id>\d+)$', 'print_poll', name='poll_print'),
)

View File

@ -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 <b>%s</b> was successfully deleted.') % poll)
else:
gen_confirm_form(request, _('Do you really want to delete <b>%s</b>?') % 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 <b>%s</b> was successfully deleted.') % option)
else:
gen_confirm_form(request, _('Do you really want to delete the option <b>%s</b>?') % option_id, reverse('option_delete', args=[option_id]))
return redirect(reverse('poll_overview'))

View File

@ -55,10 +55,6 @@
<li class="{% active request '/assignment' %}">
<a href="{% url assignment_overview %}" title="">{%trans "Elections" %}</a></li>
{% endif %}
{% if perms.poll.can_view_poll or perms.poll.can_manage_poll %}
<li class="{% active request '/poll' %}">
<a href="{% url poll_overview %}" title="">{%trans "Polls" %}</a></li>
{% endif %}
{% if perms.participant.can_view_participants or perms.participant.can_manage_participants %}
<li class="{% active request '/participant' %}">
<a href="{% url user_overview %}" title="">{%trans "Participants" %}</a></li>

View File

@ -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<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_DOC_ROOT}),