2016-09-18 22:14:24 +02:00
|
|
|
from django.db import models
|
|
|
|
|
2019-11-04 14:56:01 +01:00
|
|
|
from openslides.utils.manager import BaseManager
|
|
|
|
|
2019-04-23 16:57:35 +02:00
|
|
|
from ..agenda.mixins import AgendaItemWithListOfSpeakersMixin
|
2016-09-18 22:14:24 +02:00
|
|
|
from ..mediafiles.models import Mediafile
|
|
|
|
from ..utils.models import RESTModelMixin
|
|
|
|
|
|
|
|
|
2019-11-04 14:56:01 +01:00
|
|
|
class TopicManager(BaseManager):
|
2016-09-30 20:42:58 +02:00
|
|
|
"""
|
2019-11-04 14:56:01 +01:00
|
|
|
Customized model manager to support our get_prefetched_queryset method.
|
2016-09-30 20:42:58 +02:00
|
|
|
"""
|
2019-01-06 16:22:33 +01:00
|
|
|
|
2019-11-04 14:56:01 +01:00
|
|
|
def get_prefetched_queryset(self, *args, **kwargs):
|
2016-09-30 20:42:58 +02:00
|
|
|
"""
|
|
|
|
Returns the normal queryset with all topics. In the background all
|
|
|
|
attachments and the related agenda item are prefetched from the
|
|
|
|
database.
|
|
|
|
"""
|
2019-11-04 14:56:01 +01:00
|
|
|
return (
|
|
|
|
super()
|
|
|
|
.get_prefetched_queryset(*args, **kwargs)
|
|
|
|
.prefetch_related("attachments", "lists_of_speakers", "agenda_items")
|
2019-04-23 16:57:35 +02:00
|
|
|
)
|
2016-09-18 16:00:31 +02:00
|
|
|
|
|
|
|
|
2019-04-23 16:57:35 +02:00
|
|
|
class Topic(RESTModelMixin, AgendaItemWithListOfSpeakersMixin, models.Model):
|
2016-09-18 22:14:24 +02:00
|
|
|
"""
|
|
|
|
Model for slides with custom content. Used to be called custom slide.
|
|
|
|
"""
|
2019-01-06 16:22:33 +01:00
|
|
|
|
2016-09-18 16:00:31 +02:00
|
|
|
objects = TopicManager()
|
2016-09-18 22:14:24 +02:00
|
|
|
|
|
|
|
title = models.CharField(max_length=256)
|
|
|
|
text = models.TextField(blank=True)
|
|
|
|
attachments = models.ManyToManyField(Mediafile, blank=True)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
default_permissions = ()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.title
|
|
|
|
|
2019-04-23 16:57:35 +02:00
|
|
|
def get_title_information(self):
|
2019-02-15 12:17:08 +01:00
|
|
|
return {"title": self.title}
|