2014-01-28 08:32:26 +01:00
|
|
|
from django.core.urlresolvers import reverse
|
|
|
|
from django.db import models
|
|
|
|
from django.utils.translation import ugettext_lazy, ugettext_noop
|
2014-10-12 11:11:54 +02:00
|
|
|
# TODO: activate the following line after using the apploader
|
|
|
|
# from django.contrib.auth import get_user_model
|
2014-01-28 08:32:26 +01:00
|
|
|
|
|
|
|
from openslides.projector.models import SlideMixin
|
2015-01-17 14:25:05 +01:00
|
|
|
from openslides.utils.models import AbsoluteUrlMixin
|
|
|
|
from openslides.utils.rest_api import RESTModelMixin
|
2014-01-28 08:32:26 +01:00
|
|
|
|
2014-10-11 14:34:49 +02:00
|
|
|
# Imports the default user so that other apps can import it from here.
|
2014-10-12 11:11:54 +02:00
|
|
|
# TODO: activate this with the new apploader
|
|
|
|
# User = get_user_model()
|
2014-10-11 14:34:49 +02:00
|
|
|
|
2014-01-28 08:32:26 +01:00
|
|
|
|
2015-01-17 14:25:05 +01:00
|
|
|
class CustomSlide(RESTModelMixin, SlideMixin, AbsoluteUrlMixin, models.Model):
|
2014-01-28 08:32:26 +01:00
|
|
|
"""
|
|
|
|
Model for Slides, only for the projector.
|
|
|
|
"""
|
|
|
|
slide_callback_name = 'customslide'
|
|
|
|
|
|
|
|
title = models.CharField(max_length=256, verbose_name=ugettext_lazy('Title'))
|
|
|
|
text = models.TextField(null=True, blank=True, verbose_name=ugettext_lazy('Text'))
|
|
|
|
weight = models.IntegerField(default=0, verbose_name=ugettext_lazy('Weight'))
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
"""
|
|
|
|
General permissions that can not be placed at a specific app.
|
|
|
|
"""
|
|
|
|
permissions = (
|
|
|
|
('can_manage_projector', ugettext_noop('Can manage the projector')),
|
|
|
|
('can_see_projector', ugettext_noop('Can see the projector')),
|
|
|
|
('can_see_dashboard', ugettext_noop('Can see the dashboard')),
|
2014-03-12 22:15:05 +01:00
|
|
|
('can_use_chat', ugettext_noop('Can use the chat')),
|
2014-01-28 08:32:26 +01:00
|
|
|
)
|
|
|
|
|
2014-08-16 09:25:18 +02:00
|
|
|
def __str__(self):
|
2014-01-28 08:32:26 +01:00
|
|
|
return self.title
|
|
|
|
|
|
|
|
def get_absolute_url(self, link='update'):
|
|
|
|
if link == 'update':
|
|
|
|
url = reverse('customslide_update', args=[str(self.pk)])
|
|
|
|
elif link == 'delete':
|
|
|
|
url = reverse('customslide_delete', args=[str(self.pk)])
|
|
|
|
else:
|
2015-01-24 16:35:50 +01:00
|
|
|
url = super().get_absolute_url(link)
|
2014-01-28 08:32:26 +01:00
|
|
|
return url
|
2014-12-26 13:45:13 +01:00
|
|
|
|
|
|
|
|
2015-01-17 14:25:05 +01:00
|
|
|
class Tag(RESTModelMixin, AbsoluteUrlMixin, models.Model):
|
2014-12-26 13:45:13 +01:00
|
|
|
"""
|
|
|
|
Model to save tags.
|
|
|
|
"""
|
|
|
|
|
|
|
|
name = models.CharField(max_length=255, unique=True,
|
|
|
|
verbose_name=ugettext_lazy('Tag'))
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
ordering = ['name']
|
|
|
|
permissions = (
|
|
|
|
('can_manage_tags', ugettext_noop('Can manage tags')), )
|
|
|
|
|
2015-01-05 17:14:29 +01:00
|
|
|
def __str__(self):
|
2014-12-26 13:45:13 +01:00
|
|
|
return self.name
|