How to use the horizon.forms.CharField 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 / horizon / openstack_dashboard / dashboards / project / loadbalancers / workflows.py View on Github external
default_steps = (AddPoolStep,)

    def format_status_message(self, message):
        name = self.context.get('name')
        return message % name

    def handle(self, request, context):
        try:
            api.lbaas.pool_create(request, **context)
            return True
        except Exception:
            return False


class AddVipAction(workflows.Action):
    name = forms.CharField(max_length=80, label=_("Name"))
    description = forms.CharField(
        initial="", required=False,
        max_length=80, label=_("Description"))
    subnet_id = forms.ThemableChoiceField(label=_("VIP Subnet"),
                                          initial="",
                                          required=False)
    address = forms.IPField(label=_("IP address"),
                            version=forms.IPv4 | forms.IPv6,
                            mask=False,
                            required=False)
    protocol_port = forms.IntegerField(
        label=_("Protocol Port"), min_value=1,
        help_text=_("Enter an integer value "
                    "between 1 and 65535."),
        validators=[validators.validate_port_range])
    protocol = forms.ThemableChoiceField(label=_("Protocol"))
github openstack / freezer-web-ui / disaster_recovery / actions / workflows / action.py View on Github external
help_text=_("Id of nova network for recover"),
        required=False)

    get_object = forms.CharField(
        label=_("Get A Single Object"),
        help_text=_("The Object name you want to download on "
                    "the local file system."),
        required=False)

    dst_file = forms.CharField(
        label=_("Destination File"),
        help_text=_("The file name used to save the object "
                    "on your local disk and upload file in swift."),
        required=False)

    remove_older_than = forms.CharField(
        label=_("Remove Older Than"),
        help_text=_("Checks in the specified container for"
                    " object older than the specified days."
                    "If i.e. 30 is specified, it will remove"
                    " the remote object older than 30 days."
                    " Default False (Disabled) The option "
                    "--remove-older-then is deprecated and "
                    "will be removed soon"),
        required=False)

    remove_from_date = forms.CharField(
        label=_("Remove From Date"),
        help_text=_("Checks the specified container and removes"
                    " objects older than the provided datetime"
                    " in the format YYYY-MM-DDThh:mm:ss "
                    "i.e. 1974-03-25T23:23:23. Make sure the "
github openstack / adjutant-ui / adjutant_ui / content / project_users / forms.py View on Github external
def get_role_choices(request):
    """Get manageable roles for user.

    Returns a list of sorted 2-ary tuples containing the roles the current
    user can manage.
    """
    role_names = adjutant.valid_role_names_get(request)
    role_tuples = [(r, adjutant.get_role_text(r)) for r in role_names]
    role_tuples = sorted(role_tuples, key=lambda role: role[1])
    return role_tuples


class InviteUserForm(forms.SelfHandlingForm):
    username = forms.CharField(max_length=255, label=_("User Name"))
    email = forms.EmailField()
    roles = forms.MultipleChoiceField(label=_("Roles"),
                                      required=True,
                                      widget=forms.CheckboxSelectMultiple(),
                                      help_text=_("Select roles to grant to "
                                                  "the user within the "
                                                  "current project."))

    def __init__(self, *args, **kwargs):
        super(InviteUserForm, self).__init__(*args, **kwargs)
        if (hasattr(settings, 'USERNAME_IS_EMAIL') and
                getattr(settings, 'USERNAME_IS_EMAIL')):
            self.fields.pop('username')
        self.fields['roles'].choices = get_role_choices(self.request)
        self.fields['roles'].initial = ['_member_']
github intel / virtual-storage-manager / source / vsm-dashboard / vsm_dashboard / dashboards / vsm / cephupgrade / form.py View on Github external
import logging


LOG = logging.getLogger(__name__)


class CephUpgrade(forms.SelfHandlingForm):
    package_url = forms.CharField(label=_("Package URL"),
                            max_length=255,
                            min_length=1,
                            initial='http://ceph.com/debian-hammer/',
                            error_messages={
                            'required': _('This field is required.'),},
                            )

    key_url  = forms.CharField(label=_("Key URL"),
                            max_length=255,
                            min_length=1,
                            initial='https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc',
                            error_messages={
                            'required': _('This field is required.'),},
                            )
    proxy  = forms.CharField(label=_("Proxy URL"),
                            max_length=255,
                            min_length=1,
                            required=False,
                            )
    ssh_user  = forms.CharField(label=_("SSH User Name"),
                            max_length=255,
                            min_length=1,
                            required=False,
                            )
github openstack / adjutant-ui / adjutant_ui / content / quota / forms.py View on Github external
from django.core.urlresolvers import reverse  # noqa
from django.utils.translation import ugettext_lazy as _

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

from adjutant_ui.api import adjutant


LOG = logging.getLogger(__name__)


class UpdateQuotaForm(forms.SelfHandlingForm):
    region = forms.CharField(label=_("Region"))
    region.widget.attrs['readonly'] = True
    size = forms.ChoiceField(label=_("Size"))
    size.widget.attrs['onchange'] = 'updateSizeTable()'

    failure_url = 'horizon:management:quota:index'
    submit_url = 'horizon:management:quota:update'
    success_url = "horizon:management:quota:index"

    def __init__(self, *args, **kwargs):
        size_choices = kwargs.pop('size_choices')
        super(UpdateQuotaForm, self).__init__(*args, **kwargs)
        self.fields['size'].choices = size_choices

    def handle(self, request, data):
        try:
            response = adjutant.update_quotas(request, data['size'],
github openstack / horizon / openstack_dashboard / dashboards / project / routers / forms.py View on Github external
message = _('Router %s was successfully created.') % data['name']
            messages.success(request, message)
            return router
        except Exception as exc:
            if exc.status_code == 409:
                msg = _('Quota exceeded for resource router.')
            else:
                msg = _('Failed to create router "%s".') % data['name']
            LOG.info(msg)
            redirect = reverse(self.failure_url)
            exceptions.handle(request, msg, redirect=redirect)
            return False


class UpdateForm(forms.SelfHandlingForm):
    name = forms.CharField(label=_("Name"), required=False)
    admin_state = forms.BooleanField(label=_("Enable Admin State"),
                                     required=False)
    router_id = forms.CharField(label=_("ID"),
                                widget=forms.TextInput(
                                    attrs={'readonly': 'readonly'}))
    mode = forms.ThemableChoiceField(label=_("Router Type"))
    ha = forms.BooleanField(label=_("High Availability Mode"), required=False)

    redirect_url = reverse_lazy('horizon:project:routers:index')

    def __init__(self, request, *args, **kwargs):
        super(UpdateForm, self).__init__(request, *args, **kwargs)
        self.dvr_allowed = api.neutron.get_feature_permission(self.request,
                                                              "dvr", "update")
        if not self.dvr_allowed:
            del self.fields['mode']
github openstack / sahara-dashboard / saharadashboard / nodegroup_templates / workflows / create.py View on Github external
# horizon.api is for backward compatibility with folsom
nova = importutils.import_any('openstack_dashboard.api.nova',
                              'horizon.api.nova')

network = importutils.import_any('openstack_dashboard.api.network',
                                 'horizon.api.network')

LOG = logging.getLogger(__name__)


class GeneralConfigAction(workflows.Action):
    nodegroup_name = forms.CharField(label=_("Template Name"),
                                     required=True)

    description = forms.CharField(label=_("Description"),
                                  required=False,
                                  widget=forms.Textarea)

    flavor = forms.ChoiceField(label=_("OpenStack Flavor"),
                               required=True)

    storage = forms.ChoiceField(
        label=_("Storage location"),
        required=True,
        help_text=_("Storage"),
        choices=[("ephemeral_drive", "Ephemeral Drive"),
                 ("cinder_volume", "Cinder Volume")],
        widget=forms.Select(attrs={"class": "storage_field"}))

    volumes_per_node = forms.IntegerField(
        label=_("Volumes per node"),
github openstack / tacker-horizon / tacker_horizon / openstack_dashboard / dashboards / nfv / vnfmanager / forms.py View on Github external
required=False,
        choices=[('file', _('File')),
                 ('raw', _('Direct Input'))],
        widget=forms.Select(
            attrs={'class': 'switchable', 'data-slug': 'config'}))

    config_file = forms.FileField(
        label=_('Configuration Value File'),
        help_text=_('VNF Configuration file with YAML '
                    'formatted contents to upload.'),
        widget=forms.FileInput(
            attrs={'class': 'switched', 'data-switch-on': 'config',
                   'data-config-file': _('Configuration Value File')}),
        required=False)

    config_input = forms.CharField(
        label=_('Configuration Value YAML'),
        help_text=_('YAML formatted VNF configuration text.'),
        widget=forms.widgets.Textarea(
            attrs={'class': 'switched', 'data-switch-on': 'config',
                   'data-config-raw': _('Configuration Values')}),
        required=False)

    def __init__(self, request, *args, **kwargs):
        super(DeployVNF, self).__init__(request, *args, **kwargs)

        try:
            vnfd_list = api.tacker.vnfd_list(request,
                                             template_source='onboarded')
            available_choices_vnfd = [(vnf['id'], vnf['name']) for vnf in
                                      vnfd_list]
        except Exception as e:
github openstack / tacker-horizon / tacker_horizon / openstack_dashboard / dashboards / nfv / vnfmanager / forms.py View on Github external
from django.forms import ValidationError
from django.utils.translation import ugettext_lazy as _

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

from tacker_horizon.openstack_dashboard import api

LOG = logging.getLogger(__name__)


class DeployVNF(forms.SelfHandlingForm):
    vnf_name = forms.CharField(max_length=255, label=_("VNF Name"))
    description = forms.CharField(widget=forms.widgets.Textarea(
                                  attrs={'rows': 4}),
                                  label=_("Description"),
                                  required=False)
    vnfd_id = forms.ChoiceField(label=_("VNF Catalog Name"),
                                required=False)
    template_source = forms.ChoiceField(
        label=_('VNFD template Source'),
        required=False,
        choices=[('file', _('File')),
                 ('raw', _('Direct Input'))],
        widget=forms.Select(
            attrs={'class': 'switchable', 'data-slug': 'template'}))
    template_file = forms.FileField(
        label=_('VNFD template File'),
        help_text=_('VNFD template to create VNF'),
        widget=forms.FileInput(
github openstack / horizon / openstack_dashboard / dashboards / project / networks / ports / workflows.py View on Github external
'The "default" security group is associated '
                  'by default and you can remove "default" '
                  'security group from the port.')
    depends_on = ("target_tenant_id",)


class CreatePortInfoAction(workflows.Action):
    name = forms.CharField(max_length=255,
                           label=_("Name"),
                           required=False)
    admin_state = forms.BooleanField(
        label=_("Enable Admin State"),
        initial=True,
        required=False,
        help_text=_("If checked, the port will be enabled."))
    device_id = forms.CharField(max_length=100, label=_("Device ID"),
                                help_text=_("Device ID attached to the port"),
                                required=False)
    device_owner = forms.CharField(
        max_length=100, label=_("Device Owner"),
        help_text=_("Owner of the device attached to the port"),
        required=False)
    specify_ip = forms.ThemableChoiceField(
        label=_("Specify IP address or subnet"),
        help_text=_("To specify a subnet or a fixed IP, select any options."),
        required=False,
        choices=[('', _("Unspecified")),
                 ('subnet_id', _("Subnet")),
                 ('fixed_ip', _("Fixed IP Address"))],
        widget=forms.ThemableSelectWidget(attrs={
            'class': 'switchable',
            'data-slug': 'specify_ip',