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 __init__(self, *args, **kwargs): super(GroupForm, self).__init__(*args, **kwargs) # add MacroGroups by users self.fields['macrogroups'].queryset = get_objects_for_user(self.request.user, 'view_macrogroup', MacroGroup) self.helper = FormHelper(self) self.helper.form_tag = False self.helper.layout = Layout( Div( Div( Div( Div( HTML("<h3 class='box-title'><i class='fa fa-file'></i> {}</h3>".format(_('General data'))), css_class='box-header with-border' ), Div( 'name', 'title', Field('description', css_class='wys5', style="width:100%;"), Field('lang', css_class='select2', style="width:100%;"), css_class='box-body', ), css_class='box box-success' ), css_class='col-md-6' ), crispyBoxACL(self), crispyBoxMacroGroups(self), Div( Div( Div( HTML("<h3 class='box-title'><i class='fa fa-globe'></i> {}</h3>".format(_('GEO data'))), css_class='box-header with-border' ), Div( Div( Div( Field('srid', css_class='select2', style="width:100%;"), css_class='col-md-12' ), css_class='row' ), css_class='box-body' ), css_class='box box-danger' ), css_class='col-md-6' ), Div( Div( Div( HTML("<h3 class='box-title'><i class='fa fa-map'></i> {}</h3>".format(_('Base Layers and Map default features'))), Div( HTML("<button class='btn btn-box-tool' data-widget='collapse'><i class='fa fa-minus'></i></button>"), css_class='box-tools', ), css_class='box-header with-border' ), Div( Field('mapcontrols', **{'css_class': 'select2 col-md-12', 'multiple': 'multiple', 'style': 'width:100%;'}), Field('baselayers', **{'css_class': 'select2 col-md-12', 'multiple': 'multiple', 'style': 'width:100%;'}), AppendedText('background_color', '<i></i>', css_class='colorpicker'), css_class='box-body' ), css_class='box box-danger' ), css_class='col-md-6' ), css_class='row' ), Div( Div( Div( Div( HTML("<h3 class='box-title'><i class='fa fa-file-image-o'></i> {}</h3>".format(_('Logo/Picture'))), css_class='box-header with-border' ), Div( Div( 'header_logo_img', HTML("""<img {% if not form.header_logo_img.value %}style="display:none;"{% endif %} class="img-responsive img-thumbnail" src="{{ MEDIA_URL }}{{ form.header_logo_img.value }}">""", ), 'form_id', 'upload_url', 'delete_url', css_class='col-md-12' ), Div( #AppendedText('header_logo_height','px'), 'header_logo_link', css_class='col-md-12' ), css_class='box-body' ), css_class='box box-primary' ), css_class='col-md-6' ), Div( Div( Div( HTML("<h3 class='box-title'><i class='fa fa-copyright'></i> {}</h3>".format(_('Copyright'))), Div( HTML("<button class='btn btn-box-tool' data-widget='collapse'><i class='fa fa-minus'></i></button>"), css_class='box-tools', ), css_class='box-header with-border' ), Div( Field('header_terms_of_use_text',css_class='wys5'), 'header_terms_of_use_link', css_class='box-body' ), css_class='box box-default {}'.format(self.checkEmptyInitialsData('header_terms_of_use_text','header_terms_of_use_link')) ), css_class='col-md-6' ), css_class='row' ) )