示例#1
0
    def modify(self):
        self._object = user = usergroup.User(env.request.parameters.get("name", env.request.user.name))

        if not env.request.parameters["language"] in localization.getLanguagesIdentifiers():
            raise error.PrewikkaUserError(N_("Invalid Language"), N_("Specified language does not exist"), log_priority=log.WARNING)

        list(hookmanager.trigger("HOOK_USERMANAGEMENT_USER_MODIFY", user))
        if not env.request.parameters["timezone"] in localization.get_timezones():
            raise error.PrewikkaUserError(N_("Invalid Timezone"), N_("Specified timezone does not exist"), log_priority=log.WARNING)

        need_reload = False
        user.begin_properties_change()

        for param, reload in (("fullname", False), ("email", False), ("theme", True), ("language", True), ("timezone", False)):
            if user == env.request.user and reload and env.request.parameters.get(param) != user.get_property(param):
                need_reload = True

            user.set_property(param, env.request.parameters.get(param))

        if user == env.request.user:
            user.set_locale()

        user.commit_properties_change()

        # Make sure nothing is returned (reset the default dataset)
        env.request.dataset = None

        if need_reload:
            return response.PrewikkaDirectResponse({"type": "reload"})

        return response.PrewikkaRedirectResponse(url_for(".display"), 303)
示例#2
0
    def _redirect_default(self, request):
        if env.menumanager.default_endpoint:
            url = url_for(env.menumanager.default_endpoint)
        else:
            # The configured view does not exist. Fall back to "settings/my_account"
            # which does not require any specific permission.
            url = request.get_baseurl() + "settings/my_account"

        return response.PrewikkaRedirectResponse(url)
示例#3
0
    def logout(self):
        try:
            env.session.logout(env.request.web)
        except:
            # logout always generate an exception to render the logout template
            pass

        return response.PrewikkaRedirectResponse(
            env.request.parameters.get("redirect",
                                       env.request.web.get_baseurl()))
示例#4
0
    def delete(self):
        c = Criterion()

        for analyzerid in env.request.parameters.getlist("id[]"):
            for i in env.request.parameters.getlist("types[]"):
                if i in ("alert", "heartbeat"):
                    c |= Criterion("%s.analyzer.analyzerid" % i, "=",
                                   analyzerid)

        env.dataprovider.delete(c)
        return response.PrewikkaRedirectResponse(url_for(".agents"))
示例#5
0
    def help(self, path=None):
        server = string.Template(self._get_server())

        lang = None
        if env.request.user:
            userl = env.request.user.get_property("language")
            if userl:
                lang = self._get_help_language(userl)

        if not lang:
            lang = self._get_help_language(env.config.general.default_locale,
                                           "en")

        return response.PrewikkaRedirectResponse(
            server.safe_substitute(lang=lang, path=path))
示例#6
0
 def respond(self):
     return response.PrewikkaRedirectResponse(self.location, code=self.code)
 def save(self):
     self._db.add_host(env.request.parameters["hostname"],
                       env.request.parameters.get("address"),
                       env.request.parameters.get("os"))
     return response.PrewikkaRedirectResponse(url_for("Inventory.hosts"))