present a poll

This commit is contained in:
Oskar Hahn 2012-02-15 12:36:50 +01:00
parent bc05b78648
commit c4874ae6a0
9 changed files with 47 additions and 11 deletions

View File

@ -1,4 +1 @@
from projector.api import register_slidefunc
from agenda.slides import agenda_show
register_slidefunc('agenda_show', agenda_show)

View File

@ -152,4 +152,11 @@ ItemText = Item # ItemText is Depricated
register_slidemodel(Item)
# TODO: put this in anouther file
from projector.api import register_slidefunc
from agenda.slides import agenda_show
register_slidefunc('agenda_show', agenda_show)

View File

@ -501,3 +501,6 @@ class ApplicationOption(BaseOption):
class ApplicationPoll(BasePoll):
option_class = ApplicationOption
def get_application(self):
return self.get_options()[0].application

View File

@ -72,6 +72,7 @@
{% if poll.has_vote %}</a>{% endif %}
<a href="{% url application_poll_delete poll.id %}"><img src="/static/images/icons/edit-delete.png" title="{% trans 'Delete Vote' %}"></a>
{% endif %}
<a href="{% url application_poll_activate poll.id %}">{% trans 'project' %}</a>
<br>
{% if poll.has_vote %}
{% for option in poll.options %}

View File

@ -13,7 +13,7 @@
from django.conf.urls.defaults import *
from django.utils.translation import ugettext as _
from application.views import ViewPoll
from application.views import ViewPoll, ActivatePoll
urlpatterns = patterns('application.views',
@ -83,7 +83,12 @@ urlpatterns = patterns('application.views',
url(r'^application/poll/(?P<poll_id>\d+)$',
ViewPoll.as_view(),
name='application_poll_view'
name='application_poll_view',
),
url(r'^application/poll/(?P<poll_id>\d+)/activate$',
ActivatePoll.as_view(),
name='application_poll_activate',
),
url(r'^application/poll/(?P<poll_id>\d+)/del$', 'delete_poll', \

View File

@ -22,6 +22,7 @@ from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _
from django.utils.translation import ungettext
from django.db import transaction
from django.views.generic.base import RedirectView
from system import config
@ -424,7 +425,7 @@ class ViewPoll(PollFormView):
def get_context_data(self, **kwargs):
context = super(ViewPoll, self).get_context_data()
self.application = self.poll.get_options()[0].application
self.application = self.poll.get_application()
context['application'] = self.application
return context
@ -434,6 +435,20 @@ class ViewPoll(PollFormView):
return ''
class ActivatePoll(RedirectView):
permanent = False
def get_redirect_url(self, **kwargs):
poll = ApplicationPoll.objects.get(pk=self.kwargs['poll_id'])
application = poll.get_application()
return reverse('application_view', args=[application.id])
def get(self, request, *args, **kwargs):
self.poll = ApplicationPoll.objects.get(pk=self.kwargs['poll_id'])
self.poll.set_active()
return super(ActivatePoll, self).get(request, *args, **kwargs)
@permission_required('application.can_manage_application')
def permit_version(request, aversion_id):
aversion = AVersion.objects.get(pk=aversion_id)

View File

@ -1,4 +1,5 @@
from django import forms
from django.utils.translation import ugettext as _
class OptionForm(forms.Form):
def __init__(self, *args, **kwargs):

View File

@ -13,8 +13,10 @@
from django.db import models
from django.utils.translation import ugettext as _
#from projector.api import register_slidemodel
#from projector.models import Slide
from projector.api import register_slidemodel
from projector.models import Slide
from poll.forms import OptionForm
class BaseOption(models.Model):
@ -42,7 +44,7 @@ class Vote(models.Model):
value = models.CharField(max_length=255, null=True)
class BasePoll(models.Model): #, Slide):
class BasePoll(models.Model, Slide):
prefix = 'BasePoll'
description = models.TextField(null=True, blank=True, verbose_name = _("Description"))
@ -97,9 +99,13 @@ class BasePoll(models.Model): #, Slide):
form = self.get_vote_form(formid=option.id, **kwargs)
form.option = option
forms.append(form)
return forms
def slide(self):
data = super(BasePoll, self).slide()
# data['template'] = 'projector/TODO.html'
return data
#register_slidemodel(BasePoll)
register_slidemodel(BasePoll)

View File

@ -13,6 +13,7 @@ class Slide(object):
return {
'slide': self,
'title': 'dummy-title',
'template': 'projector/default.html',
}
@property