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 _
9 class PanelSettings(models.Model):
10 user = models.ForeignKey(User)
11 left_panel = models.CharField(blank=True, max_length=80)
12 right_panel = models.CharField(blank=True, max_length=80)
15 ordering = ['user__name']
16 verbose_name, verbose_name_plural = _("panel settings"), _("panel settings")
18 def __unicode__(self):
19 return u"Panel settings for %s" % self.user.name
22 class PullRequest(models.Model):
23 comitter = models.ForeignKey(User) # the user who request the pull
24 file = models.CharField(max_length=256) # the file to request
25 source_rev = models.CharField(max_length=40) # revision number of the commiter
27 comment = models.TextField() # addtional comments to the request
29 # revision number in which the changes were merged (if any)
30 merged_rev = models.CharField(max_length=40, null=True)
32 def __unicode__(self):
33 return u"Pull request from %s, source: %s %s, status: %s." % \
34 (self.commiter, self.file, self.source_rev, \
35 (("merged into "+self.merged_rev) if self.merged_rev else "pending") )
38 def get_image_folders():
39 return sorted(fn for fn in os.listdir(os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR)) if not fn.startswith('.'))
42 def get_images_from_folder(folder):
43 return sorted(settings.MEDIA_URL + settings.IMAGE_DIR + '/' + folder + '/' + fn for fn
44 in os.listdir(os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR, folder))
45 if not fn.startswith('.'))
47 def user_branch(user):
48 return 'personal_'+user.username