Beispiel #1
0
    def odm_ui_m_form_setup_widgets(self, frm: form.Form):
        super().odm_ui_m_form_setup_widgets(frm)

        frm.get_widget('title').h_size = 'col-12 col-xs-12 col-lg-6'
        frm.get_widget('alias').h_size = 'col-12 col-xs-12 col-lg-6'

        frm.add_widget(
            widget.input.Decimal(
                uid='lng',
                weight=350,
                label=self.t('longitude'),
                min=-180.0,
                max=180.0,
                required=self.get_field('lng').is_required,
                h_size='col-12 col-xs-12 col-sm-2 col-lg-1',
                value=self.lng,
            ))

        frm.add_widget(
            widget.input.Decimal(
                uid='lat',
                weight=355,
                label=self.t('latitude'),
                min=-90.0,
                max=90.0,
                required=self.get_field('lng').is_required,
                h_size='col-12 col-xs-12 col-sm-2 col-lg-1',
                value=self.lat,
            ))
Beispiel #2
0
    def odm_ui_m_form_setup_widgets(self, frm: form.Form):
        super().odm_ui_m_form_setup_widgets(frm)

        frm.add_widget(
            _widget.StreetSelect(
                uid='street',
                weight=50,
                label=self.t('street'),
                h_size='col-12 col-xs-12 col-lg-6',
                required=self.get_field('street').is_required,
                value=self.street,
            ))
Beispiel #3
0
    def odm_ui_m_form_setup_widgets(self, frm: form.Form):
        """Hook
        """
        super().odm_ui_m_form_setup_widgets(frm)

        if self.has_field('route_alias') and auth.get_current_user().is_admin:
            # Route alias
            frm.add_widget(widget.input.Text(
                uid='route_alias',
                label=self.t('path'),
                value=self.route_alias.alias if self.route_alias else '',
            ))
    def odm_ui_m_form_submit(self, frm: _form.Form):
        """Hook
        """
        driver_opts = {}
        for w in frm.get_widgets():
            if not w.uid.startswith('driver_opts_'):
                continue

            driver_opts[w.uid.replace('driver_opts_', '')] = w.value

        self.f_set('driver_opts', driver_opts)

        super().odm_ui_m_form_submit(frm)
Beispiel #5
0
    def odm_ui_m_form_setup_widgets(self, frm: form.Form):
        """Hook
        """
        super().odm_ui_m_form_setup_widgets(frm)

        # Starred
        if self.has_field('starred') and auth.get_current_user().has_permission('article@set_starred.' + self.model):
            frm.add_widget(widget.select.Checkbox(
                uid='starred',
                weight=50,
                label=self.t('starred'),
                value=self.starred,
            ))

        # Section
        if self.has_field('section'):
            frm.add_widget(section.widget.SectionSelect(
                uid='section',
                weight=60,
                label=self.t('section'),
                value=self.section,
                h_size='col-xs-12 col-12 col-sm-6',
                required=self.get_field('section').is_required,
            ))
Beispiel #6
0
    def odm_ui_m_form_setup_widgets(self, frm: form.Form):
        super().odm_ui_m_form_setup_widgets(frm)

        if frm.has_widget('_parent'):
            frm.remove_widget('_parent')

        frm.add_widget(
            widget.select.Checkbox(
                uid='is_container',
                weight=25,
                label=self.t('is_container'),
                value=self.is_container,
            ))

        frm.add_widget(
            content.widget.EntitySelect(
                uid='entity',
                weight=150,
                label=self.t('content'),
                required=self.get_field('entity').is_required,
                value=self.entity,
            ))
