created model for pojector slides

This commit is contained in:
Oskar Hahn 2012-03-12 18:22:18 +01:00
parent a04c5fff1d
commit 7a63ec6f10
9 changed files with 193 additions and 129 deletions

View File

@ -22,7 +22,7 @@ from mptt.models import MPTTModel, TreeForeignKey
from system import config from system import config
from projector.models import SlideMixin from projector.projector import SlideMixin
from projector.api import register_slidemodel from projector.api import register_slidemodel
from agenda.api import is_summary from agenda.api import is_summary
@ -126,7 +126,6 @@ class Item(MPTTModel, SlideMixin):
permissions = ( permissions = (
('can_see_agenda', "Can see agenda"), ('can_see_agenda', "Can see agenda"),
('can_manage_agenda', "Can manage agenda"), ('can_manage_agenda', "Can manage agenda"),
('can_see_projector', "Can see projector"),
) )
class MPTTMeta: class MPTTMeta:

View File

@ -1,5 +1,5 @@
from system import config from system import config
from projector.models import SLIDE, Slide from projector import SLIDE, Slide
def get_slide_from_sid(sid): def get_slide_from_sid(sid):

View File

@ -1,62 +1,26 @@
from django.db import models from django.db import models
from django.utils.translation import ugettext as _
from api import register_slidemodel
from projector import SlideMixin
from system import config from system import config
SLIDE = {}
class SlideMixin(object): class ProjectorSlide(models.Model, SlideMixin):
prefix = 'ProjectorSlide'
def slide(self): title = models.CharField(max_length=100, verbose_name=_("Title"))
""" text = models.TextField(null=True, blank=True, verbose_name=_("Text"))
Return a map with all Data for a Slide weight = models.IntegerField(default=0, verbose_name=_("Weight"))
"""
return {
'slide': self,
'title': 'dummy-title',
'template': 'projector/default.html',
}
@property def __unicode__(self):
def sid(self): return self.title
"""
Return the sid from this Slide
"""
for key, value in SLIDE.iteritems():
if type(self) == value.model:
return "%s-%d" % (key, self.id)
return None
@property class Meta:
def active(self): permissions = (
""" ('can_manage_projector', "Can manage the projector"),
Return True, if the the slide is the active one. ('can_see_projector', "Can see projector"),
""" )
from projector.api import get_active_slide
return True if get_active_slide(only_sid=True) == self.sid else False
def set_active(self): register_slidemodel(ProjectorSlide, category=_('Projector'), model_name=_('Projector Slide'))
"""
Appoint this item as the active one.
"""
config["presentation"] = "%s-%d" % (self.prefix, self.id)
class Slide(object):
def __init__(self, model_slide=False, func=None, model=None, category=None, key=None, model_name=''):
"""
model_slide: Boolean if the value is a Model.
func: The function to call. Only if modelslide is False.
model: The model. Only if modelslide is True.
model_name: The name shown for the model.
category: The category to show this Slide.
key: the key in the slide object to find myself.
"""
self.model_slide = model_slide
self.func = func
self.model = model
self.model_name = model_name
self.category = category
self.key = key
def get_items(self):
return self.model.objects.all()

View File

@ -0,0 +1,60 @@
from system import config
SLIDE = {}
class SlideMixin(object):
def slide(self):
"""
Return a map with all Data for a Slide
"""
return {
'slide': self,
'title': 'dummy-title',
'template': 'projector/default.html',
}
@property
def sid(self):
"""
Return the sid from this Slide
"""
for key, value in SLIDE.iteritems():
if type(self) == value.model:
return "%s-%d" % (key, self.id)
return None
@property
def active(self):
"""
Return True, if the the slide is the active one.
"""
from api import get_active_slide
return True if get_active_slide(only_sid=True) == self.sid else False
def set_active(self):
"""
Appoint this item as the active one.
"""
config["presentation"] = "%s-%d" % (self.prefix, self.id)
class Slide(object):
def __init__(self, model_slide=False, func=None, model=None, category=None, key=None, model_name=''):
"""
model_slide: Boolean if the value is a Model.
func: The function to call. Only if modelslide is False.
model: The model. Only if modelslide is True.
model_name: The name shown for the model.
category: The category to show this Slide.
key: the key in the slide object to find myself.
"""
self.model_slide = model_slide
self.func = func
self.model = model
self.model_name = model_name
self.category = category
self.key = key
def get_items(self):
return self.model.objects.all()

View File

