예제 #1
0
    def test_Repeat_Ref_Multifield_edit(self):
        self._create_image_multifield_repeat_ref_and_view()

        # Render view of multifield reference
        u = entitydata_edit_url("edit",
                                "testcoll",
                                "ref_type",
                                "Test_rpt_entity",
                                view_id="Test_rptimg_view")
        r = self.client.get(u)
        self.assertEqual(r.status_code, 200)
        self.assertEqual(r.reason_phrase, "OK")

        # Check render context
        self.assertEqual(r.context['coll_id'], "testcoll")
        self.assertEqual(r.context['type_id'], "ref_type")
        self.assertEqual(r.context['entity_id'], "Test_rpt_entity")
        self.assertEqual(r.context['action'], "edit")
        # Fields
        self.assertEqual(len(r.context['fields']), 2)
        # 1st field - Id
        f0 = context_view_field(r.context, 0, 0)
        self.assertEqual(f0['field_id'], "Entity_id")
        self.assertEqual(f0['field_name'], "entity_id")
        self.assertEqual(f0['field_label'], "Id")
        self.assertEqual(f0['field_value'], "Test_rpt_entity")
        # 2nd field - multifield group
        f1 = context_view_field(r.context, 1, 0)
        self.assertEqual(f1['field_id'], "Test_rptref_field")
        self.assertEqual(f1['field_name'], "Test_rptref_field")
        self.assertEqual(f1['field_label'], "Repeat image reference")
        self.assertEqual(f1['field_render_type'], "Group_Seq_Row")
        self.assertEqual(f1['field_value_mode'], "Value_direct")
        self.assertEqual(f1['field_value_type'], "annal:Field_group")
        self.assertEqual(f1['field_group_ref'], "Test_rptref_group")
        self.assertEqual(f1['group_label'], "Repeat image reference")
        self.assertEqual(f1['field_property_uri'], "test:rpt_image")
        self.assertEqual(f1['field_value'][0],
                         {'test:ref_image': 'Test_img_entity'})

        # Test rendered result
        field_vals = default_fields(
            coll_id="testcoll",
            type_id="ref_type",
            entity_id="Test_rpt_entity",
            view_id="Test_rptimg_view",
            basepath=TestBasePath,
            tooltip1=f0['field_help'],
        )
        formrow1 = """
            <div class="small-12 medium-6 columns" title="%(tooltip1)s">
              <div class="row view-value-row">
                <div class="%(label_classes)s">
                  <span>Id</span>
                </div>
                <div class="%(input_classes)s">
                    <input type="text" size="64" name="entity_id"
                           placeholder="(entity id)"
                           value="%(entity_id)s"/>
                </div>
              </div>
            </div>
            """ % field_vals(width=6)
        formrow2a = """
            <div class="group-label small-12 medium-2 columns">
              <span>Repeat image reference</span>
            </div>
            """
        formrow2b = """
            <div class="small-12 medium-10 columns hide-for-small-only">
              <div class="row">
                <div class="small-1 columns">
                  &nbsp;
                </div>
                <div class="small-11 columns">
                  <div class="edit-grouprow col-head row">
                    <div class="%(col_head_classes)s">
                      <span>Image reference</span>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            """ % field_vals(width=6)

        tgt_field_vals = default_fields(
            coll_id="testcoll",
            type_id="img_type",
            entity_id="Test_img_entity",
            view_id="Test_rptimg_view",
            repeat_id="Test_rptref_field",
            field_id="Test_refimg_field",
            tooltip3b=f1._field_description['group_field_descs'][0]
            ['field_help'])
        formrow3a = """
            <div class="small-12 medium-2 columns hide-for-small-only">
              &nbsp;
            </div>
            """ % tgt_field_vals(width=6)
        formrow3b = ("""
            <div class="small-12 medium-10 columns">
              <div class="tbody row select-row">
                <div class="small-1 columns checkbox-in-edit-padding">
                  <input type="checkbox" class="select-box right"
                         name="%(repeat_id)s__select_fields"
                         value="0" />
                </div>
                <div class="small-11 columns">
                  <div class="edit-grouprow row">
                    <div class="%(col_item_classes)s" title="%(tooltip3b)s">
                      <div class="row show-for-small-only">
                        <div class="view-label small-12 columns">
                          <span>Image reference</span>
                        </div>
                      </div>
                      <div class="row view-value-col">
                        <div class="view-value small-12 columns">
                        """ + render_select_options(
            "%(repeat_id)s__0__%(field_id)s", "Image reference", [
                FieldChoice("%(type_id)s/%(entity_id)s",
                            label="Label %(entity_id)s")
            ], "%(type_id)s/%(entity_id)s") + """
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            """) % tgt_field_vals(width=6)
        # log.info(r.content)
        self.assertContains(r, formrow1, html=True)
        self.assertContains(r, formrow2a, html=True)
        self.assertContains(r, formrow2b, html=True)
        self.assertContains(r, formrow3a, html=True)
        self.assertContains(r, formrow3b, html=True)
        return
