예제 #1
0
파일: serialise.py 프로젝트: tazo90/lux
 def as_form(self, ng_controller=None, **attrs):
     data = self.as_dict(**attrs)
     form = data['field']
     directive = form.pop('directive', 'lux-form')
     id = form['id']
     script = form_script % (id, json.dumps(data))
     html = Html(directive, script).data('options', 'luxforms.%s' % id)
     ng_controller = ng_controller or form.pop('ng_controller', None)
     # add controller if required
     if ng_controller:
         html.data('ng-controller', ng_controller)
     return html
예제 #2
0
 def as_form(self, ng_controller=None, **attrs):
     data = self.as_dict(**attrs)
     form = data['field']
     directive = form.pop('directive', 'lux-form')
     id = form['id']
     script = form_script % (id, json.dumps(data))
     html = Html(directive, script).data('options', 'luxforms.%s' % id)
     ng_controller = ng_controller or form.pop('ng_controller', None)
     # add controller if required
     if ng_controller:
         html.data('ng-controller', ng_controller)
     return html
예제 #3
0
 def _get_content(self, page, context):
     container = Html(None)
     if 'content_ids' not in context:
         context['content_ids'] = {}
     ids = context['content_ids']
     for content in page.content.get(self.key) or ():
         template = content.get('template')
         row = Html('div', template=template)
         for content in content.get('children') or ():
             column = Html('div')
             for bc in content or ():
                 block = Html('div', template=bc.get('template'))
                 for data in bc.get('children') or ():
                     if not data:
                         continue
                     content = data.pop('content', None)
                     if content is None:
                         continue
                     if isinstance(content, dict):
                         elem = Html('div', data=content)
                         # This is THE very special case where the
                         # content in this element is the content
                         # served by the url if there was no cms extension
                         if content.get(CONTENT_URL) == THIS:
                             value = context.get(THIS)
                             elem.append(Html('div', value, field=THIS))
                     else:
                         # id, we need to retrieve the content
                         content = int_or_string(content)
                         elem = Html('div')
                         if content in ids:
                             ids[content].append(elem)
                         else:
                             ids[content] = [elem]
                     elem.data(data)
                     block.append(elem)
                 column.append(block)
             row.append(column)
         container.append(row)
     return container
예제 #4
0
파일: grid.py 프로젝트: pombredanne/lux
 def _get_content(self, page, context):
     container = Html(None)
     if 'content_ids' not in context:
         context['content_ids'] = {}
     ids = context['content_ids']
     for content in page.content.get(self.key) or ():
         template = content.get('template')
         row = Html('div', template=template)
         for content in content.get('children') or ():
             column = Html('div')
             for bc in content or ():
                 block = Html('div', template=bc.get('template'))
                 for data in bc.get('children') or ():
                     if not data:
                         continue
                     content = data.pop('content', None)
                     if content is None:
                         continue
                     if isinstance(content, dict):
                         elem = Html('div', data=content)
                         # This is THE very special case where the
                         # content in this element is the content
                         # served by the url if there was no cms extension
                         if content.get(CONTENT_URL) == THIS:
                             value = context.get(THIS)
                             elem.append(Html('div', value, field=THIS))
                     else:
                         # id, we need to retrieve the content
                         content = int_or_string(content)
                         elem = Html('div')
                         if content in ids:
                             ids[content].append(elem)
                         else:
                             ids[content] = [elem]
                     elem.data(data)
                     block.append(elem)
                 column.append(block)
             row.append(column)
         container.append(row)
     return container