@ -3,13 +3,16 @@
{% load tags %} {% load tags %}
{% load i18n %} {% load i18n %}
{% block title %}foasdfasdfafs {% endblock %}
{% block submenu %} {% block submenu %}
{% url item_overview as url_itemoverview %} {% url item_overview as url_itemoverview %}
{% url item_new as url_itemnew %} {% url item_new as url_itemnew %}
<h4 class="sectiontitle">{%trans "Projector" %}</h4> <h4 class="sectiontitle">{%trans "Projector" %}</h4>
<ul> <ul>
{% if perms.agenda.can_see_projector %} {% if perms.projector.can_see_projector %}
<li><a href="{% url projector_show %}"><img src="/static/images/icons/video-projector.png"> {%trans 'Projector view' %}</a></li> <li><a href="{% url projector_new %}">{% trans 'New Slide' %}</a></li>
<li><a href="{% url projector_show %}"><img src="/static/images/icons/video-projector.png"> {% trans 'Projector view' %}</a></li>
{% endif %} {% endif %}
</ul> </ul>
{% endblock %} {% endblock %}

View File

@ -50,79 +50,78 @@
{% block content %} {% block content %}
<h1>{% trans 'Projector' %}</h1> <h1>{% trans 'Projector' %}</h1>
<div style="text-align: right; padding: 0 5px 5px 0; margin-top:-20px;">
<!-- countdown -->
<input type="checkbox" name="countdown" onchange="document.location='{% if countdown_visible %}{% url countdown_close %}{% else %}{% url countdown_open %}{% endif %}'"{% if countdown_visible %} checked{% endif %}>
{% trans "Countdown" %} (<a href="{% url config_agenda %}">{{countdown_time}}{% trans "sec" %}</a>)
{% if countdown_visible == "True" %}:
<a class="projector_countdown" href="{% url countdown_reset countdown_time %}" title="{% trans 'Reset countdown' %}">
<img src="/static/images/icons/media-skip-backward.png" />
</a>
<a class="projector_countdown" href="{% url countdown_start %}" title="{% trans 'Start countdown' %}">
<img src="/static/images/icons/media-playback-start.png" />
</a>
<a class="projector_countdown" href="{% url countdown_stop %}" title="{% trans 'Stop countdown' %}">
<img src="/static/images/icons/media-playback-pause.png" />
</a>
{% endif %}
<p></p>
<!-- projector control -->
{% trans "Adjust projector view" %}:
<a class="projector_edit" href="{% url projector_bigger %}" title="{% trans 'Zoom in' %}">
<img src="/static/images/icons/zoom-in.png" />
</a>
<a class="projector_edit" href="{% url projector_smaller %}" title="{% trans 'Zoom out' %}">
<img src="/static/images/icons/zoom-out.png" />
</a>
<a class="projector_edit" href="{% url projector_up %}" title="{% trans 'Scroll text up' %}">
<img src="/static/images/icons/go-up.png" />
</a>
<a class="projector_edit" href="{% url projector_down %}" title="{% trans 'Scroll text down' %}">
<img src="/static/images/icons/go-down.png" />
</a>
<a class="projector_edit" href="{% url projector_clean %}" title="{% trans 'Reset projector view' %}">
<img src="/static/images/icons/view-restore.png" />
</a>
</div>
{% if perms.agenda.can_manage_agenda %}
<div style="text-align: right; padding: 0 5px 5px 0; margin-top:-20px;">
<!-- countdown -->
<input type="checkbox" name="countdown" onchange="document.location='{% if countdown_visible %}{% url countdown_close %}{% else %}{% url countdown_open %}{% endif %}'"{% if countdown_visible %} checked{% endif %}>
{% trans "Countdown" %} (<a href="{% url config_agenda %}">{{countdown_time}}{% trans "sec" %}</a>)
{% if countdown_visible == "True" %}:
<a class="projector_countdown" href="{% url countdown_reset countdown_time %}" title="{% trans 'Reset countdown' %}">
<img src="/static/images/icons/media-skip-backward.png" />
</a>
<a class="projector_countdown" href="{% url countdown_start %}" title="{% trans 'Start countdown' %}">
<img src="/static/images/icons/media-playback-start.png" />
</a>
<a class="projector_countdown" href="{% url countdown_stop %}" title="{% trans 'Stop countdown' %}">
<img src="/static/images/icons/media-playback-pause.png" />
</a>
{% endif %}
<p></p>
<!-- projector control -->
{% trans "Adjust projector view" %}:
<a class="projector_edit" href="{% url projector_bigger %}" title="{% trans 'Zoom in' %}">
<img src="/static/images/icons/zoom-in.png" />
</a>
<a class="projector_edit" href="{% url projector_smaller %}" title="{% trans 'Zoom out' %}">
<img src="/static/images/icons/zoom-out.png" />
</a>
<a class="projector_edit" href="{% url projector_up %}" title="{% trans 'Scroll text up' %}">
<img src="/static/images/icons/go-up.png" />
</a>
<a class="projector_edit" href="{% url projector_down %}" title="{% trans 'Scroll text down' %}">
<img src="/static/images/icons/go-down.png" />
</a>
<a class="projector_edit" href="{% url projector_clean %}" title="{% trans 'Reset projector view' %}">
<img src="/static/images/icons/view-restore.png" />
</a>
</div>
{% endif %}
{% for category, slides in categories.items %} {% for category, slides in categories.items %}
<div class="column"> <div class="column">
<div class="portlet"> <div class="portlet">
<div class="portlet-header">{{ category }}</div> <div class="portlet-header">{{ category }}</div>
<div class="portlet-content"> <div class="portlet-content">
{% for slide in slides %} {% for slide in slides %}
{% if slide.model_slide %} {% if slide.model_slide %}
<ul> <ul>
{% for item in slide.get_items %} {% for item in slide.get_items %}
<li><a href="{% url projector_activate_slide item.sid %}">{{ item }}</a></li> <li><a href="{% url projector_activate_slide item.sid %}">{{ item }}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>
{% else %} {% else %}
# <a href="{% url projector_activate_slide slide.key %}">{{ slide.key }}</a> # <a href="{% url projector_activate_slide slide.key %}">{{ slide.key }}</a>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</div>
</div> </div>
</div> </div>
</div> {% endfor %}
{% endfor %}
<div class="column"> <div class="column">
<div class="portlet"> <div class="portlet">
<div class="portlet-header">{% trans "Live View" %}</div> <div class="portlet-header">
<div class="portlet-content"> {% trans "Live View" %}
<iframe src="{% url projector_show %}" width="100%" style="zoom:15%;"> </div>
<div class="portlet-content">
<iframe src="{% url projector_show %}" width="100%" style="zoom:15%;"></iframe>
</div>
</div> </div>
<div class="portlet">
<div class="portlet-header">{% trans "Hidden information" %}</div>
<div class="portlet-content">
TODO: list hidden agenda items
</div>
</div>
</div> </div>
<div class="portlet">
<div class="portlet-header">{% trans "Hidden information" %}</div>
<div class="portlet-content">
TODO: list hidden agenda items
</div>
</div>
</div>
{% endblock %} {% endblock %}

