def __init__(self, *args, **kwargs): if 'instance' in kwargs and hasattr(kwargs['instance'], 'url_alias'): kwargs['initial']['url_alias'] = kwargs['instance'].url_alias super(QdjangoProjetForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.form_tag = False self.helper.layout = Layout( Div(Div(Div(Div(HTML( "<h3 class='box-title'><i class='ion ion-map'></i> {}</h3>". format(_('Qgis Project'))), css_class='box-header with-border'), Div( 'qgis_file', 'form_id', 'upload_url', 'delete_url', css_class='box-body', ), css_class='box box-success'), css_class='col-md-6'), crispyBoxACL(self), crispyBoxBaseLayer(self), css_class='row'), Div(Div(Div(Div(HTML( "<h3 class='box-title'><i class='fa fa-file'></i> {}</h3>". format(_('Description data'))), css_class='box-header with-border'), Div( 'title_ur', Field('description', css_class='wys5'), 'thumbnail', HTML( """<img {% if not form.thumbnail.value %}style="display:none;"{% endif %} class="img-responsive img-thumbnail" src="{{ MEDIA_URL }}{{ form.thumbnail.value }}">""", ), 'url_alias', css_class='box-body', ), css_class='box box-success'), css_class='col-md-6'), Div(Div(Div(HTML( "<h3 class='box-title'><i class='ion ion-gear'></i> {}</h3>" .format(_('Options and actions'))), css_class='box-header with-border'), Div( 'feature_count_wms', 'multilayer_query', 'multilayer_querybybbox', 'multilayer_querybypolygon', css_class='box-body', ), css_class='box box-success'), css_class='col-md-6'), css_class='row'), )
def __init__(self, *args, **kwargs): super(QdjangoProjetForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.form_tag = False self.helper.layout = Layout( Div( Div( Div( Div( HTML("<h3 class='box-title'><i class='ion ion-map'></i> {}</h3>" .format(_('Qgis Project'))), css_class='box-header with-border' ), Div( 'qgis_file', 'form_id', 'upload_url', 'delete_url', css_class='box-body', ), css_class='box box-success' ), css_class='col-md-6' ), crispyBoxACL(self), crispyBoxBaseLayer(self), Div( Div( Div( HTML("<h3 class='box-title'><i class='fa fa-file'></i> {}</h3>" .format(_('Descrition data'))), css_class='box-header with-border' ), Div( Field('description', css_class='wys5'), 'thumbnail', HTML("""<img {% if not form.thumbnail.value %}style="display:none;"{% endif %} class="img-responsive img-thumbnail" src="{{ MEDIA_URL }}{{ form.thumbnail.value }}">""", ), css_class='box-body', ), css_class='box box-success' ), css_class='col-md-12' ), css_class='row' ) )
def __init__(self, *args, **kwargs): if 'instance' in kwargs and hasattr(kwargs['instance'], 'url_alias'): kwargs['initial']['url_alias'] = kwargs['instance'].url_alias super().__init__(*args, **kwargs) # rebuild toc_tab_default by baselayers saved into part group base_layers = self.group.baselayers.count() if not base_layers: nc = list(Project.CLIENT_TOC_TABS) del (nc[1]) self.fields['toc_tab_default'].choices = nc # Check for authcfg errors if self.has_error('qgis_file'): for err in self.errors['qgis_file']: if 'authcfg' in err: try: authcfg = re.findall(r'authcfg=(\w{7})', err)[0] if QgisAuth.objects.filter(id=authcfg).count() == 0: kwargs['initial']['authentication_id'] = authcfg self.fields['authentication_id'].initial = authcfg data = self.data.copy() data['authentication_id'] = authcfg self.data = data else: # This authcfg already exists but the error might be not related if not '__all__' in self.errors: self.errors['__all__'] = [] self.errors['__all__'].append( mark_safe( _('Warning: an invalid layer is using an existing authentication configuration ({authentication_id}). Ask an administrator to check if the configuration is correct by browinsg the URL<a target=_new href="{admin_url}">{admin_url}</a>' ).format( authentication_id=authcfg, admin_url=reverse( 'admin:qdjango_qgisauth_change', args=(authcfg, ))))) except: pass self.helper = FormHelper(self) self.helper.form_tag = False self.helper.layout = Layout( Div(Div(Div(Div(HTML( "<h3 class='box-title'><i class='ion ion-map'></i> {}</h3>". format(_('Qgis Project'))), css_class='box-header with-border'), Div( 'qgis_file', 'form_id', 'upload_url', 'delete_url', css_class='box-body', ), css_class='box box-success'), css_class='col-md-6'), crispyBoxACL(self), crispyBoxBaseLayer(self), css_class='row'), Div(Div(Div(Div(HTML( "<h3 class='box-title'><i class='fa fa-file'></i> {}</h3>". format(_('Description data'))), css_class='box-header with-border'), Div( 'title_ur', Field('description', css_class='wys5'), 'thumbnail', HTML( """<img {% if not form.thumbnail.value %}style="display:none;"{% endif %} class="img-responsive img-thumbnail" src="{{ MEDIA_URL }}{{ form.thumbnail.value }}">""", ), 'url_alias', css_class='box-body', ), css_class='box box-success'), css_class='col-md-6'), Div(Div(Div(HTML( "<h3 class='box-title'><i class='ion ion-gear'></i> {}</h3>" .format(_('Options and actions'))), css_class='box-header with-border'), Div( 'use_map_extent_as_init_extent', 'toc_tab_default', 'toc_layers_init_status', 'toc_themes_init_status', 'legend_position', 'autozoom_query', 'feature_count_wms', 'multilayer_query', 'multilayer_querybybbox', 'multilayer_querybypolygon', css_class='box-body', ), css_class='box box-success'), css_class='col-md-6'), css_class='row'), ) if self.fields['authentication_id'].initial: auth_box = Div(Div(Div(HTML( """<h3 class='box-title'><i class='fa fa-lock'></i> {}</h3> <p>The error in the project suggests that one or more layers require authentication. You can add the required credentials now. Credentials will be encrypted and added to the QGIS Authentication DB.</p> <p><strong>Authentication ID: {}</strong></p>""" .format(_('QGIS Authentication'), self.fields['authentication_id'].initial)), css_class='box-header with-border'), Div( 'authentication_id', 'authentication_username', 'authentication_password', css_class='box-body', ), css_class='box box-success'), css_class='col-md-6') self.helper.layout.fields.insert(1, auth_box)
def test_crispyBoxBaseLayer(self): """ Test function utils with same name """ # Expected a Crispy div object self.assertIsInstance(crispyBoxBaseLayer(Form()), Div)