예제 #2
0
    def test_Repeat_Ref_Multifield_edit(self):
        self._create_image_multifield_repeat_ref_and_view()

        # Render view of multifield reference
        u = entitydata_edit_url("edit", "testcoll", "ref_type", "Test_rpt_entity", view_id="Test_rptimg_view")
        response = self.client.get(u)
        self.assertEqual(response.status_code,   200)
        self.assertEqual(response.reason_phrase, "OK")

        # Check render context
        expect_context = self._create_rptref_view_context(
            entity_id="Test_rpt_entity",
            action="edit",
            continuation_url=""
            )
        actual_context = context_bind_fields(response.context)
        self.assertEqual(len(response.context['fields']), 2)
        self.assertDictionaryMatch(actual_context, expect_context)

        f0 = context_view_field(response.context, 0, 0)
        f1 = context_view_field(response.context, 1, 0)

        # Test rendered result
        field_vals    = default_fields(
            coll_id="testcoll", type_id="ref_type", entity_id="Test_rpt_entity", 
            view_id="Test_rptimg_view",
            basepath=TestBasePath,
            tooltip1=f0['field_tooltip'],
            )
        formrow1 = """
            <div class="small-12 medium-6 columns" title="%(tooltip1)s">
              <div class="row view-value-row">
                <div class="%(label_classes)s">
                  <span>Id</span>
                </div>
                <div class="%(input_classes)s">
                    <input type="text" size="64" name="entity_id"
                           placeholder="(entity id)"
                           value="%(entity_id)s"/>
                </div>
              </div>
            </div>
            """%field_vals(width=6)
        formrow2a = """
            <div class="group-label small-12 medium-2 columns">
              <span>Repeat image reference</span>
            </div>
            """
        formrow2b = """
            <div class="small-12 medium-10 columns hide-for-small-only">
              <div class="row">
                <div class="small-1 columns">
                  &nbsp;
                </div>
                <div class="small-11 columns">
                  <div class="edit-grouprow col-head row">
                    <div class="%(col_head_classes)s">
                      <span>Image reference</span>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            """%field_vals(width=6)

        tgt_field_vals = default_fields(
            coll_id="testcoll", type_id="img_type", entity_id="Test_img_entity", 
            view_id="Test_rptimg_view",
            repeat_id="Test_rptref_field",
            field_id="Test_refimg_field",
            tooltip3b=f1._field_description['group_field_descs'][0]['field_tooltip_test']
            )
        formrow3a = """
            <div class="small-12 medium-2 columns hide-for-small-only">
              &nbsp;
            </div>
            """%tgt_field_vals(width=6)
        formrow3b = ("""
            <div class="small-12 medium-10 columns">
              <div class="tbody row select-row">
                <div class="small-1 columns checkbox-in-edit-padding">
                  <input type="checkbox" class="select-box right"
                         name="%(repeat_id)s__select_fields"
                         value="0" />
                </div>
                <div class="small-11 columns">
                  <div class="edit-grouprow row">
                    <div class="%(col_item_classes)s" title="%(tooltip3b)s">
                      <div class="row show-for-small-only">
                        <div class="view-label small-12 columns">
                          <span>Image reference</span>
                        </div>
                      </div>
                      <div class="row view-value-col">
                        <div class="view-value small-12 columns">
                        """+
                        render_select_options(
                            "%(repeat_id)s__0__%(field_id)s", 
                            "Image reference",
                            [FieldChoice("%(type_id)s/%(entity_id)s", label="Label %(entity_id)s")],
                            "%(type_id)s/%(entity_id)s"
                            )+
                        """
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            """)%tgt_field_vals(width=6)
        # log.info(r.content)
        self.assertContains(response, formrow1,  html=True)
        self.assertContains(response, formrow2a, html=True)
        self.assertContains(response, formrow2b, html=True)
        self.assertContains(response, formrow3a, html=True)
        self.assertContains(response, formrow3b, html=True)
        return