View File

@ -0,0 +1,25 @@
{% extends "projector/base_projector.html" %}
{% load tags %}
{% load i18n %}
{% block title %}{{ block.super }} {%trans "New Slide" %}{% endblock %}
{% block content %}
<h1>{% trans 'New Slide' %}</h1>
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
<button class="button" type="submit">
<span class="icon ok">{%trans 'Save' %}</span>
</button>
<button class="button" type="submit" name="apply">
<span class="icon apply">{%trans 'Apply' %}</span>
</button>
<a href='{% url item_overview %}'>
<button class="button" type="button" onclick="window.location='{% url item_overview %}'">
<span class="icon cancel">{%trans 'Cancel' %}</span>
</button>
</a>
</form>
{% endblock %}

View File

@ -12,7 +12,11 @@
from django.conf.urls.defaults import * from django.conf.urls.defaults import *
from projector.views import ControlView, ActivateView from utils.views import CreateView
from views import ControlView, ActivateView
from models import ProjectorSlide
urlpatterns = patterns('projector.views', urlpatterns = patterns('projector.views',
url(r'^$', 'active_slide', url(r'^$', 'active_slide',
@ -28,6 +32,16 @@ urlpatterns = patterns('projector.views',
name='projector_activate_slide', name='projector_activate_slide',
), ),
url(r'^new/$',
CreateView.as_view(
success_url='projector_control',
model=ProjectorSlide,
template_name='projector/new.html',
permission_required='projector.can_manage_projector'
),
name='projector_new',
),
url(r'^bigger/$', 'projector_edit', {'direction': 'bigger'}, url(r'^bigger/$', 'projector_edit', {'direction': 'bigger'},
name='projector_bigger'), name='projector_bigger'),

View File

@ -25,8 +25,8 @@ from utils.template import render_block_to_string
from system import config from system import config
from projector.api import get_active_slide, set_active_slide from api import get_active_slide, set_active_slide
from projector.models import SLIDE from projector import SLIDE
class ControlView(TemplateView): class ControlView(TemplateView):
@ -59,7 +59,7 @@ class ActivateView(RedirectView):
return context return context
@permission_required('agenda.can_see_projector') @permission_required('projector.can_see_projector')
def active_slide(request): def active_slide(request):
""" """
Shows the active Slide. Shows the active Slide.