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
58 class Document(models.Model):
61 ("can_share", "Can share documents without pull requests."),
66 class PullRequest(models.Model):
68 ("N", "Pending for resolution"),
70 ("A", "Accepted & merged"),
73 comitter = models.ForeignKey(User) # the user who request the pull
74 comment = models.TextField() # addtional comments to the request
77 document = models.CharField(max_length=255)
79 # revision to be merged into the main branch
80 source_revision = models.CharField(max_length=40, unique=True)
83 status = models.CharField(max_length=1, choices=REQUEST_STATUSES)
85 # comment to the status change of request (if applicable)
86 response_comment = models.TextField(blank=True)
88 # revision number in which the changes were merged (if any)
89 merged_rev = models.CharField(max_length=40, blank=True, null=True)
91 def __unicode__(self):
92 return unicode(self.comitter) + u':' + self.document
94 # Yes, this is intentionally unnormalized !
95 class GalleryForDocument(models.Model):
96 name = models.CharField(max_length=100)
98 # directory containing scans under MEDIA_ROOT/
99 subpath = models.CharField(max_length=255)
101 # document associated with the gallery
102 document = models.CharField(max_length=255)
104 def __unicode__(self):
105 return u"%s:%s" % (self.subpath, self.document)