예제 #1
0
class BuilderSystemMetrics(View, Controller):
    """Add and Remove Builder System Metrics Private Endpoint Controller"""
    def __init__(self):
        self.__settings = Settings()
        self.__metric = MetricModule()

    @allow_if_authenticated_and_has_permission("manage_settings")
    def post(self, request):

        request_data = self.get_request_data(request, "post",
                                             {"metric_id": ""})

        if request_data["metric_id"] == "" or not self.__metric.get_one_by_id(
                request_data["metric_id"].replace("m-", "")):
            return self.json([{
                "type": "error",
                "message": _("Error! Metric is required.")
            }])

        metrics = self.__settings.get_value_by_key("builder_metrics",
                                                   json.dumps([]))

        metrics = json.loads(metrics)

        if request_data["metric_id"] in metrics:
            return self.json([{
                "type": "success",
                "message": _("Metric added successfully.")
            }])

        metrics.append(request_data["metric_id"])

        result = self.__settings.update_options(
            {"builder_metrics": json.dumps(metrics)})

        if result:
            return self.json([{
                "type": "success",
                "message": _("Metric added successfully.")
            }])

        else:
            return self.json([{
                "type":
                "error",
                "message":
                _("Error! Something goes wrong while adding metric.")
            }])

    @allow_if_authenticated_and_has_permission("manage_settings")
    def delete(self, request, metric_id):

        metrics = self.__settings.get_value_by_key("builder_metrics",
                                                   json.dumps([]))

        metrics = json.loads(metrics)

        if metric_id not in metrics:
            return self.json([{
                "type": "success",
                "message": _("Metric deleted successfully.")
            }])

        metrics.remove(metric_id)

        result = self.__settings.update_options(
            {"builder_metrics": json.dumps(metrics)})

        if result:
            return self.json([{
                "type": "success",
                "message": _("Metric deleted successfully.")
            }])

        else:
            return self.json([{
                "type":
                "error",
                "message":
                _("Error! Something goes wrong while deleting metric.")
            }])
예제 #2
0
class BuilderComponents(View, Controller):
    """Add and Remove Builder Components Private Endpoint Controller"""
    def __init__(self):
        self.__settings = Settings()
        self.__component = ComponentModule()
        self.__component_group = ComponentGroupModule()

    @allow_if_authenticated_and_has_permission("manage_settings")
    def post(self, request):

        request_data = self.get_request_data(request, "post",
                                             {"component_id": ""})

        if request_data["component_id"] == "" or (
                "c-" not in request_data["component_id"]
                and "g-" not in request_data["component_id"]):
            return self.json([{
                "type":
                "error",
                "message":
                _("Error! Compnent or compnent group is required.")
            }])

        if "c-" in request_data[
                "component_id"] and not self.__component.get_one_by_id(
                    request_data["component_id"].replace("c-", "")):
            return self.json([{
                "type":
                "error",
                "message":
                _("Error! Compnent or compnent group is required.")
            }])

        if "g-" in request_data[
                "component_id"] and not self.__component_group.get_one_by_id(
                    request_data["component_id"].replace("g-", "")):
            return self.json([{
                "type":
                "error",
                "message":
                _("Error! Compnent or compnent group is required.")
            }])

        components = self.__settings.get_value_by_key("builder_components",
                                                      json.dumps([]))

        components = json.loads(components)

        if request_data["component_id"] in components:
            return self.json([{
                "type": "success",
                "message": _("Component added successfully.")
            }])

        components.append(request_data["component_id"])

        result = self.__settings.update_options(
            {"builder_components": json.dumps(components)})

        if result:
            return self.json([{
                "type": "success",
                "message": _("Component added successfully.")
            }])

        else:
            return self.json([{
                "type":
                "error",
                "message":
                _("Error! Something goes wrong while adding component.")
            }])

    @allow_if_authenticated_and_has_permission("manage_settings")
    def delete(self, request, component_id):

        components = self.__settings.get_value_by_key("builder_components",
                                                      json.dumps([]))

        components = json.loads(components)

        if component_id not in components:
            return self.json([{
                "type": "success",
                "message": _("Component deleted successfully.")
            }])

        components.remove(component_id)

        result = self.__settings.update_options(
            {"builder_components": json.dumps(components)})

        if result:
            return self.json([{
                "type": "success",
                "message": _("Component deleted successfully.")
            }])

        else:
            return self.json([{
                "type":
                "error",
                "message":
                _("Error! Something goes wrong while deleting component.")
            }])
