now it is possible to create a item, witch is realted to another object, for example an application.
This commit is contained in:
parent
e23c195388
commit
4e904c7356
@ -25,7 +25,7 @@ class ItemForm(ModelForm, CssClassMixin):
|
|||||||
parent = TreeNodeChoiceField(queryset=Item.objects.all(), label=_("Parent item"), required=False)
|
parent = TreeNodeChoiceField(queryset=Item.objects.all(), label=_("Parent item"), required=False)
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Item
|
model = Item
|
||||||
exclude = ('closed', 'weight')
|
exclude = ('closed', 'weight', 'releated_sid')
|
||||||
|
|
||||||
|
|
||||||
def genweightchoices():
|
def genweightchoices():
|
||||||
|
@ -22,7 +22,7 @@ from mptt.models import MPTTModel, TreeForeignKey
|
|||||||
from config.models import config
|
from config.models import config
|
||||||
|
|
||||||
from projector.projector import SlideMixin
|
from projector.projector import SlideMixin
|
||||||
from projector.api import register_slidemodel
|
from projector.api import register_slidemodel, get_slide_from_sid
|
||||||
|
|
||||||
from utils.translation_ext import ugettext as _
|
from utils.translation_ext import ugettext as _
|
||||||
|
|
||||||
@ -35,12 +35,26 @@ class Item(MPTTModel, SlideMixin):
|
|||||||
"""
|
"""
|
||||||
prefix = 'item'
|
prefix = 'item'
|
||||||
|
|
||||||
title = models.CharField(max_length=100, verbose_name=_("Title"))
|
title = models.CharField(null=True, max_length=100, verbose_name=_("Title"))
|
||||||
text = models.TextField(null=True, blank=True, verbose_name=_("Text"))
|
text = models.TextField(null=True, blank=True, verbose_name=_("Text"))
|
||||||
comment = models.TextField(null=True, blank=True, verbose_name=_("Comment"))
|
comment = models.TextField(null=True, blank=True, verbose_name=_("Comment"))
|
||||||
closed = models.BooleanField(default=False, verbose_name=_("Closed"))
|
closed = models.BooleanField(default=False, verbose_name=_("Closed"))
|
||||||
weight = models.IntegerField(default=0, verbose_name=_("Weight"))
|
weight = models.IntegerField(default=0, verbose_name=_("Weight"))
|
||||||
parent = TreeForeignKey('self', null=True, blank=True, related_name='children')
|
parent = TreeForeignKey('self', null=True, blank=True, related_name='children')
|
||||||
|
releated_sid = models.CharField(null=True, blank=True, max_length=64)
|
||||||
|
|
||||||
|
def get_releated_slide(self):
|
||||||
|
return get_slide_from_sid(self.releated_sid, True)
|
||||||
|
|
||||||
|
def get_title(self):
|
||||||
|
if self.releated_sid is None:
|
||||||
|
return self.title
|
||||||
|
return self.get_releated_slide().get_agenda_title()
|
||||||
|
|
||||||
|
def get_text(self):
|
||||||
|
if self.releated_sid is None:
|
||||||
|
return self.text
|
||||||
|
return self.get_releated_slide().get_agenda_text()
|
||||||
|
|
||||||
|
|
||||||
def slide(self):
|
def slide(self):
|
||||||
@ -49,7 +63,7 @@ class Item(MPTTModel, SlideMixin):
|
|||||||
"""
|
"""
|
||||||
data = {
|
data = {
|
||||||
'item': self,
|
'item': self,
|
||||||
'title': self.title,
|
'title': self.get_title(),
|
||||||
'template': 'projector/AgendaText.html',
|
'template': 'projector/AgendaText.html',
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
@ -105,7 +119,7 @@ class Item(MPTTModel, SlideMixin):
|
|||||||
return ('item_delete', [str(self.id)])
|
return ('item_delete', [str(self.id)])
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.title
|
return self.get_title()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
permissions = (
|
permissions = (
|
||||||
@ -114,7 +128,7 @@ class Item(MPTTModel, SlideMixin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
class MPTTMeta:
|
class MPTTMeta:
|
||||||
order_insertion_by = ['weight', 'title']
|
order_insertion_by = ['weight']
|
||||||
|
|
||||||
|
|
||||||
register_slidemodel(Item, control_template='agenda/control_item.html')
|
register_slidemodel(Item, control_template='agenda/control_item.html')
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
{% block title %}{{ block.super }} – {{ item.title }}{% endblock %}
|
{% block title %}{{ block.super }} – {{ item.title }}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>{{ item.title }}</h1>
|
<h1>{{ item }}</h1>
|
||||||
<p>{{ item.text|safe|linebreaks }}</p>
|
<p>{{ item.get_text|safe|linebreaks }}</p>
|
||||||
|
|
||||||
{% if perms.agenda.can_manage_agenda and item.comment %}
|
{% if perms.agenda.can_manage_agenda and item.comment %}
|
||||||
<h2>{% trans "Comment" %}</h2>
|
<h2>{% trans "Comment" %}</h2>
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block title %}{{ block.super }} - {{ item.title }}{% endblock %}
|
{% block title %}{{ block.super }} - {{ item }}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if item.text %}
|
{% if item.get_text %}
|
||||||
<h1>{{ item.title }}</h1>
|
<h1>{{ item }}</h1>
|
||||||
{{ item.text|safe|linebreaks }}
|
{{ item.get_text|safe|linebreaks }}
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="item_fullscreen">{{ item.title }}</div>
|
<div class="item_fullscreen">{{ item }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -162,9 +162,9 @@ class AgendaPDF(PDFView):
|
|||||||
ancestors = item.get_ancestors()
|
ancestors = item.get_ancestors()
|
||||||
if ancestors:
|
if ancestors:
|
||||||
space = " " * ancestors.count()
|
space = " " * ancestors.count()
|
||||||
story.append(Paragraph("%s%s" % (space, item.title), stylesheet['Subitem']))
|
story.append(Paragraph("%s%s" % (space, item.get_title()), stylesheet['Subitem']))
|
||||||
else:
|
else:
|
||||||
story.append(Paragraph(item.title, stylesheet['Item']))
|
story.append(Paragraph(item.get_title(), stylesheet['Item']))
|
||||||
|
|
||||||
|
|
||||||
class Config(FormView):
|
class Config(FormView):
|
||||||
|
@ -399,6 +399,12 @@ class Application(models.Model, SlideMixin):
|
|||||||
self.log += "\n"
|
self.log += "\n"
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
|
def get_agenda_title(self):
|
||||||
|
return self.title
|
||||||
|
|
||||||
|
def get_agenda_text(self):
|
||||||
|
return 'TODO'
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
"""
|
"""
|
||||||
if name is title, text, reason or time,
|
if name is title, text, reason or time,
|
||||||
|
@ -26,7 +26,10 @@
|
|||||||
<li><a href="{% url application_delete application.id %}">{%trans 'Delete Application' %}</a></li>
|
<li><a href="{% url application_delete application.id %}">{%trans 'Delete Application' %}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.projector.can_manage_projector %}
|
{% if perms.projector.can_manage_projector %}
|
||||||
<li><a href="{% url application_activate_item application.id %}"><img src="{% static 'images/icons/video-projector.png' %}"> {%trans 'Show Application' %}</a></li>
|
<li><a href="{% url projector_activate_slide application.sid %}"><img src="{% static 'images/icons/video-projector.png' %}">{%trans 'Show Application' %}</a></li>
|
||||||
|
{% endif %}
|
||||||
|
{% if perms.agenda.can_manage_agenda %}
|
||||||
|
<li><a href="{% url application_create_agenda application.id %}">{%trans 'Create Agendaitem for this application' %}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li><a href="{% url print_application application.id %}"><img src="{% static 'images/icons/application-pdf.png' %}"> {%trans 'Application as PDF' %}</a></li>
|
<li><a href="{% url print_application application.id %}"><img src="{% static 'images/icons/application-pdf.png' %}"> {%trans 'Application as PDF' %}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -10,10 +10,10 @@
|
|||||||
:license: GNU GPL, see LICENSE for more details.
|
:license: GNU GPL, see LICENSE for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from django.conf.urls.defaults import *
|
from django.conf.urls.defaults import url, patterns
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
from application.views import ViewPoll, ApplicationPDF, ApplicationPollPDF
|
from application.views import ViewPoll, ApplicationPDF, ApplicationPollPDF, CreateAgendaItem
|
||||||
|
|
||||||
urlpatterns = patterns('application.views',
|
urlpatterns = patterns('application.views',
|
||||||
url(r'^$',
|
url(r'^$',
|
||||||
@ -26,6 +26,11 @@ urlpatterns = patterns('application.views',
|
|||||||
name='application_view',
|
name='application_view',
|
||||||
),
|
),
|
||||||
|
|
||||||
|
url(r'^(?P<application_id>\d+)/agenda/$',
|
||||||
|
CreateAgendaItem.as_view(),
|
||||||
|
name='application_create_agenda',
|
||||||
|
),
|
||||||
|
|
||||||
url(r'^(?P<application_id>\d+)/newest/$',
|
url(r'^(?P<application_id>\d+)/newest/$',
|
||||||
'view',
|
'view',
|
||||||
{'newest': True},
|
{'newest': True},
|
||||||
@ -97,11 +102,6 @@ urlpatterns = patterns('application.views',
|
|||||||
name='application_unsupport',
|
name='application_unsupport',
|
||||||
),
|
),
|
||||||
|
|
||||||
url(r'^(?P<application_id>\d+)/set_active/$',
|
|
||||||
'set_active',
|
|
||||||
name='application_activate_item',
|
|
||||||
),
|
|
||||||
|
|
||||||
url(r'^(?P<application_id>\d+)/gen_poll/$',
|
url(r'^(?P<application_id>\d+)/gen_poll/$',
|
||||||
'gen_poll',
|
'gen_poll',
|
||||||
name='application_gen_poll',
|
name='application_gen_poll',
|
||||||
|
@ -29,7 +29,6 @@ from django.core.urlresolvers import reverse
|
|||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
from django.utils.translation import ungettext
|
from django.utils.translation import ungettext
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.views.generic.base import RedirectView
|
|
||||||
|
|
||||||
from reportlab.lib import colors
|
from reportlab.lib import colors
|
||||||
from reportlab.lib.units import cm
|
from reportlab.lib.units import cm
|
||||||
@ -38,7 +37,7 @@ from reportlab.platypus import PageBreak, Paragraph, Spacer, Table, TableStyle
|
|||||||
from config.models import config
|
from config.models import config
|
||||||
from settings import SITE_ROOT
|
from settings import SITE_ROOT
|
||||||
from utils.pdf import stylesheet
|
from utils.pdf import stylesheet
|
||||||
from utils.views import PDFView
|
from utils.views import PDFView, RedirectView
|
||||||
|
|
||||||
from agenda.models import Item
|
from agenda.models import Item
|
||||||
|
|
||||||
@ -377,13 +376,6 @@ def unsupport(request, application_id):
|
|||||||
return redirect(reverse('application_view', args=[application_id]))
|
return redirect(reverse('application_view', args=[application_id]))
|
||||||
|
|
||||||
|
|
||||||
@permission_required('application.can_manage_application')
|
|
||||||
def set_active(request, application_id):
|
|
||||||
application = Application.objects.get(pk=application_id)
|
|
||||||
application.set_active()
|
|
||||||
return redirect(reverse('application_view', args=[application_id]))
|
|
||||||
|
|
||||||
|
|
||||||
@permission_required('application.can_manage_application')
|
@permission_required('application.can_manage_application')
|
||||||
@template('application/view.html')
|
@template('application/view.html')
|
||||||
def gen_poll(request, application_id):
|
def gen_poll(request, application_id):
|
||||||
@ -577,6 +569,18 @@ def application_import(request):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class CreateAgendaItem(RedirectView):
|
||||||
|
permission_required = 'agenda.can_manage_agenda'
|
||||||
|
|
||||||
|
def pre_redirect(self, request, *args, **kwargs):
|
||||||
|
self.application = Application.objects.get(pk=kwargs['application_id'])
|
||||||
|
self.item = Item(releated_sid=self.application.sid)
|
||||||
|
self.item.save()
|
||||||
|
|
||||||
|
def get_redirect_url(self, **kwargs):
|
||||||
|
return reverse('item_view', args=[self.item.id])
|
||||||
|
|
||||||
|
|
||||||
class ApplicationPDF(PDFView):
|
class ApplicationPDF(PDFView):
|
||||||
permission_required = 'application.can_manage_application'
|
permission_required = 'application.can_manage_application'
|
||||||
top_space = 0
|
top_space = 0
|
||||||
|
@ -20,14 +20,17 @@ def split_sid(sid):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_slide_from_sid(sid):
|
def get_slide_from_sid(sid, element=False):
|
||||||
try:
|
try:
|
||||||
key, id = split_sid(sid)
|
key, id = split_sid(sid)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if id is not None:
|
if id is not None:
|
||||||
return SLIDE[key].model.objects.get(pk=id).slide()
|
object = SLIDE[key].model.objects.get(pk=id)
|
||||||
|
if element:
|
||||||
|
return object
|
||||||
|
return object.slide()
|
||||||
try:
|
try:
|
||||||
return SLIDE[key].func()
|
return SLIDE[key].func()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
@ -127,7 +127,7 @@ class RedirectView(PermissionMixin, _RedirectView):
|
|||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
self.pre_redirect( request, *args, **kwargs)
|
self.pre_redirect(request, *args, **kwargs)
|
||||||
elif request.method == 'POST':
|
elif request.method == 'POST':
|
||||||
self.pre_post_redirect(request, *args, **kwargs)
|
self.pre_post_redirect(request, *args, **kwargs)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user