예제 #3
0
    def test_Ref_Multifield_edit(self):
        self._create_image_multifield_ref_and_view()

        # Render view of multifield reference
        u = entitydata_edit_url("edit",
                                "testcoll",
                                "ref_type",
                                "Test_ref_entity",
                                view_id="Test_refimg_view")
        r = self.client.get(u)
        self.assertEqual(r.status_code, 200)
        self.assertEqual(r.reason_phrase, "OK")

        # Check render context
        self.assertEqual(r.context['coll_id'], "testcoll")
        self.assertEqual(r.context['type_id'], "ref_type")
        self.assertEqual(r.context['entity_id'], "Test_ref_entity")
        self.assertEqual(r.context['action'], "edit")
        # Fields
        self.assertEqual(len(r.context['fields']), 1)
        # 1st field - Id
        f0 = context_view_field(r.context, 0, 0)
        self.assertEqual(f0['field_id'], "Entity_id")
        self.assertEqual(f0['field_name'], "entity_id")
        self.assertEqual(f0['field_label'], "Id")
        self.assertEqual(f0['field_value'], "Test_ref_entity")
        # 2nd field - multifield group
        f1 = context_view_field(r.context, 0, 1)
        self.assertEqual(f1['field_id'], "Test_refimg_field")
        self.assertEqual(f1['field_name'], "Test_refimg_field")
        self.assertEqual(f1['field_label'], "Image reference")
        self.assertEqual(f1['field_render_type'], "RefMultifield")
        self.assertEqual(f1['field_value_mode'], "Value_entity")
        self.assertEqual(f1['field_value_type'], "annal:Field_group")
        self.assertEqual(f1['field_group_ref'], "Test_refimg_group")
        self.assertEqual(f1['group_label'], "Image reference")
        self.assertEqual(f1['field_property_uri'], "test:ref_image")
        self.assertEqual(f1['field_value'], "Test_img_entity")

        # Test rendered result
        field_vals = default_fields(
            coll_id="testcoll",
            type_id="ref_type",
            entity_id="Test_ref_entity",
            view_id="Test_refimg_view",
            basepath=TestBasePath,
            tooltip1=f0['field_help'],
        )
        formrow1 = """
            <div class="small-12 medium-6 columns" title="%(tooltip1)s">
              <div class="row view-value-row">
                <div class="%(label_classes)s">
                  <span>Id</span>
                </div>
                <div class="%(input_classes)s">
                  <input type="text" size="64" name="entity_id"
                         placeholder="(entity id)"
                         value="%(entity_id)s"/>
                </div>
              </div>
            </div>
            """ % field_vals(width=6)

        tgt_field_vals = default_fields(
            coll_id="testcoll",
            type_id="img_type",
            entity_id="Test_img_entity",
            view_id="Test_refimg_view",
            field_id="Test_refimg_field",
            basepath=TestBasePath,
            tooltip2=f1['field_help'],
        )
        formrow2 = ("""
            <div class="small-12 medium-6 columns" title="%(tooltip2)s">
              <div class="row view-value-row">
                <div class="%(label_classes)s">
                  <span>Image reference</span>
                </div>
                <div class="%(input_classes)s">
                """ +
                    render_select_options("%(field_id)s", "Image reference", [
                        FieldChoice("%(type_id)s/%(entity_id)s",
                                    label="Label %(entity_id)s")
                    ], "%(type_id)s/%(entity_id)s") + """
                </div>
              </div>
            </div>
            """) % tgt_field_vals(width=6)
        # log.info(r.content)
        self.assertContains(r, formrow1, html=True)
        self.assertContains(r, formrow2, html=True)
        return