예제 #3
0
class BuilderSettings(View, Controller):
    """Update Builder Settings Private Endpoint Controller"""
    def __init__(self):
        self.__settings = Settings()

    @allow_if_authenticated_and_has_permission("manage_settings")
    def post(self, request):

        request_data = self.get_request_data(
            request, "post", {
                "builder_headline": "",
                "builder_favicon_url": "",
                "builder_logo_url": "",
                "builder_about": ""
            })

        self.form().add_inputs({
            'builder_headline': {
                'value': request_data["builder_headline"],
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'length_between': {
                        'param': [0, 100],
                        'error': _('Error! Headline is very long.')
                    },
                    'optional': {}
                }
            },
            'builder_favicon_url': {
                'value': request_data["builder_favicon_url"],
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'sv_url': {
                        'error': _('Error! Favicon URL is invalid.')
                    }
                }
            },
            'builder_logo_url': {
                'value': request_data["builder_logo_url"],
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'sv_url': {
                        'error': _('Error! Logo URL is invalid.')
                    }
                }
            },
            'builder_about': {
                'value': request_data["builder_about"],
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'length_between': {
                        'param': [0, 20000],
                        'error': _('Error! About is very long.')
                    },
                    'optional': {}
                }
            },
        })

        self.form().process()

        if not self.form().is_passed():
            return self.json(self.form().get_errors())

        result = self.__settings.update_options({
            "builder_headline":
            self.form().get_sinput("builder_headline"),
            "builder_favicon_url":
            self.form().get_sinput("builder_favicon_url"),
            "builder_logo_url":
            self.form().get_sinput("builder_logo_url"),
            "builder_about":
            self.form().get_sinput("builder_about")
        })

        if result:
            return self.json([{
                "type": "success",
                "message": _("Settings updated successfully.")
            }])

        else:
            return self.json([{
                "type":
                "error",
                "message":
                _("Error! Something goes wrong while updating settings.")
            }])
