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 def get_image_folders():
23 return sorted(fn for fn in os.listdir(os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR)) if not fn.startswith('.'))
26 def get_images_from_folder(folder):
27 return sorted(settings.MEDIA_URL + settings.IMAGE_DIR + '/' + folder + '/' + fn for fn
28 in os.listdir(os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR, folder))
29 if not fn.startswith('.'))
31 def user_branch(user):
32 return 'personal_'+user.username