Beispiel #7
0
    def odm_ui_m_form_setup_widgets(self, frm: form.Form):
        super().odm_ui_m_form_setup_widgets(frm)

        if frm.has_widget('order'):
            frm.remove_widget('order')

        if self.has_field('enabled'):
            frm.add_widget(
                widget.select.Checkbox(
                    uid='enabled',
                    weight=10,
                    label=self.t('enabled'),
                    value=self.enabled,
                ))

        if self.has_field('new_window'):
            frm.add_widget(
                widget.select.Checkbox(
                    uid='new_window',
                    weight=20,
                    label=self.t('new_window'),
                    value=self.new_window,
                ))

        if self.has_field('path'):
            frm.add_widget(
                widget.input.Text(
                    uid='path',
                    weight=210,
                    label=self.t('path'),
                    required=self.get_field('path').is_required,
                    value=self.path,
                ))

        if self.has_field('icon'):
            frm.add_widget(
                widget.input.Text(
                    uid='icon',
                    weight=220,
                    label=self.t('icon'),
                    required=self.get_field('icon').is_required,
                    h_size='col-12 col-xs-12 col-sm-3 col-md-2 col-lg-1',
                    value=self.icon,
                ))
Beispiel #8
0
    def odm_ui_m_form_setup_widgets(self, frm: form.Form):
        """Hook
        """
        # Parent
        from ._widget import TermSelect
        frm.add_widget(
            TermSelect(
                uid='_parent',
                model=self.model,
                exclude=self if not self.is_new else None,
                exclude_descendants=True,
                label=self.t('parent'),
                append_none_item=not self.get_field('_parent').is_required,
                value=self.parent,
            ))

        # Title
        if self.has_field('title'):
            frm.add_widget(
                widget.input.Text(
                    uid='title',
                    label=lang.t('taxonomy@title'),
                    value=self.title,
                    required=self.get_field('title').is_required,
                ))

        # Alias
        if self.has_field('alias'):
            frm.add_widget(
                widget.input.Text(
                    uid='alias',
                    label=lang.t('taxonomy@alias'),
                    value=self.f_get('alias'),
                ))

        # Weight
        if self.has_field('weight'):
            frm.add_widget(
                widget.input.Integer(uid='weight',
                                     label=lang.t('taxonomy@weight'),
                                     value=self.weight,
                                     h_size='col-sm-3 col-md-2 col-lg-1'))

        # Image
        if self.has_field('image'):
            frm.add_widget(
                file_ui.widget.ImagesUpload(
                    uid='image',
                    label=lang.t('taxonomy@image'),
                    required=self.get_field('image').is_required,
                    value=self.image,
                ))

        # Language
        if self.has_field('language'):
            lng = lang.get_current() if self.is_new else self.language
            frm.add_widget(
                widget.static.Text(
                    uid='language',
                    label=lang.t('taxonomy@language'),
                    text=lang.lang_title(lng),
                    value=lng,
                    hidden=len(lang.langs()) == 1,
                ))
    def odm_ui_m_form_setup_widgets(self, frm: _form.Form):
        """Setup of a modification form.
        """
        if frm.current_step == 1:
            frm.add_widget(_widget.select.Checkbox(
                weight=10,
                uid='enabled',
                label=self.t('enabled'),
                value=self.enabled,
            ))

            frm.add_widget(_file_ui.widget.ImagesUpload(
                weight=20,
                uid='logo',
                label=self.t('logo'),
                value=self.logo,
                max_files=1,
                show_numbers=False,
                dnd=False,
            ))

            frm.add_widget(_widget.input.Text(
                weight=30,
                uid='description',
                label=self.t('description'),
                value=self.description,
            ))

            frm.add_widget(_content.widget.ModelSelect(
                weight=40,
                uid='content_model',
                label=self.t('content_model'),
                value=self.content_model,
                h_size='col-sm-4',
                required=True,
            ))

            frm.add_widget(_section.widget.SectionSelect(
                weight=50,
                uid='content_section',
                label=self.t('content_section'),
                value=self.content_section,
                h_size='col-sm-4',
                required=True,
            ))

            frm.add_widget(_content.widget.StatusSelect(
                weight=60,
                uid='content_status',
                label=self.t('content_status'),
                value=self.content_status,
                h_size='col-sm-4',
                required=True,
            ))

            frm.add_widget(_auth_ui.widget.UserSelect(
                weight=70,
                uid='content_author',
                label=self.t('content_author'),
                value=self.content_author if not self.is_new else _auth.get_current_user(),
                h_size='col-sm-4',
                required=True,
            ))

            frm.add_widget(_content_import_widget.DriverSelect(
                weight=80,
                uid='driver',
                label=self.t('driver'),
                value=self.driver,
                h_size='col-sm-4',
                required=True,
            ))

            frm.add_widget(_widget.input.Tokens(
                weight=90,
                uid='add_tags',
                label=self.t('additional_tags'),
                value=self.add_tags,
            ))

            frm.add_widget(_widget.select.DateTime(
                weight=100,
                uid='paused_till',
                label=self.t('paused_till'),
                value=self.paused_till,
                h_size='col-sm-5 col-md-4 col-lg-3',
                hidden=self.is_new,
            ))

            frm.add_widget(_widget.input.Integer(
                weight=110,
                uid='errors',
                label=self.t('errors'),
                value=self.errors,
                h_size='col-sm-1',
                hidden=self.is_new or not self.errors,
            ))

            frm.add_widget(_widget.static.Text(
                weight=120,
                uid='content_language',
                label=self.t('content_language'),
                value=self.content_language,
                text=_lang.lang_title(self.content_language),
                h_size='col-sm-4',
                required=True,
            ))

        if frm.current_step == 2:
            driver = _api.get_driver(_router.request().inp.get('driver'))
            settings_widget = driver.get_settings_widget(self.driver_opts)
            frm.add_widget(settings_widget)