예제 #4
0
class Settings(View):
    """Update Settings Private Endpoint Controller"""
    def __init__(self):
        self.__request = Request()
        self.__response = Response()
        self.__helpers = Helpers()
        self.__form = Form()
        self.__settings_module = SettingsModule()
        self.__acl = ACL()
        self.__activity_module = ActivityModule()
        self.__logger = self.__helpers.get_logger(__name__)
        self.__correlation_id = ""
        self.__form.add_validator(ExtraRules())

    @allow_if_authenticated_and_has_permission("manage_settings")
    def post(self, request):

        self.__correlation_id = request.META[
            "X-Correlation-ID"] if "X-Correlation-ID" in request.META else ""
        self.__request.set_request(request)
        request_data = self.__request.get_request_data(
            "post", {
                "app_name": "",
                "app_email": "",
                "app_url": "",
                "app_description": "",
                "google_analytics_account": "",
                "reset_mails_messages_count": "",
                "reset_mails_expire_after": "",
                "access_tokens_expire_after": "",
                "prometheus_token": "",
                "newrelic_api_key": ""
            })

        self.__form.add_inputs({
            'app_name': {
                'value': request_data["app_name"],
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'alpha_numeric': {
                        'error':
                        _('Error! Application name must be alpha numeric.')
                    },
                    'length_between': {
                        'param': [2, 30],
                        'error':
                        _('Error! Application name must be 2 to 30 characters long.'
                          )
                    }
                }
            },
            'app_email': {
                'value': request_data["app_email"],
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'sv_email': {
                        'error': _('Error! Application email is invalid.')
                    }
                }
            },
            'app_url': {
                'value': request_data["app_url"],
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'sv_url': {
                        'error': _('Error! Application url is invalid.')
                    }
                }
            },
            'app_description': {
                'value': request_data["app_description"],
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'length_between': {
                        'param': [0, 300],
                        'error': _('Error! App description is very long.')
                    },
                    'optional': {}
                }
            },
            "prometheus_token": {
                'value': request_data["prometheus_token"],
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'length_between': {
                        'param': [0, 100],
                        'error': _('Error! Prometheus token is invalid.')
                    },
                    'optional': {}
                }
            },
            "newrelic_api_key": {
                'value': request_data["newrelic_api_key"],
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'length_between': {
                        'param': [0, 100],
                        'error': _('Error! Prometheus token is invalid.')
                    },
                    'optional': {}
                }
            },
            'google_analytics_account': {
                'value': request_data["google_analytics_account"],
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'length_between': {
                        'param': [0, 30],
                        'error':
                        _('Error! Google analytics account is invalid.')
                    },
                    'optional': {}
                }
            },
            'reset_mails_messages_count': {
                'value': int(request_data["reset_mails_messages_count"]),
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'greater_than': {
                        'error': _('Error! Reset mails count is invalid.'),
                        'param': [0]
                    }
                }
            },
            'reset_mails_expire_after': {
                'value': int(request_data["reset_mails_expire_after"]),
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'greater_than': {
                        'error': _('Error! Reset mails count is invalid.'),
                        'param': [0]
                    }
                }
            },
            'access_tokens_expire_after': {
                'value': int(request_data["access_tokens_expire_after"]),
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'greater_than': {
                        'error':
                        _('Error! Access token expiry interval is invalid.'),
                        'param': [0]
                    }
                }
            },
        })

        self.__form.process()

        if not self.__form.is_passed():
            return JsonResponse(
                self.__response.send_errors_failure(self.__form.get_errors(),
                                                    {}, self.__correlation_id))

        result = self.__settings_module.update_options({
            "app_name":
            self.__form.get_sinput("app_name"),
            "app_email":
            self.__form.get_sinput("app_email"),
            "app_url":
            self.__form.get_sinput("app_url"),
            "app_description":
            self.__form.get_sinput("app_description"),
            "google_analytics_account":
            self.__form.get_sinput("google_analytics_account"),
            "reset_mails_messages_count":
            self.__form.get_sinput("reset_mails_messages_count"),
            "reset_mails_expire_after":
            self.__form.get_sinput("reset_mails_expire_after"),
            "access_tokens_expire_after":
            self.__form.get_sinput("access_tokens_expire_after"),
            "prometheus_token":
            self.__form.get_sinput("prometheus_token"),
            "newrelic_api_key":
            self.__form.get_sinput("newrelic_api_key")
        })

        if result:

            self.__activity_module.track(
                request.user.id, _('You updated application settings.'))

            return JsonResponse(
                self.__response.send_private_success(
                    [{
                        "type": "success",
                        "message": _("Settings updated successfully.")
                    }], {}, self.__correlation_id))

        else:
            return JsonResponse(
                self.__response.send_private_failure([{
                    "type":
                    "error",
                    "message":
                    _("Error! Something goes wrong while updating settings.")
                }], {}, self.__correlation_id))
예제 #5
0
class BuilderSettings(View):

    __request = None
    __response = None
    __helpers = None
    __form = None
    __logger = None
    __user_id = None
    __settings = None
    __correlation_id = None

    def __init__(self):
        self.__request = Request()
        self.__response = Response()
        self.__helpers = Helpers()
        self.__settings = Settings()
        self.__form = Form()
        self.__logger = self.__helpers.get_logger(__name__)
        self.__form.add_validator(ExtraRules())

    @allow_if_authenticated_and_has_permission("manage_settings")
    def post(self, request):

        self.__correlation_id = request.META[
            "X-Correlation-ID"] if "X-Correlation-ID" in request.META else ""
        self.__request.set_request(request)
        request_data = self.__request.get_request_data(
            "post", {
                "builder_headline": "",
                "builder_favicon_url": "",
                "builder_logo_url": "",
                "builder_about": ""
            })

        self.__form.add_inputs({
            'builder_headline': {
                'value': request_data["builder_headline"],
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'length_between': {
                        'param': [0, 100],
                        'error': _('Error! Headline is very long.')
                    },
                    'optional': {}
                }
            },
            'builder_favicon_url': {
                'value': request_data["builder_favicon_url"],
                'sanitize': {
                    'escape': {},
                    'strip': {}
                },
                'validate': {
                    'sv_url': {
                        'error': _('Error! Favicon URL is invalid.')
                    }
                }
            },
            'builder_logo_url': {
                'value': request_data["builder_logo_url"],
                'sanitize': {
                    'escape': {},
                    'strip': {}
                },
                'validate': {
                    'sv_url': {
                        'error': _('Error! Logo URL is invalid.')
                    }
                }
            },
            'builder_about': {
                'value': request_data["builder_about"],
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'length_between': {
                        'param': [0, 20000],
                        'error': _('Error! About is very long.')
                    },
                    'optional': {}
                }
            },
        })

        self.__form.process()

        if not self.__form.is_passed():
            return JsonResponse(
                self.__response.send_errors_failure(self.__form.get_errors(),
                                                    {}, self.__correlation_id))

        result = self.__settings.update_options({
            "builder_headline":
            self.__form.get_sinput("builder_headline"),
            "builder_favicon_url":
            self.__form.get_sinput("builder_favicon_url"),
            "builder_logo_url":
            self.__form.get_sinput("builder_logo_url"),
            "builder_about":
            self.__form.get_sinput("builder_about")
        })

        if result:
            return JsonResponse(
                self.__response.send_private_success(
                    [{
                        "type": "success",
                        "message": _("Settings updated successfully.")
                    }], {}, self.__correlation_id))

        else:
            return JsonResponse(
                self.__response.send_private_failure([{
                    "type":
                    "error",
                    "message":
                    _("Error! Something goes wrong while updating settings.")
                }], {}, self.__correlation_id))
