How to use the horizon.forms.HiddenInput function in horizon

To help you get started, we’ve selected a few horizon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstack / freezer-web-ui / disaster_recovery / actions / workflows / action.py View on Github external
# See the License for the specific language governing permissions and
# limitations under the License.

from django import shortcuts
from django.utils.translation import ugettext_lazy as _

from horizon import exceptions
from horizon import forms
from horizon import workflows

import disaster_recovery.api.api as freezer_api


class ActionConfigurationAction(workflows.Action):
    action_id = forms.CharField(
        widget=forms.HiddenInput(),
        required=False)

    backup_name = forms.CharField(
        label=_("Action Name *"),
        required=False)

    action = forms.ChoiceField(
        help_text=_("Set the action to be taken"))

    mode = forms.ChoiceField(
        help_text=_("Choose what you want to backup"),
        required=False)

    storage = forms.ChoiceField(
        help_text=_("Set storage backend for a backup"))
github openstack / sahara-dashboard / sahara_dashboard / content / data_processing / jobs / job_templates / workflows / create.py View on Github external
cleaned_data['main_binary'] = None

        return cleaned_data

    class Meta(object):
        name = _("Create Job Template")
        help_text_template = "job_templates/_create_job_help.html"


class ConfigureInterfaceArgumentsAction(workflows.Action):
    hidden_arguments_field = forms.CharField(
        required=False,
        widget=forms.HiddenInput(attrs={"class": "hidden_arguments_field"}))
    argument_ids = forms.CharField(
        required=False,
        widget=forms.HiddenInput())

    def __init__(self, request, *args, **kwargs):
        super(ConfigureInterfaceArgumentsAction, self).__init__(
            request, *args, **kwargs)
        req = request.GET or request.POST
        if 'argument_ids' in req:
            self.arguments = []
            for id in json.loads(req['argument_ids']):
                fields = {
                    "name": "argument_name_" + str(id),
                    "description": "argument_description_" + str(id),
                    "mapping_type": "argument_mapping_type_" + str(id),
                    "location": "argument_location_" + str(id),
                    "value_type": "argument_value_type_" + str(id),
                    "default_value": "argument_default_value_" + str(id)}
                argument = {k: req[v]
github openstack / solum-dashboard / solumdashboard / applications / workflows / launch.py View on Github external
def __init__(self, request, *args, **kwargs):
        super(ConfigAssemblyAction, self).__init__(request, *args, **kwargs)
        if 'application_id' in request.REQUEST:
            plan_id = request.REQUEST['application_id']
            solum = solumclient(request)
            plan = solum.plans.get(plan_id=plan_id)
            plan_uri = plan.uri
        else:
            plan_uri = request.POST['plan_uri']

        self.fields["plan_uri"] = forms.CharField(
            widget=forms.HiddenInput(),
            initial=plan_uri)
github openstack / sahara-dashboard / saharadashboard / jobs / workflows / launch.py View on Github external
def __init__(self, request, *args, **kwargs):
        super(JobExecutionGeneralConfigAction, self).__init__(request,
                                                              *args,
                                                              **kwargs)

        if request.REQUEST.get("job_id", None) is None:
            self.fields["job"] = forms.ChoiceField(
                label=_("Job"),
                required=True)
            self.fields["job"].choices = self.populate_job_choices(request)
        else:
            self.fields["job"] = forms.CharField(
                widget=forms.HiddenInput(),
                initial=request.REQUEST.get("job_id", None))
github openstack / horizon / openstack_dashboard / dashboards / admin / networks / agents / forms.py View on Github external
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

from django.urls import reverse
from django.utils.translation import ugettext_lazy as _

from horizon import exceptions
from horizon import forms
from horizon import messages

from openstack_dashboard import api


class AddDHCPAgent(forms.SelfHandlingForm):
    network_id = forms.CharField(widget=forms.HiddenInput())
    network_name = forms.CharField(label=_("Network Name"),
                                   widget=forms.TextInput(
                                   attrs={'readonly': 'readonly'}))
    agent = forms.ThemableChoiceField(
        label=_("New DHCP Agent"),
        help_text=_("Choose an DHCP Agent to attach to."))

    def __init__(self, request, *args, **kwargs):
        super(AddDHCPAgent, self).__init__(request, *args, **kwargs)
        initial = kwargs.get('initial', {})
        self.fields['agent'].choices = self._populate_agent_choices(request,
                                                                    initial)

    def _populate_agent_choices(self, request, initial):
        network_id = initial.get('network_id')
        agents = initial.get('agents')
github openstack / horizon / openstack_dashboard / dashboards / project / images / snapshots / forms.py View on Github external
#    under the License.

from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from novaclient import exceptions as nova_exceptions

from horizon import exceptions
from horizon import forms
from horizon import messages

from openstack_dashboard import api


class CreateSnapshot(forms.SelfHandlingForm):
    instance_id = forms.CharField(label=_("Instance ID"),
                                  widget=forms.HiddenInput(),
                                  required=False)
    name = forms.CharField(max_length=255, label=_("Snapshot Name"))

    def handle(self, request, data):
        try:
            snapshot = api.nova.snapshot_create(request,
                                                data['instance_id'],
                                                data['name'])
            # NOTE(gabriel): This API call is only to display a pretty name.
            instance = api.nova.server_get(request, data['instance_id'])
            vals = {"name": data['name'], "inst": instance.name}
            messages.success(request, _('Snapshot "%(name)s" created for '
                                        'instance "%(inst)s"') % vals)
            return snapshot
        except nova_exceptions.Forbidden as exc:
            if str(exc).startswith('Quota exceeded for resources: snapshots'):
github openstack / horizon / horizon / dashboards / project / instances / forms.py View on Github external
import logging

from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _

from horizon import api
from horizon import exceptions
from horizon import forms
from horizon import messages


LOG = logging.getLogger(__name__)


class UpdateInstance(forms.SelfHandlingForm):
    tenant_id = forms.CharField(widget=forms.HiddenInput)
    instance = forms.CharField(widget=forms.HiddenInput)
    name = forms.CharField(required=True)

    def handle(self, request, data):
        try:
            server = api.server_update(request, data['instance'], data['name'])
            messages.success(request,
                             _('Instance "%s" updated.') % data['name'])
            return server
        except:
            redirect = reverse("horizon:project:instances:index")
            exceptions.handle(request,
                              _('Unable to update instance.'),
                              redirect=redirect)
github openstack / horizon / openstack_dashboard / dashboards / admin / defaults / workflows.py View on Github external
def __init__(self, request, *args, **kwargs):
        super(UpdateDefaultQuotasAction, self).__init__(request,
                                                        *args,
                                                        **kwargs)
        disabled_quotas = quotas.get_disabled_quotas(request)
        for field in disabled_quotas:
            if field in self.fields:
                self.fields[field].required = False
                self.fields[field].widget = forms.HiddenInput()
github openstack / freezer-web-ui / disaster_recovery / jobs / workflows / create.py View on Github external
no_available_text = _("No clients found.")
    no_members_text = _("No clients selected.")
    show_roles = False
    contributes = ("clients",)

    def contribute(self, data, context):
        request = self.workflow.request
        if data:
            field_name = self.get_member_field_name('member')
            context["clients"] = request.POST.getlist(field_name)
        return context


class InfoConfigurationAction(workflows.Action):
    actions = forms.CharField(
        widget=forms.HiddenInput(),
        required=False)

    description = forms.CharField(
        label=_("Job Name"),
        help_text=_("Set a name for this job"))

    job_id = forms.CharField(
        widget=forms.HiddenInput(),
        required=False)

    schedule_start_date = forms.CharField(
        label=_("Start Date and Time"),
        required=False)

    interval_uint = forms.ChoiceField(
        label=_("Interval Unit"),
github openstack / horizon / openstack_dashboard / dashboards / project / access_and_security / security_groups / forms.py View on Github external
class UpdateGroup(GroupBase):
    success_message = _('Successfully updated security group: %s')
    error_message = _('Unable to update security group: %s')

    id = forms.CharField(widget=forms.HiddenInput())

    def _call_network_api(self, request, data):
        return api.network.security_group_update(request,
                                                 data['id'],
                                                 data['name'],
                                                 data['description'])


class AddRule(forms.SelfHandlingForm):
    id = forms.CharField(widget=forms.HiddenInput())
    rule_menu = forms.ChoiceField(label=_('Rule'),
                                  widget=forms.Select(attrs={
                                      'class': 'switchable',
                                      'data-slug': 'rule_menu'}))

    # "direction" field is enabled only when custom mode.
    # It is because most common rules in local_settings.py is meaningful
    # when its direction is 'ingress'.
    direction = forms.ChoiceField(
        label=_('Direction'),
        required=False,
        widget=forms.Select(attrs={
            'class': 'switched',
            'data-switch-on': 'rule_menu',
            'data-rule_menu-tcp': _('Direction'),
            'data-rule_menu-udp': _('Direction'),