home.views ========== .. py:module:: home.views .. autoapi-nested-parse:: Contains views that handle HTTP requests and return appropriate responses for the application. Module Contents --------------- .. py:data:: SUCCESS :value: 25 .. py:data:: ERROR :value: 40 .. py:class:: IndexView(**kwargs) Bases: :py:obj:`django.views.generic.base.RedirectView` Redirects authenticated users to the dashboard page. .. py:attribute:: permanent :value: False .. py:attribute:: pattern_name :value: 'home:dashboard' .. py:class:: DashboardView(*args, **kwargs) Bases: :py:obj:`trustpoint.views.base.SortableTableMixin`\ [\ :py:obj:`management.models.NotificationModel`\ ], :py:obj:`django.views.generic.list.ListView`\ [\ :py:obj:`management.models.NotificationModel`\ ] Renders the dashboard page for authenticated users. Uses the 'home/dashboard.html' template. .. py:attribute:: template_name :value: 'home/dashboard.html' .. py:attribute:: model .. py:attribute:: context_object_name :value: 'management' .. py:attribute:: default_sort_param :value: '-created_at' .. py:attribute:: paginate_by :value: 5 .. py:attribute:: last_week_dates .. py:method:: generate_last_week_dates() :staticmethod: Generates date strings for last one week. :returns: A list of date strings from last one week. .. py:method:: get_queryset() Returns a queryset of NotificationModel instances. :returns: A `QuerySet` containing filtered notifications. .. py:method:: get_context_data(**kwargs) Fetch context data. :param \*\*kwargs: Keyword arguments passed to super().get_context_data. :returns: The context to render the page. .. py:class:: NotificationDetailsView Bases: :py:obj:`django.views.generic.detail.DetailView`\ [\ :py:obj:`management.models.NotificationModel`\ ] Renders the notification details page for authenticated users. .. py:attribute:: template_name :value: 'home/notification_details.html' .. py:attribute:: model .. py:attribute:: context_object_name :value: 'notification' .. py:method:: get_context_data(**kwargs) Adds information about the statuses of the Notification. :param \*\*kwargs: Keyword arguments passed to super().get_context_data. :returns: The context to render the page. .. py:class:: NotificationMarkSolvedView Bases: :py:obj:`django.views.generic.detail.DetailView`\ [\ :py:obj:`management.models.NotificationModel`\ ] Mark notification as solved when viewed in the notification details page. .. py:attribute:: template_name :value: 'home/notification_details.html' .. py:attribute:: model .. py:attribute:: context_object_name :value: 'notification' .. py:method:: get_context_data(**kwargs) Adds information about the solved status of the notification. :param \*\*kwargs: Keyword arguments passed to super().get_context_data. :returns: The context to render the page. .. py:class:: AddDomainsAndDevicesView(**kwargs) Bases: :py:obj:`trustpoint.logger.LoggerMixin`, :py:obj:`django.views.generic.base.TemplateView` View to execute the add_domains_and_devices management command and pass status to the template. .. py:method:: get(request, *args, **kwargs) Handles GET requests and redirects to the dashboard. :param request: The HTTP request object. :param \*args: Additional positional arguments. :param \*\*kwargs: Keyword arguments passed to super().get_context_data. :returns: dashboard. :rtype: The response that redirects the user to home .. py:class:: DashboardChartsAndCountsView(**kwargs) Bases: :py:obj:`trustpoint.logger.LoggerMixin`, :py:obj:`django.views.generic.base.TemplateView` View to mark the notification as Solved. .. py:method:: get(request, *args, **kwargs) Get dashboard data for panels, tables and charts. :param request: The HTTP request object. :param \*args: Additional positional arguments. :param \*\*kwargs: Keyword arguments passed to super().get_context_data. :returns: The JSON response containing dashboard data. .. py:method:: get_device_charts_data(dashboard_data, start_date) Fetch data from database for device charts and add to dashboard data object. :param dashboard_data: The dashboard data object. :param start_date: The start date for fetching device data. :returns: It returns nothing. It adds the device related data in dashboard_data object. .. py:method:: get_cert_charts_data(dashboard_data, start_date) Fetch data from database for certificate charts and add to dashboard data object. :param dashboard_data: The dashboard data object. :param start_date: The start date for fetching certificate data. :returns: It returns nothing. It adds the certificate related data in dashboard_data object. .. py:method:: get_ca_charts_data(dashboard_data, start_date) Fetch data from database for issuing ca charts and add to dashboard data object. :param dashboard_data: The dashboard data object. :param start_date: The start date for fetching issuing ca data. :returns: It returns nothing. It adds the issuing ca related data in dashboard_data object. .. py:method:: get_device_count_by_onboarding_status(start_date) Fetch device count by onboarding status from database. Active devices: Devices with NoOnboardingConfigModel OR OnboardingConfigModel with ONBOARDED status Pending devices: Devices with OnboardingConfigModel with PENDING status :param start_date: The start date for fetching data. :returns: It returns device counts grouped by device onboarding status. .. py:method:: get_cert_counts(reference_date = None) Fetch certificate count from database. :param reference_date: The reference date to calculate expiration windows from. If None, uses current time. :returns: It returns certificate counts. .. py:method:: get_cert_counts_by_status_and_date() Fetch certificate counts grouped by issue date and certificate status from database. :returns: It returns certificate counts grouped by issue date and certificate status. .. py:method:: get_cert_counts_by_status(start_date) Fetch certs count by onboarding status from database. :param start_date: The start date for fetching data. :returns: It returns device counts grouped by device onboarding status. .. py:method:: get_issuing_ca_counts() Fetch issuing CA count from database. :returns: It returns total, active and expired issuing CA counts. .. py:method:: get_device_counts_by_date_and_status() Fetch device count by date and onboarding status from database. :returns: It returns device count grouped by date and onboarding status. .. py:method:: get_device_count_by_onboarding_protocol(start_date) Fetch device count by onboarding protocol from database. :param start_date: The start date for fetching data. :returns: It returns device count by onboarding protocol. .. py:method:: get_device_count_by_domain(start_date) Fetch onboarded devices count grouped by domain from database. :param start_date: The start date for fetching data. :returns: It returns onboarded devices count grouped by domain. .. py:method:: get_cert_counts_by_issuing_ca(start_date) Fetch certificate count grouped by issuing ca from database. :param start_date: The start date for fetching data. :returns: It returns certificate count grouped by issuing ca (CN only). .. py:method:: get_cert_counts_by_issuing_ca_and_date(start_date) Fetch certificate count grouped by issuing ca and date from database. :param start_date: The start date for fetching data. :returns: It returns certificate count grouped by issuing ca (CN only) and date. .. py:method:: get_cert_counts_by_domain(start_date) Fetch certificate count grouped by domain from database. :param start_date: The start date for fetching data. :returns: It returns certificate count grouped by domain. .. py:method:: get_cert_counts_by_profile(start_date) Fetch certificate count grouped by profile from database. :param start_date: The start date for fetching data. :returns: Dict of certificate count for each certificate profile, plus CA certificates. .. py:method:: get_issuing_ca_counts_by_type(start_date) Fetch issuing ca counts grouped by type from database. :param start_date: The start date for fetching data. :returns: It returns issuing ca counts grouped by type. .. py:method:: get_expiring_device_counts(reference_date = None) Fetch expiring domain credential counts from database. :param reference_date: The reference date for calculating expiration windows. If None, uses current time. :returns: It returns counts of domain credentials with expiring certificates (not devices). expiring_in_1_day: 0-24 hours expiring_in_7_days: 1-7 days (excluding the 24-hour window) .. py:method:: get_expiring_issuing_ca_counts() Fetch expiring issuing CA counts from database. :returns: It returns counts of issuing CAs with expiring certificates. expiring_in_1_day: 0-24 hours expiring_in_7_days: 24h-7 days (excluding the 24-hour window) .. py:method:: get_expired_device_counts() Fetch expired device counts from database. :returns: It returns counts of expired devices.