Source code for sandglass.models.theme

import os

from django.contrib.staticfiles.finders import find
from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.utils.translation import ugettext_lazy as _

from django_extensions.db.models import TimeStampedModel


def theme_folder_choices():
    theme_path = find(os.path.join('sandglass', 'themes'))
    if not theme_path:
        raise ImproperlyConfigured("Missing sandglass theme folder")
    return [(folder, folder) for folder in sorted(os.listdir(theme_path))
            if os.path.isdir(os.path.join(theme_path, folder))]


[docs]class Theme(TimeStampedModel): name = models.CharField( verbose_name=_(u"name"), max_length=255, db_index=True) description = models.TextField( verbose_name=_(u"description"), blank=True, null=True) theme_folder = models.CharField( verbose_name=_(u"theme folder"), max_length=30, db_index=True, choices=theme_folder_choices()) class Meta: app_label = 'sandglass'
__all__ = ('Theme',)

Project Versions