home.views

Contains views that handle HTTP requests and return appropriate responses for the application.

Module Contents

home.views.SUCCESS = 25[source]
home.views.ERROR = 40[source]
class home.views.IndexView(**kwargs)[source]

Bases: django.views.generic.base.RedirectView

Redirects authenticated users to the dashboard page.

permanent = False[source]
pattern_name = 'home:dashboard'[source]
class home.views.DashboardView(*args, **kwargs)[source]

Bases: trustpoint.views.base.SortableTableMixin[management.models.NotificationModel], django.views.generic.list.ListView[management.models.NotificationModel]

Renders the dashboard page for authenticated users. Uses the ‘home/dashboard.html’ template.

Parameters:
  • args (Any)

  • kwargs (Any)

template_name = 'home/dashboard.html'[source]
model[source]
context_object_name = 'management'[source]
default_sort_param = '-created_at'[source]
paginate_by = 5[source]
last_week_dates[source]
static generate_last_week_dates()[source]

Generates date strings for last one week.

Returns:

A list of date strings from last one week.

Return type:

list[str]

get_queryset()[source]

Returns a queryset of NotificationModel instances.

Returns:

A QuerySet containing filtered notifications.

Return type:

Any

get_context_data(**kwargs)[source]

Fetch context data.

Parameters:

**kwargs (Any) – Keyword arguments passed to super().get_context_data.

Returns:

The context to render the page.

Return type:

dict[str, Any]

class home.views.NotificationDetailsView[source]

Bases: django.views.generic.detail.DetailView[management.models.NotificationModel]

Renders the notification details page for authenticated users.

template_name = 'home/notification_details.html'[source]
model[source]
context_object_name = 'notification'[source]
get_context_data(**kwargs)[source]

Adds information about the statuses of the Notification.

Parameters:

**kwargs (Any) – Keyword arguments passed to super().get_context_data.

Returns:

The context to render the page.

Return type:

dict[str, Any]

class home.views.NotificationMarkSolvedView[source]

Bases: django.views.generic.detail.DetailView[management.models.NotificationModel]

Mark notification as solved when viewed in the notification details page.

template_name = 'home/notification_details.html'[source]
model[source]
context_object_name = 'notification'[source]
get_context_data(**kwargs)[source]

Adds information about the solved status of the notification.

Parameters:

**kwargs (Any) – Keyword arguments passed to super().get_context_data.

Returns:

The context to render the page.

Return type:

dict[str, Any]

class home.views.AddDomainsAndDevicesView(**kwargs)[source]

Bases: trustpoint.logger.LoggerMixin, django.views.generic.base.TemplateView

View to execute the add_domains_and_devices management command and pass status to the template.

get(request, *args, **kwargs)[source]

Handles GET requests and redirects to the dashboard.

Parameters:
  • request (django.http.HttpRequest) – The HTTP request object.

  • *args (Any) – Additional positional arguments.

  • **kwargs (Any) – Keyword arguments passed to super().get_context_data.

Returns:

dashboard.

Return type:

The response that redirects the user to home

class home.views.DashboardChartsAndCountsView(**kwargs)[source]

Bases: trustpoint.logger.LoggerMixin, django.views.generic.base.TemplateView

View to mark the notification as Solved.

get(request, *args, **kwargs)[source]

Get dashboard data for panels, tables and charts.

Parameters:
  • request (django.http.HttpRequest) – The HTTP request object.

  • *args (Any) – Additional positional arguments.

  • **kwargs (Any) – Keyword arguments passed to super().get_context_data.

Returns:

The JSON response containing dashboard data.

Return type:

django.http.JsonResponse

get_device_charts_data(dashboard_data, start_date)[source]

Fetch data from database for device charts and add to dashboard data object.

Parameters:
  • dashboard_data (dict[str, Any]) – The dashboard data object.

  • start_date (datetime.datetime) – The start date for fetching device data.

Returns:

It returns nothing. It adds the device related data in dashboard_data object.

Return type:

None

get_cert_charts_data(dashboard_data, start_date)[source]

Fetch data from database for certificate charts and add to dashboard data object.

Parameters:
  • dashboard_data (dict[str, Any]) – The dashboard data object.

  • start_date (datetime.datetime) – The start date for fetching certificate data.

