1 # -*- encoding: utf-8 -*-
4 from django.db import models
5 from django.contrib.auth.models import User
6 from django.conf import settings
7 from django.utils.translation import gettext_lazy as _
11 from explorer import fields
13 class EditorSettings(models.Model):
14 """Ustawienia edytora dla użytkownika.
16 Pole settings zawiera obiekt JSON o kluczach:
17 - panels - lista otwartych paneli i ich proporcje
18 - recentFiles - lista otwartych plików i ustawienia dla nich
23 {'name': 'htmleditor',
25 {'name': 'gallery', 'ratio': 0.5}
29 'fileId': 'mickiewicz_pan_tadeusz.xml',
31 {'name': 'htmleditor', 'ratio': 0.4},
32 {'name': 'gallery', 'ratio': 0.6}
38 user = models.ForeignKey(User, unique=True)
39 settings = fields.JSONField()
42 verbose_name, verbose_name_plural = _("editor settings"), _("editor settings")
44 def __unicode__(self):
45 return u"Editor settings for %s" % self.user.username
47 class EditorPanel(models.Model):
48 id = models.CharField(max_length=24, primary_key=True)
49 display_name = models.CharField(max_length=128)
51 toolbar_groups = models.ManyToManyField(toolbar.models.ButtonGroup, blank=True)
52 toolbar_extra = models.ForeignKey(toolbar.models.ButtonGroup, null=True, blank=True,
53 unique=True, related_name='main_editor_panels')
55 def __unicode__(self):
56 return self.display_name
59 # Yes, this is intentionally unnormalized !
60 class GalleryForDocument(models.Model):
61 name = models.CharField(max_length=100, blank=True)
63 # document associated with the gallery
64 document = models.CharField(max_length=255, unique=True)
66 # directory containing scans under MEDIA_ROOT/
67 subpath = models.CharField(max_length=255)
69 def __unicode__(self):
70 return u"%s:%s" % (self.subpath, self.document)