예제 #4
0
    def test_Ref_Multifield_edit(self):
        self._create_image_multifield_ref_and_view()

        # Render edit view of multifield reference
        u = entitydata_edit_url("edit", "testcoll", "ref_type", "Test_ref_entity", view_id="Test_refimg_view")
        response = self.client.get(u)
        self.assertEqual(response.status_code,   200)
        self.assertEqual(response.reason_phrase, "OK")

        # Check render context
        expect_context = self._create_refimg_view_context(
            entity_id="Test_ref_entity",
            entity_ref="Test_img_entity",
            action="edit",
            continuation_url=""
            )
        actual_context = context_bind_fields(response.context)
        self.assertEqual(len(response.context['fields']), 1)
        self.assertDictionaryMatch(actual_context, expect_context)

        # Test rendered result
        f0 = context_view_field(response.context, 0, 0)
        f1 = context_view_field(response.context, 0, 1)
        field_vals    = default_fields(
            coll_id="testcoll", type_id="ref_type", entity_id="Test_ref_entity", 
            view_id="Test_refimg_view",
            basepath=TestBasePath,
            tooltip1=f0['field_tooltip'],
            )
        formrow1 = """
            <div class="small-12 medium-6 columns" title="%(tooltip1)s">
              <div class="row view-value-row">
                <div class="%(label_classes)s">
                  <span>Id</span>
                </div>
                <div class="%(input_classes)s">
                  <input type="text" size="64" name="entity_id"
                         placeholder="(entity id)"
                         value="%(entity_id)s"/>
                </div>
              </div>
            </div>
            """%field_vals(width=6)

        tgt_field_vals = default_fields(
            coll_id="testcoll", type_id="img_type", entity_id="Test_img_entity",
            view_id="Test_refimg_view",
            field_id="Test_refimg_field",
            basepath=TestBasePath,
            tooltip2=f1['field_tooltip'],
            )
        formrow2 = ("""
            <div class="small-12 medium-6 columns" title="%(tooltip2)s">
              <div class="row view-value-row">
                <div class="%(label_classes)s">
                  <span>Image reference</span>
                </div>
                <div class="%(input_classes)s">
                """+
                render_select_options(
                    "%(field_id)s", 
                    "Image reference",
                    [FieldChoice("%(type_id)s/%(entity_id)s", label="Label %(entity_id)s")],
                    "%(type_id)s/%(entity_id)s"
                    )+
                """
                </div>
              </div>
            </div>
            """)%tgt_field_vals(width=6)
        # log.info(r.content)
        self.assertContains(response, formrow1,  html=True)
        self.assertContains(response, formrow2,  html=True)
        return
