Cleaned up mediafiles app. Fixed #1629.
This commit is contained in:
parent
4600fd9b02
commit
4ad99f2bc9
@ -1,17 +1,15 @@
|
|||||||
|
from django.conf import settings
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
from django.utils.translation import ugettext_lazy, ugettext_noop
|
from django.utils.translation import ugettext_lazy, ugettext_noop
|
||||||
|
|
||||||
from openslides.users.models import User
|
from ..utils.models import RESTModelMixin
|
||||||
from openslides.utils.models import RESTModelMixin
|
|
||||||
|
|
||||||
|
|
||||||
class Mediafile(RESTModelMixin, models.Model):
|
class Mediafile(RESTModelMixin, models.Model):
|
||||||
"""
|
"""
|
||||||
Class for uploaded files which can be delivered under a certain url.
|
Class for uploaded files which can be delivered under a certain url.
|
||||||
"""
|
"""
|
||||||
slide_callback_name = 'mediafile'
|
|
||||||
|
|
||||||
mediafile = models.FileField(upload_to='file', verbose_name=ugettext_lazy('File'))
|
mediafile = models.FileField(upload_to='file', verbose_name=ugettext_lazy('File'))
|
||||||
"""
|
"""
|
||||||
See https://docs.djangoproject.com/en/dev/ref/models/fields/#filefield
|
See https://docs.djangoproject.com/en/dev/ref/models/fields/#filefield
|
||||||
@ -21,7 +19,7 @@ class Mediafile(RESTModelMixin, models.Model):
|
|||||||
title = models.CharField(max_length=255, unique=True, blank=True, verbose_name=ugettext_lazy('Title'))
|
title = models.CharField(max_length=255, unique=True, blank=True, verbose_name=ugettext_lazy('Title'))
|
||||||
"""A string representing the title of the file."""
|
"""A string representing the title of the file."""
|
||||||
|
|
||||||
uploader = models.ForeignKey(User, null=True, blank=True, verbose_name=ugettext_lazy('Uploaded by'))
|
uploader = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True, verbose_name=ugettext_lazy('Uploaded by'))
|
||||||
"""A user – the uploader of a file."""
|
"""A user – the uploader of a file."""
|
||||||
|
|
||||||
timestamp = models.DateTimeField(auto_now_add=True)
|
timestamp = models.DateTimeField(auto_now_add=True)
|
||||||
|
@ -14,12 +14,10 @@ class MediafileSlide(ProjectorElement):
|
|||||||
name = 'mediafiles/mediafile'
|
name = 'mediafiles/mediafile'
|
||||||
|
|
||||||
def get_context(self):
|
def get_context(self):
|
||||||
pk = self.config_entry.get('id')
|
|
||||||
try:
|
try:
|
||||||
Mediafile.objects.get(pk=pk)
|
Mediafile.objects.get(pk=self.config_entry.get('id'))
|
||||||
except Mediafile.DoesNotExist:
|
except Mediafile.DoesNotExist:
|
||||||
raise ProjectorException(_('File does not exist.'))
|
raise ProjectorException(_('File does not exist.'))
|
||||||
return {'id': pk}
|
|
||||||
|
|
||||||
def get_requirements(self, config_entry):
|
def get_requirements(self, config_entry):
|
||||||
pk = config_entry.get('id')
|
pk = config_entry.get('id')
|
||||||
|
Loading…
Reference in New Issue
Block a user