예제 #6
0
class BuilderSystemMetrics(View):

    __request = None
    __response = None
    __helpers = None
    __form = None
    __logger = None
    __user_id = None
    __settings = None
    __metric = None
    __correlation_id = None

    def __init__(self):
        self.__request = Request()
        self.__response = Response()
        self.__helpers = Helpers()
        self.__settings = Settings()
        self.__metric = MetricModule()
        self.__form = Form()
        self.__logger = self.__helpers.get_logger(__name__)
        self.__form.add_validator(ExtraRules())

    @allow_if_authenticated_and_has_permission("manage_settings")
    def post(self, request):

        self.__correlation_id = request.META[
            "X-Correlation-ID"] if "X-Correlation-ID" in request.META else ""
        self.__request.set_request(request)
        request_data = self.__request.get_request_data("post",
                                                       {"metric_id": ""})

        if request_data["metric_id"] == "" or not self.__metric.get_one_by_id(
                request_data["metric_id"]):
            return JsonResponse(
                self.__response.send_private_failure(
                    [{
                        "type": "error",
                        "message": _("Error! Metric is required.")
                    }], {}, self.__correlation_id))

        metrics = self.__settings.get_value_by_key("builder_metrics",
                                                   json.dumps([]))

        metrics = json.loads(metrics)

        if request_data["metric_id"] in metrics:
            return JsonResponse(
                self.__response.send_private_success(
                    [{
                        "type": "success",
                        "message": _("Metric added successfully.")
                    }], {}, self.__correlation_id))

        metrics.append(request_data["metric_id"])

        result = self.__settings.update_options(
            {"builder_metrics": json.dumps(metrics)})

        if result:
            return JsonResponse(
                self.__response.send_private_success(
                    [{
                        "type": "success",
                        "message": _("Metric added successfully.")
                    }], {}, self.__correlation_id))

        else:
            return JsonResponse(
                self.__response.send_private_failure([{
                    "type":
                    "error",
                    "message":
                    _("Error! Something goes wrong while adding metric.")
                }], {}, self.__correlation_id))

    @allow_if_authenticated_and_has_permission("manage_settings")
    def delete(self, request, metric_id):

        self.__correlation_id = request.META[
            "X-Correlation-ID"] if "X-Correlation-ID" in request.META else ""
        metrics = self.__settings.get_value_by_key("builder_metrics",
                                                   json.dumps([]))

        metrics = json.loads(metrics)

        if metric_id not in metrics:
            return JsonResponse(
                self.__response.send_private_success(
                    [{
                        "type": "success",
                        "message": _("Metric deleted successfully.")
                    }], {}, self.__correlation_id))

        metrics.remove(metric_id)

        result = self.__settings.update_options(
            {"builder_metrics": json.dumps(metrics)})

        if result:
            return JsonResponse(
                self.__response.send_private_success(
                    [{
                        "type": "success",
                        "message": _("Metric deleted successfully.")
                    }], {}, self.__correlation_id))

        else:
            return JsonResponse(
                self.__response.send_private_failure([{
                    "type":
                    "error",
                    "message":
                    _("Error! Something goes wrong while deleting metric.")
                }], {}, self.__correlation_id))