예제 #5
0
 def test_get_form_rendering_view_bibentry(self):
     u = entitydata_edit_url("edit",
                             "testcoll",
                             layout.VIEW_TYPEID,
                             entity_id="BibEntry_view",
                             view_id="View_view")
     r = self.client.get(u)
     self.assertEqual(r.status_code, 200)
     self.assertEqual(r.reason_phrase, "OK")
     field_vals = default_fields(
         coll_id="testcoll",
         type_id=layout.VIEW_TYPEID,
         entity_id="BibEntry_view",
         tooltip1=context_view_field(r.context, 0, 0)['field_tooltip'],
         tooltip2=context_view_field(r.context, 1, 0)['field_tooltip'],
         tooltip3=context_view_field(r.context, 2, 0)['field_tooltip'],
         tooltip5=context_view_field(r.context, 4, 0)['field_tooltip'],
         tooltip6=context_view_field(
             r.context, 5, 0)._field_description['group_field_descs'][0]
         ['field_tooltip_test'])
     formrow1 = """
         <div class="small-12 medium-6 columns" title="%(tooltip1)s">
           <div class="row view-value-row">
             <div class="%(label_classes)s">
               <span>View Id</span>
             </div>
             <div class="%(input_classes)s">
               <input type="text" size="64" name="entity_id" 
                      placeholder="(view id)" value="%(entity_id)s"/>
             </div>
           </div>
         </div>
         """ % field_vals(width=6)
     formrow2 = """
         <div class="small-12 columns" title="%(tooltip2)s">
           <div class="row view-value-row">
             <div class="%(label_classes)s">
               <span>Label</span>
             </div>
             <div class="%(input_classes)s">
               <input type="text" size="64" name="View_label"
                      placeholder="(view label)" 
                      value="Bibliographic metadata"/>
             </div>
           </div>
         </div>
         """ % field_vals(width=12)
     formrow3 = """
         <div class="small-12 columns" title="%(tooltip3)s">
           <div class="row view-value-row">
             <div class="%(label_classes)s">
               <span>Help</span>
             </div>
             <div class="%(input_classes)s">
               <textarea cols="64" rows="6" name="View_comment" 
                         class="small-rows-4 medium-rows-8"
                         placeholder="(description of record view)">
                   Bibliography entries each contain some subset of standard data entries.
               </textarea>
             </div>
           </div>
         </div>
         """ % field_vals(width=12)
     formrow5 = """
         <div class="small-12 medium-6 columns" title="%(tooltip5)s">
           <div class="row view-value-row">
             <div class="%(label_classes)s">
               <span>Editable view?</span>
             </div>
             <div class="%(input_classes)s">
               <input type="checkbox" name="View_edit_view" value="Yes" checked="checked" />
                <span class="value-placeholder">(edit view from edit entity form)</span>
             </div>
           </div>
         </div>
         """ % field_vals(width=6)
     formrow6 = ("""
         <div class="small-12 medium-4 columns" title="%(tooltip6)s">
           <div class="row show-for-small-only">
             <div class="view-label small-12 columns">
               <span>Field ref</span>
             </div>
           </div>
           <div class="row view-value-col">
             <div class="view-value small-12 columns">
             """ + render_select_options("View_fields__0__View_field_sel",
                                         "Field ref",
                                         no_selection("(field reference)") +
                                         get_site_bibentry_fields_sorted(),
                                         layout.FIELD_TYPEID + "/Entity_id",
                                         placeholder="(field reference)") +
                 """
             </div>
           </div>
         </div>
         """) % field_vals(width=4)
     formrow7 = """
         <div class="small-1 columns checkbox-in-edit-padding">
           <input type="checkbox" class="select-box right" 
                  name="View_fields__select_fields"
                  value="0" />
         </div>        
         """
     # log.info("*** BibEntry_view content: "+r.content)
     # log.info("*** %r"%(r.context['fields'][5]._field_description['field_help']))
     # log.info("*** %r"%(r.context['fields'][5]._field_description['group_field_descs'][0]['field_tooltip_test']))
     self.assertContains(r, formrow1, html=True)
     self.assertContains(r, formrow2, html=True)
     self.assertContains(r, formrow3, html=True)
     self.assertContains(r, formrow5, html=True)
     self.assertContains(r, formrow6, html=True)
     self.assertContains(r, formrow7, html=True)
     return
 def test_get_form_rendering(self):
     u = entitydata_edit_url("new", "testcoll", "testtype")
     r = self.client.get(u + "?continuation_url=/xyzzy/")
     self.assertEqual(r.status_code, 200)
     self.assertEqual(r.reason_phrase, "OK")
     self.assertContains(r, "Collection testcoll")
     field_vals = default_fields(coll_id="testcoll",
                                 type_id="testtype",
                                 entity_id="00000001")
     formrow1 = """
           <!-- editable text field -->
           <div class="small-12 medium-6 columns">
             <div class="row">
               <div class="%(label_classes)s">
                 <p>
                   Id
                 </p>
               </div>
               <div class="%(input_classes)s">
                 <!-- cf http://stackoverflow.com/questions/1480588/input-size-vs-width -->
                 <input type="text" size="64" name="entity_id" 
                        placeholder="(entity id)" value="00000001">
               </div>
             </div>
           </div>
         """ % field_vals(width=6)
     formrow2 = ("""
           <!-- record type dropdown -->
           <div class="small-12 medium-6 columns">
             <div class="row">
               <div class="%(label_classes)s">
                 <p>
                   Type
                 </p>
               </div>
               <div class="%(input_classes)s">
               """ + render_select_options(
         "entity_type", "Type",
         get_site_types_sorted() + ["testtype"], "testtype") + """
               </div>
             </div>
           </div>
         """) % field_vals(width=6)
     formrow3 = """
           <!-- editable text field -->
           <div class="small-12 columns">
             <div class="row">
               <div class="%(label_classes)s">
                 <p>
                   Label
                 </p>
               </div>
               <div class="%(input_classes)s">
                 <!-- cf http://stackoverflow.com/questions/1480588/input-size-vs-width -->
                 <input type="text" size="64" name="Entity_label" 
                        placeholder="(label)" 
                        value="%(default_label_esc)s">
               </div>
             </div>
           </div>
         """ % field_vals(width=12)
     formrow4 = """
           <!-- editable textarea field -->
           <div class="small-12 columns">
             <div class="row">
               <div class="%(label_classes)s">
                 <p>
                   Comment
                 </p>
               </div>
               <div class="%(input_classes)s">
                 <textarea cols="64" rows="6" name="Entity_comment" 
                           class="small-rows-4 medium-rows-8"
                           placeholder="(description)">
                     %(default_comment_esc)s
                 </textarea>
               </div>
             </div>
           </div>
         """ % field_vals(width=12)
     # log.info("******\n"+r.content)
     self.assertContains(r, formrow1, html=True)
     self.assertContains(r, formrow2, html=True)
     self.assertContains(r, formrow3, html=True)
     self.assertContains(r, formrow4, html=True)
     return
