How to use the horizon.messages.error 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 stackforge-attic / tuskar-ui-extras / tuskar_sat_ui / nodes / tabs.py View on Github external
def get_context_data(self, request, **kwargs):
        context = super(DetailOverviewTab,
                        self).get_context_data(request, **kwargs)
        if context['node'].uuid is None:
            return context

        # TODO(rdopiera) We can probably get the stack from the context.
        stack = _get_stack(request)
        if stack is None:
            return context

        try:
            host, auth, organization = _get_satellite_config(stack.parameters)
        except NoConfigError as e:
            horizon.messages.error(request, _(
                "No Satellite configuration found. "
                "Missing parameter %r."
            ) % e.param)
            return context
        except BadAuthError as e:
            horizon.messages.error(request, _(
                "Satellite configuration error, "
                "unknown authentication method %r."
            ) % e.auth)
            return context

        addresses = context['node'].addresses
        try:
            uuid = _find_uuid_by_mac(host, auth, organization, addresses)
        except NodeNotFound:
            return context
github openstack / heat-dashboard / heat_dashboard / content / stacks / tabs.py View on Github external
stack_identifier,
                marker=marker,
                paginate=True,
                sort_dir=sort_dir)
            if prev_marker is not None:
                events = sorted(events, key=attrgetter('event_time'),
                                reverse=True)
            LOG.debug('got events %s', events)
            # The stack id is needed to generate the resource URL.
            for event in events:
                event.stack_id = stack.id
        except Exception:
            events = []
            self._prev = False
            self._more = False
            messages.error(self.request, _(
                'Unable to get events for stack "%s".') % stack.stack_name)
        return events
github openstack / python-muranoclient / dashboard / windc / tables.py View on Github external
def action(self, request, service_id):
        link = request.__dict__['META']['HTTP_REFERER']
        datacenter_id = re.search('windc/(\S+)', link).group(0)[6:-1]

        try:
            api.windc.services_delete(request, datacenter_id, service_id)
        except:
            messages.error(request,
                  _('Sorry, you can not delete this service right now.'))
github openstack / manila-ui / manila_ui / dashboards / project / shares / tables.py View on Github external
def delete(self, request, obj_id):
        share = manila.share_get(request, obj_id)
        try:
            manila.share_delete(
                request, share.id, share_group_id=share.share_group_id)
        except Exception:
            msg = _('Unable to delete share "%s". ') % obj_id
            messages.error(request, msg)
github openstack / horizon / horizon / dashboards / settings / project / forms.py View on Github external
context = {'user': request.user,
                       'auth_url': keystone_url,
                       'tenant_id': tenant_id,
                       'tenant_name': tenant_name}

            response = shortcuts.render(request,
                                        'settings/project/openrc.sh.template',
                                        context,
                                        content_type="text/plain")
            response['Content-Disposition'] = 'attachment; filename=openrc.sh'
            response['Content-Length'] = str(len(response.content))
            return response

        except Exception, e:
            LOG.exception("Exception in DownloadOpenRCForm.")
            messages.error(request, _('Error Downloading RC File: %s') % e)
            return shortcuts.redirect(request.build_absolute_uri())
github openstack / sahara-dashboard / saharadashboard / job_binaries / forms.py View on Github external
bin_url = "%s://%s" % (context["job_binary_type"],
                                   context["job_binary_url"])
            if(context["job_binary_type"] == "internal-db"):
                bin_url = self.handle_internal(request, context)
            elif(context["job_binary_type"] == "swift"):
                extra = self.handle_swift(request, context)

            sahara.job_binaries.create(
                context["job_binary_name"],
                bin_url,
                context["job_binary_description"],
                extra)
            messages.success(request, "Successfully created job binary")
            return True
        except api_base.APIException as e:
            messages.error(request, str(e))
            return False
        except Exception as e:
            messages.error(request, str(e))
            return False
github open-power-ref-design-toolkit / opsmgr / horizon / operational_mgmt / inventory / views.py View on Github external
logging.error("%s: Exception received trying to retrieve"
                              " rack information.  Exception is: %s",
                              __method__, e)
                exceptions.handle(self.request, failure_message)
                return
        else:
            # This is unexpected.  RemoveRackView called with no context
            # of what to edit.  Need to display an error message because
            # the dialog will not be primed with required data
            logging.error("%s: RemoveRackView called with no context.",
                          __method__)
            messages.error(self.request, failure_message)
            return

        if rc != 0:
            messages.error(self.request, failure_message)
            return
        else:
            # We should have at least one resource in the results...just
            # return the first value
            if len(result_dict['racks']) > 0:
                return result_dict['racks'][0]
            else:
                logging.error("%s: list_racks returned no information for"
                              " rack with rack id %s",
                              __method__, self.kwargs["rack_id"])
                messages.error(self.request, failure_message)
                return
github openstack / designate-dashboard / designatedashboard / dashboards / project / dns_domains / forms.py View on Github external
if six.text_type(ex) is not None:
                data['message'] = six.text_type(ex)
                msg += "Error: %(message)s"
            else:
                data["type"] = ex.type
                msg += "Error Type: %(type)s"

            if ex.code >= 500:
                msg += " (Request ID: %(request_id)s"
                data["request_id"] = ex.request_id

            form.api_error(_(msg) % data)  # noqa

            return False
        except Exception:
            messages.error(request, form.exc_message)
            return True
github django-leonardo / django-leonardo / leonardo / module / leonardo_auth / forms.py View on Github external
def handle(self, request, data):

        try:
            user = User.objects.create_user(**data)
            messages.success(
                request,
                _("User account {} was successfuly created.".format(user)))

        except Exception as e:
            raise e
        else:
            data.pop('email')
            return LoginForm().handle(request, data)

        messages.error(request, _("Create Account failed."))
        return False
github openstack / tacker-horizon / tacker_horizon / openstack_dashboard / dashboards / nfv / vnffgmanager / tables.py View on Github external
vnffg_desc_str = vnffg['description']
            except KeyError:
                vnffg_desc_str = ""

            if not item:
                # Add an item entry
                item = VNFFGManagerItem(vnffg['name'], vnffg_desc_str,
                                        vnffg['status'], vnffg['id'])
            else:
                item.description = vnffg_desc_str
                item.status = vnffg['status']
            return item
        except (Http404, NotFound):
            raise Http404
        except Exception as e:
            messages.error(request, e)
            raise