Exemplo n.º 1
0
Arquivo: admin.py Projeto: tazo90/lux
 def info(self, app):
     '''Information for admin navigation
     '''
     info = {'title': nicename(self.model),
             'name': nicename(self.model),
             'href': self.full_route.path,
             'icon': self.icon}
     return self.section, info
Exemplo n.º 2
0
 def info(self, request):
     '''Information for admin navigation
     '''
     model = self.get_model(request)
     name = nicename(model.identifier)
     info = {'title': name,
             'name': name,
             'href': self.full_route.path,
             'icon': self.icon}
     return self.section, info
Exemplo n.º 3
0
 def __init__(self, name, sortable=None, filter=None, type=None,
              displayName=None, field=None, hidden=None, model=None):
     self.name = name
     self.sortable = sortable
     self.filter = filter
     self.type = type or ('object' if model else 'string')
     self.displayName = displayName or nicename(name)
     self.field = field
     self.hidden = hidden
     self.model = model
Exemplo n.º 4
0
 def info(self, request):
     '''Information for admin navigation
     '''
     model = self.get_model(request)
     name = nicename(model.identifier)
     info = {
         'title': name,
         'name': name,
         'href': self.full_route.path,
         'icon': self.icon
     }
     return self.section, info
Exemplo n.º 5
0
 def _as_dict(self, defaults):
     for k, v in self.__dict__.items():
         if k.startswith('_'):
             continue
         if v is None and defaults:
             if k == 'displayName':
                 v = nicename(self.name)
             elif k == 'field':
                 v = self.name
             elif k == 'type':
                 v = 'string'
         if v is not None:
             yield k, v
Exemplo n.º 6
0
Arquivo: form.py Projeto: tourist/lux
 def __init__(self, form, field):
     self.form = form
     self.field = field
     self.request = form.request
     self.name = field.name
     self.html_name = field.html_name(form.prefix)
     self.value = None
     if field.label is None:
         self.label = nicename(self.name)
     else:
         self.label = field.label
     self.required = field.required
     self.help_text = field.help_text
     self.id = self.auto_id.format(self.__dict__)
     self.errors_id = self.id + '-errors'
Exemplo n.º 7
0
 def __init__(self, form, field):
     self.form = form
     self.field = field
     self.request = form.request
     self.name = field.name
     self.html_name = field.html_name(form.prefix)
     self.value = None
     if field.label is None:
         self.label = nicename(self.name)
     else:
         self.label = field.label
     self.required = field.required
     self.help_text = field.help_text
     self.id = self.auto_id.format(self.__dict__)
     self.errors_id = self.id + '-errors'
Exemplo n.º 8
0
def column_info(name, col):
    sortable = True
    filter = True
    try:
        type = _types.get(col.type.python_type, 'string')
    except NotImplementedError:
        type = col.type.__class__.__name__.lower()
        sortable = False
        filter = False

    info = {'name': name,
            'field': col.name,
            'displayName': nicename(name),
            'sortable': sortable,
            'filter': filter,
            'type': type}
    return info
Exemplo n.º 9
0
 def get(cls, code, name=None, description=None, fields=None,
         type=None, sortable=True, filter=None,
         cssClasses=None):
     '''Get or create a new :class:`Column`.'''
     if isinstance(code, cls):
         return code
     if name is None:
         name = nicename(code)
     code = slugify(code)
     fields = fields or code
     if not isinstance(fields, (list, tuple)):
         fields = (fields,)
     else:
         fields = tuple(fields)
     type = type or 'text'
     return cls(code, name, description, type, fields, filter,
                sortable, cssClasses)
Exemplo n.º 10
0
def column_info(name, col):
    sortable = True
    filter = True
    try:
        type = _types.get(col.type.python_type, 'string')
    except NotImplementedError:
        type = col.type.__class__.__name__.lower()
        sortable = False
        filter = False

    info = {
        'name': name,
        'field': col.name,
        'displayName': col.doc or nicename(name),
        'sortable': sortable,
        'filter': filter,
        'type': type
    }

    return info
Exemplo n.º 11
0
 def _():
     for key, template in templates.items():
         yield key, nicename(key)
Exemplo n.º 12
0
 def getattrs(self, form=None):
     '''Dictionary of attributes for the Html element.
     '''
     attrs = self.attrs.copy()
     attrs['label'] = self.label or nicename(self.name)
     return attrs
Exemplo n.º 13
0
Arquivo: admin.py Projeto: tourist/lux
 def info(self, app):
     info = app.mapper.api_info(self.meta)
     if info:
         info['label'] = nicename(info['name'])
         info['href'] = self.full_route.path
         return info
Exemplo n.º 14
0
 def metadata(self):
     return {
         'name': self.name,
         'displayName': self.label or nicename(self.name),
         'type': self.type
     }
Exemplo n.º 15
0
 def getattrs(self, form=None):
     '''Dictionary of attributes for the Html element.
     '''
     attrs = dict(attributes(form, self.attrs))
     attrs['label'] = self.label or nicename(self.name)
     return attrs