Beispiel #10
0
 def odm_ui_m_form_setup(self, frm: _form.Form):
     """Hook.
     """
     frm.steps = 2
Beispiel #11
0
    def odm_ui_m_form_setup_widgets(self, frm: _form.Form):
        super().odm_ui_m_form_setup_widgets(frm)

        frm.remove_widget('_parent')
Beispiel #12
0
    def odm_ui_m_form_setup_widgets(self, frm: form.Form):
        """Hook
        """
        weight = 0
        for uid, field in self.fields.items():
            if uid.startswith('_') or field is None:
                continue

            weight += 10

            if isinstance(field, odm.field.Bool):
                frm.add_widget(
                    widget.select.Checkbox(
                        uid=uid,
                        weight=weight,
                        label=self.t(uid),
                        required=field.is_required,
                        default=field.default,
                        value=field.get_val(),
                    ))
            elif isinstance(field, odm.field.Integer):
                frm.add_widget(
                    widget.input.Integer(
                        uid=uid,
                        weight=weight,
                        label=self.t(uid),
                        required=field.is_required,
                        default=field.default,
                        value=field.get_val(),
                    ))
            elif isinstance(field, odm.field.Decimal):
                frm.add_widget(
                    widget.input.Decimal(
                        uid=uid,
                        weight=weight,
                        label=self.t(uid),
                        required=field.is_required,
                        default=field.default,
                        value=field.get_val(),
                    ))
            elif isinstance(field, odm.field.Email):
                frm.add_widget(
                    widget.input.Email(
                        uid=uid,
                        weight=weight,
                        label=self.t(uid),
                        required=field.is_required,
                        default=field.default,
                        value=field.get_val(),
                    ))
            elif isinstance(field, odm.field.String):
                frm.add_widget(
                    widget.input.Text(
                        uid=uid,
                        weight=weight,
                        label=self.t(uid),
                        required=field.is_required,
                        default=field.default,
                        value=field.get_val(),
                    ))
            elif isinstance(field, odm.field.Enum):
                frm.add_widget(
                    widget.select.Select(
                        uid=uid,
                        weight=weight,
                        label=self.t(uid),
                        required=field.is_required,
                        items=[(x, self.t(x)) for x in field.values],
                        default=field.default,
                        value=field.get_val(),
                    ))
