management.views.settings ========================= .. py:module:: management.views.settings .. autoapi-nested-parse:: Settings views. Module Contents --------------- .. py:data:: LOG_LEVELS :value: ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] .. py:class:: SettingsView(security_feature = None, *args, **kwargs) Bases: :py:obj:`trustpoint.page_context.PageContextMixin`, :py:obj:`management.security.mixins.SecurityLevelMixin`, :py:obj:`trustpoint.logger.LoggerMixin`, :py:obj:`django.views.generic.edit.FormView`\ [\ :py:obj:`management.forms.SecurityConfigForm`\ ] A view for managing security settings in the Trustpoint application. This view handles the display and processing of the SecurityConfigForm, allowing users to configure security-related settings such as security mode, auto-generated PKI, and notification configurations. .. py:attribute:: template_name :value: 'management/settings.html' .. py:attribute:: form_class .. py:attribute:: success_url .. py:attribute:: page_category :value: 'management' .. py:attribute:: page_name :value: 'settings' .. py:method:: post(request, *args, **kwargs) Handle POST requests for both SecurityConfig and NotificationConfig forms. :param request: The HTTP request object. :type request: HttpRequest :param \*args: Positional arguments. :type \*args: tuple :param \*\*kwargs: Keyword arguments. :type \*\*kwargs: dict :param Returns: :param -------: :param HttpResponse: A response object. .. py:method:: get_form_kwargs() Get the keyword arguments for instantiating the form. This method retrieves or creates the `SecurityConfig` instance and includes it in the form's keyword arguments. Returns: ------- dict The keyword arguments for the form, including the `instance`. .. py:method:: form_valid(form) Handle valid form submission. This method processes the form data, applies security settings, and displays success messages to the user. :param form: The form instance containing the submitted data. :type form: SecurityConfigForm :param Returns: :param -------: :param HttpResponse: A redirect response to the success URL. .. py:method:: form_invalid(form) Handle invalid form submission. This method displays an error message and re-renders the form with validation errors. :param form: The form instance containing the submitted data. :type form: SecurityConfigForm :param Returns: :param -------: :param HttpResponse: A response rendering the form with errors. .. py:method:: get_context_data(**kwargs) Build the context dictionary for rendering the settings page. This method adds page metadata, notification configurations, log levels, task execution status, and the current log level to the context. :param \*\*kwargs: Additional context variables. :type \*\*kwargs: dict :param Returns: :param -------: :param dict[str: The context dictionary for the template. :param Any]: The context dictionary for the template. .. py:class:: ChangeLogLevelView(**kwargs) Bases: :py:obj:`django.views.View` A view for changing the logging level in the Trustpoint application. This view handles POST requests to update the logging level dynamically. .. py:method:: post(request) Handle POST requests to change the logging level. This method validates the provided log level, updates the logger and database configuration if valid, and redirects back to the settings page. :param request: The HTTP request object containing the POST data. :type request: HttpRequest :param Returns: :param -------: :param HttpResponse: A redirect response to the settings page.