Exemple #1
0
 def on_analyze(cls, site):
     super(Reservation, cls).on_analyze(site)
     ic = cls.workflow_state_field.choicelist
     k = 'auto_update_calendar'
     if not hasattr(ic, k):
         raise ChangedAPI("The workflow state field for {} uses {} which "
                          "has no attribute {}".format(cls, ic, k))
Exemple #2
0
    def class_init(cls):
        """Called internally at site startup. Don't override.

        """
        # if str(cls) == 'courses.Pupils':
        #     print("20160329 class_init")
        if hasattr(cls, 'required'):
            raise ChangedAPI(
                "{0} must convert `required` to `required_roles`".format(cls))
        master = getattr(cls, 'master', None)
        if isinstance(master, string_types):
            cls.master = resolve_model(master)

        actions.install_layout(cls, 'detail_layout', layouts.DetailLayout)
        actions.install_layout(cls,
                               'insert_layout',
                               layouts.InsertLayout,
                               window_size=(cls.insert_layout_width, 'auto'))

        if cls.parameters is None:
            params = cls.get_parameter_fields()
            if len(params):
                cls.parameters = params
        else:
            cls.parameters = cls.get_parameter_fields(**cls.parameters)

        cls.simple_parameters = cls.get_simple_parameters()
Exemple #3
0
 def define_names(self, names):
     if isinstance(names, six.string_types):
         raise ChangedAPI("{} must now call itself split().".format(self))
     for tag in names:
         iname = tag.replace("-", "_")
         iname = iname.replace(".", "_")
         #~ if iname in ('class','for','in','def'):
         if iname in RESERVED_WORDS:
             iname += "_"
         #~ setattr(self,iname,getattr(self._element_maker,name))
         p = partial(self.create_element, tag)
         setattr(self, iname, p)
Exemple #4
0
 def on_analyze(cls, site):
     super(Registrable, cls).on_analyze(site)
     chl = cls.workflow_state_field.choicelist
     ic = chl.item_class
     k = 'is_editable'
     if not hasattr(ic, k):
         fld = getattr(chl, k, None)
         if not isinstance(fld, models.BooleanField):
             raise ChangedAPI(
                 "The workflow state field for {} uses {} which "
                 "has no attribute {}".format(cls, ic, k))
     cls._registrable_fields = set(cls.get_registrable_fields(site))
Exemple #5
0
 def on_analyze(cls, site):
     super(Registrable, cls).on_analyze(site)
     if cls.workflow_state_field is None:
         raise Exception("{} has no workflow_state_field".format(cls))
     chl = cls.workflow_state_field.choicelist
     # for k in ('draft', 'registered'):
     #     if not hasattr(chl, k):
     #         raise Exception("{} has no value '{}'".format(chl, k))
     ic = chl.item_class
     if not issubclass(chl.item_class, RegistrableState):
         raise Exception("Invalid choicelist {} for {} state".format(
             chl, cls))
     k = 'is_editable'
     if not hasattr(ic, k):
         fld = getattr(chl, k, None)
         if not isinstance(fld, models.BooleanField):
             raise ChangedAPI(
                 "The workflow state field for {} uses {} which "
                 "has no attribute {}".format(cls, ic, k))
     cls._registrable_fields = set(cls.get_registrable_fields(site))
Exemple #6
0
 def on_analyze(cls, site):
     if hasattr(cls, 'manager_level_field'):
         raise ChangedAPI("{0} has a manager_level_field".format(cls))
     super(UserAuthored, cls).on_analyze(site)
Exemple #7
0
 def __init__(self, *args, **kw):
     kw.setdefault('max_length', 6)
     models.Field.__init__(self, *args, **kw)
     if self.blank and not self.null:
         raise ChangedAPI(
             "When `blank` is True, `null` must be True as well.")
Exemple #8
0
# Copyright 2014-2018 Rumma & Ko Ltd
# License: BSD (see file COPYING for details)

from django.conf import settings

from lino.core.utils import models_by_base

models = settings.SITE.models
"""
"""

from lino.core.exceptions import ChangedAPI
actors = modules = ChangedAPI("Replace rt.modules and rt.actors by rt.models")

# actors = settings.SITE.models

login = settings.SITE.login
startup = settings.SITE.startup
# get_printable_context = settings.SITE.get_printable_context
lookup_filter = settings.SITE.lookup_filter
find_config_file = settings.SITE.confdirs.find_config_file
find_config_files = settings.SITE.confdirs.find_config_files
find_template_config_files = settings.SITE.confdirs.find_template_config_files
makedirs_if_missing = settings.SITE.makedirs_if_missing
# relpath = settings.SITE.relpath
# get_settings_subdirs = settings.SITE.get_settings_subdirs
# is_local_project_dir = settings.SITE.is_local_project_dir


def get_template(*args, **kw):
    return settings.SITE.plugins.jinja.renderer.jinja_env.get_template(