management.views.settings¶
Settings views.
Attributes¶
Classes¶
A view for managing security settings in the Trustpoint application. |
|
A view for changing the logging level in the Trustpoint application. |
Module Contents¶
- class management.views.settings.SettingsView(security_feature=None, *args, **kwargs)[source]¶
Bases:
trustpoint.page_context.PageContextMixin,management.security.mixins.SecurityLevelMixin,trustpoint.logger.LoggerMixin,django.views.generic.edit.FormView[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.
- Parameters:
security_feature (management.security.features.SecurityFeature)
args (Any)
kwargs (Any)
- get_form_kwargs()[source]¶
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.
- Return type:
dict[str, Any]
- form_valid(form)[source]¶
Handle valid form submission.
This method processes the form data, applies security settings, and displays success messages to the user.
- Parameters:
form (SecurityConfigForm) – The form instance containing the submitted data.
Returns
-------
HttpResponse – A redirect response to the success URL.
- Return type:
django.http.HttpResponse
- form_invalid(form)[source]¶
Handle invalid form submission.
This method displays an error message and re-renders the form with validation errors.
- Parameters:
form (SecurityConfigForm) – The form instance containing the submitted data.
Returns
-------
HttpResponse – A response rendering the form with errors.
- Return type:
django.http.HttpResponse
- get_context_data(**kwargs)[source]¶
Build the context dictionary for rendering the settings page.
This method adds page metadata, notification configurations, log levels, and the current log level to the context.
- Parameters:
**kwargs (Any) – Additional context variables.
Returns
-------
dict[str – The context dictionary for the template.
Any] – The context dictionary for the template.
- Return type:
dict[str, Any]
- class management.views.settings.ChangeLogLevelView(**kwargs)[source]¶
Bases:
django.views.ViewA view for changing the logging level in the Trustpoint application.
This view handles POST requests to update the logging level dynamically.
- post(request)[source]¶
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.
- Parameters:
request (HttpRequest) – The HTTP request object containing the POST data.
Returns
-------
HttpResponse – A redirect response to the settings page.
- Return type:
django.http.HttpResponse