예제 #7
0
 def test_get_form_rendering_view_bibentry(self):
     u = entitydata_edit_url(
         "edit", "testcoll", layout.VIEW_TYPEID, entity_id="BibEntry_view", 
         view_id="View_view"
         )
     r = self.client.get(u)
     self.assertEqual(r.status_code,   200)
     self.assertEqual(r.reason_phrase, "OK")
     field_vals = default_fields(
         coll_id="testcoll", type_id=layout.VIEW_TYPEID, entity_id="BibEntry_view",
         tooltip1=context_view_field(r.context, 0, 0)['field_help'],
         tooltip2=context_view_field(r.context, 1, 0)['field_help'],
         tooltip3=context_view_field(r.context, 2, 0)['field_help'],
         tooltip4=context_view_field(r.context, 4, 0)['field_help'],
         tooltip5=context_view_field(r.context, 5, 0)._field_description['group_field_descs'][0]['field_help']
       )
     formrow1 = """
         <div class="small-12 medium-6 columns" title="%(tooltip1)s">
           <div class="row view-value-row">
             <div class="%(label_classes)s">
               <span>View Id</span>
             </div>
             <div class="%(input_classes)s">
               <input type="text" size="64" name="entity_id" 
                      placeholder="(view id)" value="%(entity_id)s"/>
             </div>
           </div>
         </div>
         """%field_vals(width=6)
     formrow2 = """
         <div class="small-12 columns" title="%(tooltip2)s">
           <div class="row view-value-row">
             <div class="%(label_classes)s">
               <span>Label</span>
             </div>
             <div class="%(input_classes)s">
               <input type="text" size="64" name="View_label"
                      placeholder="(view label)" 
                      value="Bibliographic metadata"/>
             </div>
           </div>
         </div>
         """%field_vals(width=12)
     formrow3 = """
         <div class="small-12 columns" title="%(tooltip3)s">
           <div class="row view-value-row">
             <div class="%(label_classes)s">
               <span>Help</span>
             </div>
             <div class="%(input_classes)s">
               <textarea cols="64" rows="6" name="View_comment" 
                         class="small-rows-4 medium-rows-8"
                         placeholder="(description of record view)">
                   Bibliography entries each contain some subset of standard data entries.
               </textarea>
             </div>
           </div>
         </div>
         """%field_vals(width=12)
     formrow4 = """
         <div class="small-12 medium-6 columns" title="%(tooltip4)s">
           <div class="row view-value-row">
             <div class="%(label_classes)s">
               <span>Editable view?</span>
             </div>
             <div class="%(input_classes)s">
               <input type="checkbox" name="View_edit_view" value="Yes" checked="checked" />
                <span class="value-placeholder">(edit view from edit entity form)</span>
             </div>
           </div>
         </div>
         """%field_vals(width=6)
     formrow5 = ("""
         <div class="small-12 medium-4 columns" title="%(tooltip5)s">
           <div class="row show-for-small-only">
             <div class="view-label small-12 columns">
               <span>Field id</span>
             </div>
           </div>
           <div class="row view-value-col">
             <div class="view-value small-12 columns">
             """+
               render_select_options(
                 "View_fields__0__Field_id", "Field id",
                 no_selection("(field sel)") + get_site_bibentry_fields_sorted(),
                 layout.FIELD_TYPEID+"/Entity_id",
                 placeholder="(field sel)"
                 )+
             """
             </div>
           </div>
         </div>
         """)%field_vals(width=4)
     formrow6 = """
         <div class="small-1 columns checkbox-in-edit-padding">
           <input type="checkbox" class="select-box right" 
                  name="View_fields__select_fields"
                  value="0" />
         </div>        
         """
     # log.info("*** BibEntry_view content: "+r.content)
     # log.info("*** %r"%(r.context['fields'][5]._field_description['field_help']))
     self.assertContains(r, formrow1, html=True)
     self.assertContains(r, formrow2, html=True)
     self.assertContains(r, formrow3, html=True)
     self.assertContains(r, formrow4, html=True)
     self.assertContains(r, formrow5, html=True)
     self.assertContains(r, formrow6, html=True)
     return