예제 #7
0
class BuilderComponents(View):

    __request = None
    __response = None
    __helpers = None
    __form = None
    __logger = None
    __user_id = None
    __settings = None
    __component = None
    __component_group = None
    __correlation_id = None

    def __init__(self):
        self.__request = Request()
        self.__response = Response()
        self.__helpers = Helpers()
        self.__settings = Settings()
        self.__component = ComponentModule()
        self.__component_group = ComponentGroupModule()
        self.__form = Form()
        self.__logger = self.__helpers.get_logger(__name__)
        self.__form.add_validator(ExtraRules())

    @allow_if_authenticated_and_has_permission("manage_settings")
    def post(self, request):

        self.__correlation_id = request.META[
            "X-Correlation-ID"] if "X-Correlation-ID" in request.META else ""
        self.__request.set_request(request)
        request_data = self.__request.get_request_data("post",
                                                       {"component_id": ""})

        if request_data["component_id"] == "":
            return JsonResponse(
                self.__response.send_private_failure([{
                    "type":
                    "error",
                    "message":
                    _("Error! Compnent or compnent group is required.")
                }], {}, self.__correlation_id))

        if not self.__component.get_one_by_id(
                request_data["component_id"]
        ) and not self.__component_group.get_one_by_id(
                request_data["component_id"]):
            return JsonResponse(
                self.__response.send_private_failure([{
                    "type":
                    "error",
                    "message":
                    _("Error! Compnent or compnent group is required.")
                }], {}, self.__correlation_id))

        components = self.__settings.get_value_by_key("builder_components",
                                                      json.dumps([]))

        components = json.loads(components)

        if request_data["component_id"] in components:
            return JsonResponse(
                self.__response.send_private_success(
                    [{
                        "type": "success",
                        "message": _("Component added successfully.")
                    }], {}, self.__correlation_id))

        components.append(request_data["component_id"])

        result = self.__settings.update_options(
            {"builder_components": json.dumps(components)})

        if result:
            return JsonResponse(
                self.__response.send_private_success(
                    [{
                        "type": "success",
                        "message": _("Component added successfully.")
                    }], {}, self.__correlation_id))

        else:
            return JsonResponse(
                self.__response.send_private_failure([{
                    "type":
                    "error",
                    "message":
                    _("Error! Something goes wrong while adding component.")
                }], {}, self.__correlation_id))

    @allow_if_authenticated_and_has_permission("manage_settings")
    def delete(self, request, component_id):

        self.__correlation_id = request.META[
            "X-Correlation-ID"] if "X-Correlation-ID" in request.META else ""
        components = self.__settings.get_value_by_key("builder_components",
                                                      json.dumps([]))

        components = json.loads(components)

        if component_id not in components:
            return JsonResponse(
                self.__response.send_private_success(
                    [{
                        "type": "success",
                        "message": _("Component deleted successfully.")
                    }], {}, self.__correlation_id))

        components.remove(component_id)

        result = self.__settings.update_options(
            {"builder_components": json.dumps(components)})

        if result:
            return JsonResponse(
                self.__response.send_private_success(
                    [{
                        "type": "success",
                        "message": _("Component deleted successfully.")
                    }], {}, self.__correlation_id))

        else:
            return JsonResponse(
                self.__response.send_private_failure([{
                    "type":
                    "error",
                    "message":
                    _("Error! Something goes wrong while deleting component.")
                }], {}, self.__correlation_id))
