1 # combo - content management system
2 # Copyright (C) 2015 Entr'ouvert
4 # This program is free software: you can redistribute it and/or modify it
5 # under the terms of the GNU Affero General Public License as published
6 # by the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Affero General Public License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 from django import template
18 from django.db import models
19 from django.forms import models as model_forms
20 from django.utils.translation import ugettext_lazy as _
22 from combo.data.models import CellBase
23 from combo.data.library import register_cell_class
26 class GalleryCell(CellBase):
27 title = models.CharField(_('Title'), max_length=50, blank=True, null=True)
28 manager_form_template = 'combo/gallery_manager.html'
31 verbose_name = _('Gallery')
33 def render(self, context):
34 gallery_template = template.loader.get_template('combo/gallery.html')
35 return gallery_template.render(context)
37 def get_additional_label(self):
43 class Image(models.Model):
44 gallery = models.ForeignKey(GalleryCell, verbose_name=_('Gallery'))
45 image = models.ImageField(_('Image'),
46 upload_to='uploads/gallery/%Y/%m/')
47 order = models.PositiveIntegerField()
48 title = models.CharField(_('Title'), max_length=50, blank=True)