3 from django.db import models
4 from django.contrib.auth.models import User
5 from django.conf import settings
6 from django.utils.translation import gettext_lazy as _
8 class PanelSettings(models.Model):
9 user = models.ForeignKey(User)
10 left_panel = models.CharField(blank=True, max_length=80)
11 right_panel = models.CharField(blank=True, max_length=80)
14 ordering = ['user__name']
15 verbose_name, verbose_name_plural = _("panel settings"), _("panel settings")
17 def __unicode__(self):
18 return u"Panel settings for %s" % self.user.name
20 class Book(models.Model):
23 ("can_add_files", "Can do hg add."),
27 class PullRequest(models.Model):
28 comitter = models.ForeignKey(User) # the user who request the pull
29 file = models.CharField(max_length=256) # the file to request
30 source_rev = models.CharField(max_length=40) # revision number of the commiter
32 comment = models.TextField() # addtional comments to the request
34 # revision number in which the changes were merged (if any)
35 merged_rev = models.CharField(max_length=40, null=True)
37 def __unicode__(self):
38 return u"Pull request from %s, source: %s %s, status: %s." % \
39 (self.commiter, self.file, self.source_rev, \
40 (("merged into "+self.merged_rev) if self.merged_rev else "pending") )
43 def get_image_folders():
44 return sorted(fn for fn in os.listdir(os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR)) if not fn.startswith('.'))
47 def get_images_from_folder(folder):
48 return sorted(settings.MEDIA_URL + settings.IMAGE_DIR + '/' + folder + '/' + fn for fn
49 in os.listdir(os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR, folder))
50 if not fn.startswith('.'))
52 def user_branch(user):
53 return 'personal_'+user.username