예제 #8
0
class Settings(View):

    __request = None
    __response = None
    __helpers = None
    __form = None
    __settings_module = None
    __logger = None
    __acl = None

    def __init__(self):
        self.__request = Request()
        self.__response = Response()
        self.__helpers = Helpers()
        self.__form = Form()
        self.__settings_module = Settings_Module()
        self.__acl = ACL()
        self.__logger = self.__helpers.get_logger(__name__)

    def post(self, request):

        if not self.__acl.user_has_permission(request.user.id, "manage_settings"):
            return JsonResponse(self.__response.send_private_failure([{
                "type": "error",
                "message": _("Error! Invalid Request.")
            }]))

        self.__request.set_request(request)
        request_data = self.__request.get_request_data("post", {
            "app_name": "",
            "app_email": "",
            "app_url": "",
            "app_description": "",
            "google_analytics_account": "",
            "reset_mails_messages_count": "",
            "reset_mails_expire_after": "",
            "access_tokens_expire_after": "",
            "prometheus_token": ""
        })

        self.__form.add_inputs({
            'app_name': {
                'value': request_data["app_name"],
                'sanitize': {
                    'escape': {},
                    'strip': {}
                },
                'validate': {
                    'alpha_numeric': {
                        'error': _('Error! Application name must be alpha numeric.')
                    },
                    'length_between': {
                        'param': [3, 10],
                        'error': _('Error! Application name must be 5 to 10 characters long.')
                    }
                }
            },
            'app_email': {
                'value': request_data["app_email"],
                'sanitize': {
                    'escape': {},
                    'strip': {}
                },
                'validate': {
                    'email': {
                        'error': _('Error! Application email is invalid.')
                    }
                }
            },
            'app_url': {
                'value': request_data["app_url"],
                'sanitize': {
                    'escape': {},
                    'strip': {}
                },
                'validate': {
                    'url': {
                        'error': _('Error! Application url is invalid.')
                    }
                }
            },
            'app_description': {
                'value': request_data["app_description"],
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'length_between': {
                        'param': [0, 300],
                        'error': _('Error! App description is very long.')
                    },
                    'optional': {}
                }
            },
            "prometheus_token": {
                'value': request_data["prometheus_token"],
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'length_between': {
                        'param': [0, 100],
                        'error': _('Error! Prometheus token is invalid.')
                    },
                    'optional': {}
                }
            },
            'google_analytics_account': {
                'value': request_data["google_analytics_account"],
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'length_between': {
                        'param': [0, 30],
                        'error': _('Error! Google analytics account is invalid.')
                    },
                    'optional': {}
                }
            },
            'reset_mails_messages_count': {
                'value': request_data["reset_mails_messages_count"],
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'digit': {
                        'error': _('Error! Reset mails count is invalid.')
                    },
                    'greater_than': {
                        'error': _('Error! Reset mails count is invalid.'),
                        'param': [0]
                    }
                }
            },
            'reset_mails_expire_after': {
                'value': request_data["reset_mails_expire_after"],
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'digit': {
                        'error': _('Error! Reset mails expiry interval is invalid.')
                    },
                    'greater_than': {
                        'error': _('Error! Reset mails count is invalid.'),
                        'param': [0]
                    }
                }
            },
            'access_tokens_expire_after': {
                'value': request_data["access_tokens_expire_after"],
                'sanitize': {
                    'strip': {}
                },
                'validate': {
                    'digit': {
                        'error': _('Error! Access token expiry interval is invalid.')
                    },
                    'greater_than': {
                        'error': _('Error! Access token expiry interval is invalid.'),
                        'param': [0]
                    }
                }
            },
        })

        self.__form.process()

        if not self.__form.is_passed():
            return JsonResponse(self.__response.send_private_failure(self.__form.get_errors(with_type=True)))

        result = self.__settings_module.update_options({
            "app_name": self.__form.get_input_value("app_name"),
            "app_email": self.__form.get_input_value("app_email"),
            "app_url": self.__form.get_input_value("app_url"),
            "app_description": self.__form.get_input_value("app_description"),
            "google_analytics_account": self.__form.get_input_value("google_analytics_account"),
            "reset_mails_messages_count": self.__form.get_input_value("reset_mails_messages_count"),
            "reset_mails_expire_after": self.__form.get_input_value("reset_mails_expire_after"),
            "access_tokens_expire_after": self.__form.get_input_value("access_tokens_expire_after"),
            "prometheus_token": self.__form.get_input_value("prometheus_token")
        })

        if result:
            return JsonResponse(self.__response.send_private_success([{
                "type": "success",
                "message": _("Settings updated successfully.")
            }]))

        else:
            return JsonResponse(self.__response.send_private_failure([{
                "type": "error",
                "message": _("Error! Something goes wrong while updating settings.")
            }]))