예제 #8
0
 def test_get_form_rendering(self):
     u = entitydata_edit_url("new",
                             "testcoll",
                             "_list",
                             view_id="List_view")
     r = self.client.get(u + "?continuation_url=/xyzzy/")
     self.assertEqual(r.status_code, 200)
     self.assertEqual(r.reason_phrase, "OK")
     self.assertContains(r,
                         "<h3>'_list' data in collection 'testcoll'</h3>")
     field_vals = default_fields(coll_id="testcoll",
                                 type_id="_list",
                                 entity_id="00000001")
     formrow1a = """
         <div class="small-12 medium-6 columns">
           <div class="row">
             <div class="%(label_classes)s">
               <p>Id</p>
             </div>
             <div class="%(input_classes)s">
               <input type="text" size="64" name="entity_id" 
                      placeholder="(list id)" 
                      value="00000001"/>
             </div>
           </div>
         </div>
         """ % field_vals(width=6)
     formrow1b = ("""
         <div class="small-12 medium-6 columns">
           <div class="row">
             <div class="%(label_classes)s">
               <p>List display type</p>
             </div>
             <div class="%(input_classes)s">
             """ + render_choice_options(
         "List_type", get_site_list_types_sorted(), "List") + """
             </div>
           </div>
         </div>
         """) % field_vals(width=6)
     formrow2 = """
         <div class="small-12 columns">
           <div class="row">
             <div class="%(label_classes)s">
               <p>Label</p>
             </div>
             <div class="%(input_classes)s">
               <input type="text" size="64" name="List_label" 
                      placeholder="(list label)" 
                      value="%(default_label_esc)s"/>
             </div>
           </div>
         </div>
         """ % field_vals(width=12)
     formrow3 = """
         <div class="small-12 columns">
           <div class="row">
             <div class="%(label_classes)s">
               <p>Help</p>
             </div>
             <div class="%(input_classes)s">
               <textarea cols="64" rows="6" name="List_comment" 
                       class="small-rows-4 medium-rows-8"
                       placeholder="(description of list view)">
                 %(default_comment_esc)s
               </textarea>
             </div>
           </div>
         </div>
         """ % field_vals(width=12)
     formrow4 = ("""
         <div class="small-6 columns">
           <div class="row">
             <div class="%(label_classes)s">
               <p>Record type</p>
             </div>
             <div class="%(input_classes)s">
             """ + render_select_options(
         "List_default_type", "Record type",
         get_site_types_sorted() + ["testtype"], "Default_type") + """
             </div>
           </div>
         </div>
         """) % field_vals(width=6)
     formrow5 = ("""
         <div class="small-6 columns">
           <div class="row">
             <div class="%(label_classes)s">
               <p>View</p>
             </div>
             <div class="%(input_classes)s">
             """ + render_select_options("List_default_view", "View",
                                         sorted(get_site_views()),
                                         "Default_view") + """
             </div>
           </div>
         </div>
         """) % field_vals(width=6)
     selector_text = ("(entity selector; " + "e.g. &#39;ALL&#39;, " +
                      "&#39;<type> in [@type]&#39;, " +
                      "&#39;[<field>]==<value>&#39;, " + "etc.)")
     formrow6 = """
         <div class="small-12 columns">
           <div class="row">
             <div class="%(label_classes)s">
               <p>Selector</p>
             </div>
             <div class="%(input_classes)s">
               <input type="text" size="64" name="List_entity_selector" 
                      placeholder="%(selector_text)s"
                      value="ALL"/>
             </div>
           </div>
         </div>
         """ % dict(field_vals(width=12), selector_text=selector_text)
     # log.info(r.content)     #@@
     self.assertContains(r, formrow1a, html=True)
     self.assertContains(r, formrow1b, html=True)
     self.assertContains(r, formrow2, html=True)
     self.assertContains(r, formrow3, html=True)
     self.assertContains(r, formrow4, html=True)
     self.assertContains(r, formrow5, html=True)
     self.assertContains(r, formrow6, html=True)
     return