def test_RenderFieldValue_templates(self): view_template = get_template( "field/annalist_view_text.html", "Can't load view template" ) edit_template = get_template( "field/annalist_edit_text.html", "Can't load edit template" ) fieldrender = RenderFieldValue( view_template=view_template, edit_template=edit_template ) self._check_value_renderer_results( fieldrender, context=intvalue_context, expect_rendered_view= '''<!-- field/annalist_view_text.html -->\n42''', expect_rendered_edit= '''<!-- field/annalist_edit_text.html -->\n'''+ '''<!-- cf http://stackoverflow.com/questions/1480588/input-size-vs-width -->\n'''+ '''<input type="text" size="64" name="intprefix_test_field" \n'''+ ''' placeholder="(test placeholder)"\n'''+ ''' value="42"/>''' ) return
def test_RenderFieldValue_renderers(self): class render_int_view(object): def render(self, context): return str(context['field']['field_value']) class render_int_edit(object): def render(self, context): return ( ('''<input type="text" size="64" '''+ '''name="%(repeat_prefix)s%(field_name)s" '''+ '''placeholder="%(field_placeholder)s" '''+ '''value="%(field_value)d"/>''')% { 'field_value': context['field']['field_value'] , 'field_name': context['field']['field_name'] , 'field_placeholder': context['field']['field_placeholder'] , 'repeat_prefix': context['repeat_prefix'] }) fieldrender = RenderFieldValue( view_renderer=render_int_view(), edit_renderer=render_int_edit() ) self._check_value_renderer_results( fieldrender, context=intvalue_context, expect_rendered_view="42", expect_rendered_edit= '''<input type="text" size="64" name="intprefix_test_field" '''+ '''placeholder="(test placeholder)" value="42"/>''' ) return
def get_field_placement_renderer(): """ Return field renderer object for field placement values """ return RenderFieldValue("placement", view_renderer=placement_view_renderer(), edit_renderer=placement_edit_renderer())
def get_file_upload_renderer(): """ Return field renderer object for uri import value """ return RenderFieldValue("file_upload", view_renderer=File_upload_view_renderer(), edit_renderer=File_upload_edit_renderer(), )
def get_uri_link_renderer(): """ Return field renderer object for URI link values """ return RenderFieldValue("uri_link", view_renderer=uri_link_view_renderer(), edit_renderer=uri_link_edit_renderer(), )
def get_bool_checkbox_renderer(): """ Return field renderer object for Boolean as checkbox """ return RenderFieldValue("checkbox", view_renderer=bool_checkbox_view_renderer(), edit_renderer=bool_checkbox_edit_renderer(), )
def get_field_tokenset_renderer(): """ Return field renderer object for token list values """ return RenderFieldValue( view_renderer=tokenset_view_renderer(), edit_renderer=tokenset_edit_renderer(), )
def get_ref_image_renderer(): """ Return field renderer object for token list values """ return RenderFieldValue( "ref_image", view_renderer=ref_image_view_renderer(), edit_renderer=ref_image_edit_renderer(), )
def get_uri_import_renderer(): """ Return field renderer object for uri import value """ return RenderFieldValue( "uri_import", view_renderer=uri_import_view_renderer(), edit_renderer=uri_import_edit_renderer(), )
def get_entitytype_renderer(): """ Return field renderer object for entitytype """ return RenderFieldValue( "entitytype", view_renderer=Select_view_renderer(view_entitytype), edit_renderer=Select_edit_renderer(edit_entitytype), )
def get_choice_renderer(): """ Return field renderer object for value selector (without '+' button) """ return RenderFieldValue( "choice", view_renderer=Select_view_renderer(view_choice), edit_renderer=Select_edit_renderer(edit_choice), )
def get_select_renderer(): """ Return field renderer object for value selector (with '+' button) """ return RenderFieldValue( "select", view_renderer=Select_view_renderer(view_select), edit_renderer=Select_edit_renderer(edit_select), )
def get_show_markdown_renderer(): """ Return field renderer object for display-only (no input) of Markdown text """ return RenderFieldValue( "show_markdown", view_renderer=text_markdown_view_renderer(), edit_renderer=text_markdown_view_renderer(), )
def get_text_markdown_renderer(): """ Return field renderer object for Markdown text """ return RenderFieldValue( "markdown", view_renderer=text_markdown_view_renderer(), edit_renderer=text_markdown_edit_renderer(), )
def get_ref_multifield_renderer(): """ Return multi-field renderer object """ r = RenderFieldValue( "ref_multifields", col_head_view_renderer=RenderMultiFields_label(col_head_view), view_renderer=RenderMultiFields_value(view_multifield), edit_renderer=Select_edit_renderer(edit_select)) return r
def get_view_choice_renderer(): """ Return field renderer object for "view choice" controlm, which combines a regular selection box with a "Show view" button. This option is used by the view template/renderer, and is not available as a field choice within the view. """ return RenderFieldValue( "view_choice", view_renderer=Select_view_renderer(view_view_choice), edit_renderer=Select_edit_renderer(edit_view_choice), )
def test_RenderFieldValue_files(self): fieldrender = RenderFieldValue( "render_template", view_file="field/annalist_view_text.html", edit_file="field/annalist_edit_text.html") self._check_value_renderer_results( fieldrender, context=self.intvalue_context, expect_rendered_view='''<span>42</span>''', expect_rendered_edit= '''<input type="text" size="64" name="intprefix_test_field" \n''' + ''' placeholder="(test placeholder)"\n''' + ''' value="42" />''') return
def get_fieldrow_renderer(): """ Return field row renderer object. This renders multiple fields froma supplied entity as a single row, wrapping the entire set of fields in a row <div>. """ r = RenderFieldValue( "fieldrow", view_renderer=RenderFieldRow(view_fieldrow), edit_renderer=RenderFieldRow(view_fieldrow) # @@@@ change back to edit ) # Suppress all modal rendering: just render field content # @@TODO: this is a hack - need to re-think how render modes are hamndled. r._render_label = None r._render_view = ModeWrapValueRenderer("view", r._view_renderer) r._render_edit = ModeWrapValueRenderer("edit", r._edit_renderer) r._render_label_view = ModeWrapValueRenderer("label_view", r._view_renderer) r._render_label_edit = ModeWrapValueRenderer("label_edit", r._edit_renderer) r._render_col_head = None r._render_col_head_view = ModeWrapValueRenderer("col_head_view", r._view_renderer) r._render_col_head_edit = ModeWrapValueRenderer("col_head_edit", r._edit_renderer) r._render_col_view = ModeWrapValueRenderer("col_view", r._view_renderer) r._render_col_edit = ModeWrapValueRenderer("col_edit", r._edit_renderer) r._render_label = None # r._render_label = None # r._render_view = ModeWrapValueRenderer("view", r.view().value_renderer) # r._render_edit = ModeWrapValueRenderer("edit", r.edit().value_renderer) # r._render_label_view = ModeWrapValueRenderer("label_view", r.view().value_renderer) # r._render_label_edit = ModeWrapValueRenderer("label_edit", r.edit().value_renderer) # r._render_col_head = None # r._render_col_head_view = ModeWrapValueRenderer("col_head_view", r.view().value_renderer) # r._render_col_head_edit = ModeWrapValueRenderer("col_head_edit", r.edit().value_renderer) # r._render_col_view = ModeWrapValueRenderer("col_view", r.view().value_renderer) # r._render_col_edit = ModeWrapValueRenderer("col_edit", r.edit().value_renderer) # r._render_label = None return r
def get_fieldrow_renderer(): """ Return field row renderer object. This renders multiple fields froma supplied entity as a single row, wrapping the entire set of fields in a row <div>. """ r = RenderFieldValue("fieldrow", view_renderer=RenderFieldRow(view_fieldrow), edit_renderer=RenderFieldRow(view_fieldrow) # @@@@ change back to edit ) # Suppress all modal rendering: just render field content # @@TODO: this is a hack - need to re-think how render modes are hamndled. r._render_label = None r._render_view = ModeWrapValueRenderer("view", r._view_renderer) r._render_edit = ModeWrapValueRenderer("edit", r._edit_renderer) r._render_label_view = ModeWrapValueRenderer("label_view", r._view_renderer) r._render_label_edit = ModeWrapValueRenderer("label_edit", r._edit_renderer) r._render_col_head = None r._render_col_head_view = ModeWrapValueRenderer("col_head_view", r._view_renderer) r._render_col_head_edit = ModeWrapValueRenderer("col_head_edit", r._edit_renderer) r._render_col_view = ModeWrapValueRenderer("col_view", r._view_renderer) r._render_col_edit = ModeWrapValueRenderer("col_edit", r._edit_renderer) r._render_label = None # r._render_label = None # r._render_view = ModeWrapValueRenderer("view", r.view().value_renderer) # r._render_edit = ModeWrapValueRenderer("edit", r.edit().value_renderer) # r._render_label_view = ModeWrapValueRenderer("label_view", r.view().value_renderer) # r._render_label_edit = ModeWrapValueRenderer("label_edit", r.edit().value_renderer) # r._render_col_head = None # r._render_col_head_view = ModeWrapValueRenderer("col_head_view", r.view().value_renderer) # r._render_col_head_edit = ModeWrapValueRenderer("col_head_edit", r.edit().value_renderer) # r._render_col_view = ModeWrapValueRenderer("col_view", r.view().value_renderer) # r._render_col_edit = ModeWrapValueRenderer("col_edit", r.edit().value_renderer) # r._render_label = None return r