Returns:

It returns nothing. It adds the certificate related data in dashboard_data object.

Return type:

None

get_ca_charts_data(dashboard_data, start_date)[source]

Fetch data from database for issuing ca charts and add to dashboard data object.

Parameters:
  • dashboard_data (dict[str, Any]) – The dashboard data object.

  • start_date (datetime.datetime) – The start date for fetching issuing ca data.

Returns:

It returns nothing. It adds the issuing ca related data in dashboard_data object.

Return type:

None

get_device_count_by_onboarding_status(start_date)[source]

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

Parameters:

start_date (datetime.datetime) – The start date for fetching data.

Returns:

It returns device counts grouped by device onboarding status.

Return type:

dict[str, Any]

get_cert_counts(reference_date=None)[source]

Fetch certificate count from database.

Parameters:

reference_date (datetime.datetime | None) – The reference date to calculate expiration windows from. If None, uses current time.

Returns:

It returns certificate counts.

Return type:

dict[str, Any]

get_cert_counts_by_status_and_date()[source]

Fetch certificate counts grouped by issue date and certificate status from database.

Returns:

It returns certificate counts grouped by issue date and certificate status.

Return type:

list[dict[str, Any]]

get_cert_counts_by_status(start_date)[source]

Fetch certs count by onboarding status from database.

Parameters:

start_date (datetime.datetime) – The start date for fetching data.

Returns:

It returns device counts grouped by device onboarding status.

Return type:

dict[str, Any]

get_issuing_ca_counts()[source]

Fetch issuing CA count from database.

Returns:

It returns total, active and expired issuing CA counts.

Return type:

dict[str, Any]

get_device_counts_by_date_and_status()[source]

Fetch device count by date and onboarding status from database.

Returns:

It returns device count grouped by date and onboarding status.

Return type:

list[dict[str, Any]]

get_device_count_by_onboarding_protocol(start_date)[source]

Fetch device count by onboarding protocol from database.

Parameters:

start_date (datetime.datetime) – The start date for fetching data.

Returns:

It returns device count by onboarding protocol.

Return type:

dict[str, Any]

get_device_count_by_domain(start_date)[source]

Fetch onboarded devices count grouped by domain from database.

Parameters:

start_date (datetime.datetime) – The start date for fetching data.

Returns:

It returns onboarded devices count grouped by domain.

Return type:

list[dict[str, Any]]

get_cert_counts_by_issuing_ca(start_date)[source]

Fetch certificate count grouped by issuing ca from database.

Parameters:

start_date (datetime.datetime) – The start date for fetching data.

Returns:

It returns certificate count grouped by issuing ca (CN only).

Return type:

list[dict[str, Any]]

get_cert_counts_by_issuing_ca_and_date(start_date)[source]

Fetch certificate count grouped by issuing ca and date from database.

Parameters:

start_date (datetime.datetime) – The start date for fetching data.

Returns:

It returns certificate count grouped by issuing ca (CN only) and date.

Return type:

list[dict[str, Any]]

get_cert_counts_by_domain(start_date)[source]

Fetch certificate count grouped by domain from database.

Parameters:

start_date (datetime.datetime) – The start date for fetching data.

Returns:

It returns certificate count grouped by domain.

Return type:

list[dict[str, Any]]

get_cert_counts_by_profile(start_date)[source]

Fetch certificate count grouped by profile from database.

Parameters:

start_date (datetime.datetime) – The start date for fetching data.

Returns:

Dict of certificate count for each certificate profile, plus CA certificates.

Return type:

dict[str, Any]

get_issuing_ca_counts_by_type(start_date)[source]

Fetch issuing ca counts grouped by type from database.

Parameters:

start_date (datetime.datetime) – The start date for fetching data.

Returns:

It returns issuing ca counts grouped by type.

Return type:

dict[str, Any]

get_expiring_device_counts(reference_date=None)[source]

Fetch expiring domain credential counts from database.

Parameters:

reference_date (datetime.datetime | None) – 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)

Return type:

dict[str, Any]

get_expiring_issuing_ca_counts()[source]

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)

Return type:

dict[str, Any]

get_expired_device_counts()[source]

Fetch expired device counts from database.

Returns:

It returns counts of expired devices.

Return type:

dict[str, Any]