How to use the horizon.forms.ModalFormView 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 / cloudkitty-dashboard / cloudkittydashboard / dashboards / admin / hashmap / views.py View on Github external
def get_context_data(self, **kwargs):
        context = super(FieldCreateView, self).get_context_data(**kwargs)
        context["service_id"] = self.kwargs['service_id']
        args = (self.kwargs['service_id'],)
        context['submit_url'] = reverse_lazy(self.submit_url, args=args)
        return context

    def get_initial(self):
        return {"service_id": self.kwargs["service_id"]}

    def get_success_url(self, **kwargs):
        args = (self.kwargs['service_id'],)
        return reverse_lazy(self.success_url, args=args)


class ServiceMappingCreateView(forms.ModalFormView):
    form_class = hashmap_forms.CreateServiceMappingForm
    form_id = "create_mapping"
    modal_header = _("Create Mapping")
    page_title = _("Create Mapping")
    template_name = 'admin/hashmap/mapping_create.html'
    success_url = 'horizon:admin:hashmap:service'
    submit_url = 'horizon:admin:hashmap:service_mapping_create'

    def get_object_id(self, obj):
        return obj.mapping_id

    def get_context_data(self, **kwargs):
        context = super(ServiceMappingCreateView,
                        self).get_context_data(**kwargs)
        context["service_id"] = self.kwargs.get('service_id')
        context['submit_url'] = reverse_lazy(self.submit_url,
github openstack / senlin-dashboard / senlin_dashboard / cluster / receivers / views.py View on Github external
try:
            receivers, self._more, self._prev = senlin.receiver_list(
                self.request,
                marker=marker,
                paginate=True,
                reversed_order=reversed_order,
                filters=filters)
        except Exception as e:
            self._prev = self._more = False
            receivers = []
            msg = _('Unable to retrieve receivers: %s') % e
            exceptions.handle(self.request, msg)
        return receivers


class CreateView(forms.ModalFormView):
    template_name = 'cluster/receivers/create.html'
    form_class = receivers_forms.CreateReceiverForm
    submit_url = reverse_lazy("horizon:cluster:receivers:create")
    success_url = reverse_lazy("horizon:cluster:receivers:index")

    text = _("Create Receiver")
    modal_header = text
    submit_label = text
    page_title = text


class DetailView(tabs.TabView):
    tab_group_class = receivers_tabs.ReceiverDetailTabs
    template_name = 'horizon/common/_detail.html'
    page_title = "{{ receiver.name }}"
    cluster_url = 'horizon:cluster:clusters:detail'
github openstack / mistral-dashboard / mistraldashboard / actions / views.py View on Github external
from django.urls import reverse
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.views import generic

from horizon import exceptions
from horizon import forms
from horizon import tables

from mistraldashboard.actions import forms as mistral_forms
from mistraldashboard.actions import tables as mistral_tables
from mistraldashboard import api
from mistraldashboard.default import utils


class CreateView(forms.ModalFormView):
    template_name = 'mistral/actions/create.html'
    modal_header = _("Create Action")
    form_id = "create_action"
    form_class = mistral_forms.CreateForm
    submit_label = _("Create")
    submit_url = reverse_lazy("horizon:mistral:actions:create")
    success_url = reverse_lazy('horizon:mistral:actions:index')
    page_title = _("Create Action")


class UpdateView(forms.ModalFormView):
    template_name = 'mistral/actions/update.html'
    modal_header = _("Update Action")
    form_id = "update_action"
    form_class = mistral_forms.UpdateForm
    submit_label = _("Update")
github openstack / horizon / openstack_dashboard / dashboards / identity / mappings / views.py View on Github external
if policy.check((("identity", "identity:list_mappings"),),
                        self.request):
            try:
                mappings = api.keystone.mapping_list(self.request)
            except Exception:
                exceptions.handle(
                    self.request,
                    _('Unable to retrieve mapping list.'))
        else:
            msg = _("Insufficient privilege level to view mapping "
                    "information.")
            messages.info(self.request, msg)
        return mappings


class UpdateView(forms.ModalFormView):
    template_name = 'identity/mappings/update.html'
    form_id = "update_mapping_form"
    form_class = mapping_forms.UpdateMappingForm
    submit_label = _("Update Mapping")
    submit_url = "horizon:identity:mappings:update"
    success_url = reverse_lazy('horizon:identity:mappings:index')
    page_title = _("Update Mapping")

    @memoized.memoized_method
    def get_object(self):
        try:
            return api.keystone.mapping_get(
                self.request,
                self.kwargs['mapping_id'])
        except Exception:
            redirect = reverse("horizon:identity:mappings:index")
github openstack / horizon / openstack_dashboard / dashboards / router / nexus1000v / views.py View on Github external
tabs = (NetworkProfileIndexView, PolicyProfileIndexView,)


class IndexView(tables.MultiTableView):
    table_classes = (profiletables.NetworkProfile,
                     profiletables.PolicyProfile,)
    template_name = 'router/nexus1000v/index.html'

    def get_network_profile_data(self):
        return _get_profiles(self.request, 'network')

    def get_policy_profile_data(self):
        return _get_profiles(self.request, 'policy')


class CreateNetworkProfileView(forms.ModalFormView):
    form_class = profileforms.CreateNetworkProfile
    template_name = 'router/nexus1000v/create_network_profile.html'
    success_url = urlresolvers.reverse_lazy('horizon:router:nexus1000v:index')


class UpdateNetworkProfileView(forms.ModalFormView):
    form_class = profileforms.UpdateNetworkProfile
    template_name = 'router/nexus1000v/update_network_profile.html'
    context_object_name = 'network_profile'
    success_url = urlresolvers.reverse_lazy('horizon:router:nexus1000v:index')

    def get_context_data(self, **kwargs):
        context = super(UpdateNetworkProfileView,
                        self).get_context_data(**kwargs)
        context["profile_id"] = self.kwargs['profile_id']
        return context
github intel / virtual-storage-manager / source / vsm-dashboard / vsm_dashboard / dashboards / vsm / usermgmt / views.py View on Github external
except:
        resp = dict(message="Create User failed", status="Bad", data="")
        resp = json.dumps(resp)
        return HttpResponse(resp)


def update_pwd(request):
    data = json.loads(request.body)

    api.keystone.user_update_password(request, data["id"], data["pwd"])
    resp = dict(message="Update User", status="OK", data="")
    resp = json.dumps(resp)
    return HttpResponse(resp)


class UserSettingsView(forms.ModalFormView):
    form_class = UserSettingsForm
    template_name = 'vsm/usermgmt/settings.html'
    success_url = reverse_lazy("horizon:vsm:usermgmt:index")

    def get_initial(self):
        return {
            'pagesize': utils.get_page_size(self.request)
        }

    def form_valid(self, form):
        return form.handle(self.request, form.cleaned_data)

def _one_year():
    now = datetime.utcnow()
    return datetime(now.year + 1, now.month, now.day, now.hour,
                    now.minute, now.second, now.microsecond, now.tzinfo)
github openstack / horizon / openstack_dashboard / dashboards / admin / volume_types / extras / views.py View on Github external
template_name = 'admin/volume_types/extras/index.html'

    def get_data(self):
        try:
            type_id = self.kwargs['type_id']
            extras_list = api.cinder.volume_type_extra_get(self.request,
                                                           type_id)
            extras_list.sort(key=lambda es: (es.key,))
        except Exception:
            extras_list = []
            exceptions.handle(self.request,
                              _('Unable to retrieve extra spec list.'))
        return extras_list


class CreateView(ExtraSpecMixin, forms.ModalFormView):
    form_class = project_forms.CreateExtraSpec
    form_id = "extra_spec_create_form"
    page_title = _("Create Volume Type Extra Spec")
    modal_id = "extra_spec_create_modal"
    submit_label = _("Create")
    submit_url = "horizon:admin:volume_types:extras:create"
    template_name = 'admin/volume_types/extras/create.html'
    success_url = 'horizon:admin:volume_types:extras:index'
    cancel_url = reverse_lazy('horizon:admin:volume_types:index')

    def get_initial(self):
        return {'type_id': self.kwargs['type_id']}

    def get_success_url(self):
        return reverse(self.success_url,
                       args=(self.kwargs['type_id'],))
github openstack / horizon / openstack_dashboard / dashboards / project / volume_groups / views.py View on Github external
args = (self.kwargs['group_id'],)
        context['submit_url'] = reverse(self.submit_url, args=args)
        return context

    def get_object(self):
        group_id = self.kwargs['group_id']
        try:
            self._object = cinder.group_get(self.request, group_id)
        except Exception:
            exceptions.handle(self.request,
                              _('Unable to retrieve group details.'),
                              redirect=reverse(INDEX_URL))
        return self._object


class RemoveVolumesView(forms.ModalFormView):
    template_name = 'project/volume_groups/remove_vols.html'
    page_title = _("Remove Volumes from Group")
    form_class = vol_group_forms.RemoveVolsForm
    success_url = reverse_lazy('horizon:project:volume_groups:index')
    submit_url = "horizon:project:volume_groups:remove_volumes"

    def get_initial(self):
        group = self.get_object()
        return {'group_id': self.kwargs["group_id"],
                'name': group.name}

    def get_context_data(self, **kwargs):
        context = super(RemoveVolumesView, self).get_context_data(**kwargs)
        context['group_id'] = self.kwargs['group_id']
        args = (self.kwargs['group_id'],)
        context['submit_url'] = reverse(self.submit_url, args=args)
github openstack / sahara-dashboard / saharadashboard / cluster_templates / views.py View on Github external
class ClusterTemplateDetailsView(tabs.TabView):
    tab_group_class = _tabs.ClusterTemplateDetailsTabs
    template_name = 'cluster_templates/details.html'

    def get_context_data(self, **kwargs):
        context = super(ClusterTemplateDetailsView, self)\
            .get_context_data(**kwargs)
        return context

    def get_data(self):
        pass


class UploadFileView(forms.ModalFormView):
    form_class = cluster_forms.UploadFileForm
    template_name = 'cluster_templates/upload_file.html'
    success_url = reverse_lazy('horizon:sahara:cluster_templates:index')


class CreateClusterTemplateView(workflows.WorkflowView):
    workflow_class = create_flow.CreateClusterTemplate
    success_url = \
        "horizon:sahara:cluster_templates:create-cluster-template"
    classes = ("ajax-modal")
    template_name = "cluster_templates/create.html"


class ConfigureClusterTemplateView(workflows.WorkflowView):
    workflow_class = create_flow.ConfigureClusterTemplate
    success_url = "horizon:sahara:cluster_templates"
github openstack / cloudkitty-dashboard / cloudkittydashboard / dashboards / admin / hashmap / views.py View on Github external
return obj.service_id


class FieldView(tabs.TabbedTableView):
    tab_group_class = hashmap_tables.FieldTabs
    template_name = 'admin/hashmap/field_details.html'

    def get(self, *args, **kwargs):
        field = api.cloudkittyclient(self.request).rating.hashmap.get_field(
            field_id=kwargs['field_id'])
        self.request.field_id = field['field_id']
        self.page_title = "Hashmap Field : %s" % field['name']
        return super(FieldView, self).get(*args, **kwargs)


class FieldCreateView(forms.ModalFormView):
    form_class = hashmap_forms.CreateFieldForm
    form_id = "create_field"
    modal_header = _("Create Field")
    page_title = _("Create Field")
    template_name = 'admin/hashmap/field_create.html'
    success_url = 'horizon:admin:hashmap:service'
    submit_url = 'horizon:admin:hashmap:field_create'

    def get_object_id(self, obj):
        return obj.field_id

    def get_context_data(self, **kwargs):
        context = super(FieldCreateView, self).get_context_data(**kwargs)
        context["service_id"] = self.kwargs['service_id']
        args = (self.kwargs['service_id'],)
        context['submit_url'] = reverse_lazy(self.submit_url, args=args)