Beispiel #13
0
    def odm_ui_m_form_setup_widgets(self, frm: form.Form):
        """Hook
        """
        from . import widget as _content_widget

        # Title
        if self.has_field('title'):
            f = self.get_field('title')  # type: odm.field.String
            frm.add_widget(widget.input.Text(
                uid='title',
                label=self.t('title'),
                required=f.is_required,
                min_length=f.min_length,
                max_length=f.max_length,
                value=self.title,
            ))

        # Description
        if self.has_field('description'):
            f = self.get_field('description')  # type: odm.field.String
            frm.add_widget(widget.input.Text(
                uid='description',
                label=self.t('description'),
                required=self.get_field('description').is_required,
                min_length=f.min_length,
                max_length=f.max_length,
                value=self.description,
            ))

        # Images
        if self.has_field('images'):
            frm.add_widget(file_ui.widget.ImagesUpload(
                uid='images',
                label=self.t('images'),
                value=self.f_get('images'),
                max_file_size=reg.get('content.max_image_size', 5),
                max_files=reg.get('content.max_images', 200),
            ))
            if self.get_field('images').is_required:
                frm.add_rule('images', validation.rule.NonEmpty())

        # Video links
        if self.has_field('video_links'):
            frm.add_widget(widget.input.StringList(
                uid='video_links',
                label=self.t('video'),
                add_btn_label=self.t('add_link'),
                value=self.video_links,
            ))
            frm.add_rule('video_links', validation.rule.VideoHostingUrl())

        # Body
        if self.has_field('body'):
            frm.add_widget(ckeditor.widget.CKEditor(
                uid='body',
                label=self.t('body'),
                value=self.f_get('body', process_tags=False),
            ))
            if self.get_field('body').is_required:
                frm.add_rule('body', validation.rule.NonEmpty())

        # Tags
        if self.has_field('tags'):
            frm.add_widget(taxonomy.widget.TokensInput(
                uid='tags',
                weight=250,
                model='tag',
                label=self.t('tags'),
                value=self.tags,
                required=self.get_field('tags').is_required,
            ))

        # External links
        if self.has_field('ext_links'):
            frm.add_widget(widget.input.StringList(
                uid='ext_links',
                weight=550,
                label=self.t('external_links'),
                add_btn_label=self.t('add_link'),
                value=self.ext_links,
                required=self.get_field('ext_links').is_required,
            ))
            frm.add_rule('ext_links', validation.rule.Url())

        # Status
        if self.has_field('status'):
            frm.add_widget(_content_widget.StatusSelect(
                uid='status',
                entity=self,
            ))

        # Publish time
        if self.has_field('publish_time') and self.odm_auth_check_entity_permissions(CONTENT_PERM_SET_PUBLISH_TIME):
            frm.add_widget(widget.select.DateTime(
                uid='publish_time',
                label=self.t('publish_time'),
                value=self.publish_time,
                h_size='col-xs-12 col-12 col-sm-4 col-md-3',
                required=self.get_field('publish_time'),
            ))

        # Language
        lng = lang.get_current() if self.is_new else self.language
        frm.add_widget(widget.static.Text(
            uid='language',
            label=self.t('language'),
            text=lang.lang_title(lng),
            value=lng,
            hidden=False if len(lang.langs()) > 1 else True,
        ))

        # Localizations
        if self.has_field('localization_' + lng) and \
                self.odm_auth_check_entity_permissions(CONTENT_PERM_SET_LOCALIZATION):
            for i, l in enumerate(lang.langs(False)):
                frm.add_widget(_content_widget.EntitySelect(
                    uid='localization_' + l,
                    label=self.t('localization', {'lang': lang.lang_title(l)}),
                    model=self.model,
                    ajax_url_query={'language': l},
                    value=self.f_get('localization_' + l)
                ))

        # Author
        if self.has_field('author') and auth.get_current_user().is_admin:
            frm.add_widget(auth_ui.widget.UserSelect(
                uid='author',
                label=self.t('author'),
                value=auth.get_current_user() if self.is_new else self.author,
                h_size='col-xs-12 col-12 col-sm-4',
                required=True,
            ))