diff --git a/apps/reports/api/assets/base.py b/apps/reports/api/assets/base.py index f905777d4..f21307e8d 100644 --- a/apps/reports/api/assets/base.py +++ b/apps/reports/api/assets/base.py @@ -6,7 +6,7 @@ def group_stats(queryset, alias, key, label_map=None): queryset .exclude(**{f'{key}__isnull': True}) .values(**{alias: F(key)}) - .annotate(total=Count('id')) + .annotate(total=Count('id', distinct=True)) ) data = [ diff --git a/apps/reports/api/users/change_password.py b/apps/reports/api/users/change_password.py index 2b633f65f..4737c912d 100644 --- a/apps/reports/api/users/change_password.py +++ b/apps/reports/api/users/change_password.py @@ -8,7 +8,7 @@ from rest_framework.views import APIView from audits.models import PasswordChangeLog from common.permissions import IsValidLicense -from common.utils import lazyproperty, get_ip_city, get_logger +from common.utils import lazyproperty, get_logger from rbac.permissions import RBACPermission from reports.mixins import DateRangeMixin @@ -24,22 +24,6 @@ class UserChangeSecretApi(DateRangeMixin, APIView): } permission_classes = [RBACPermission, IsValidLicense] - @staticmethod - def get_change_password_region_distribution(queryset): - unique_ips = queryset.values_list('remote_addr', flat=True).distinct() - data = defaultdict(int) - for ip in unique_ips: - try: - city = str(get_ip_city(ip)) - if not city: - continue - data[city] += 1 - except Exception: - logger.debug(f"Failed to get city for IP {ip}, skipping", exc_info=True) - continue - - return [{'name': k, 'value': v} for k, v in data.items()] - def get_change_password_metrics(self, queryset): filtered_queryset = self.filter_by_date_range(queryset, 'datetime') @@ -82,5 +66,4 @@ class UserChangeSecretApi(DateRangeMixin, APIView): 'dates_metrics_total': self.get_change_password_metrics(qs), } - data['change_password_region_distribution'] = self.get_change_password_region_distribution(qs) return JsonResponse(data, status=200) diff --git a/apps/templates/_foot_js.html b/apps/templates/_foot_js.html index 518047724..c411b394a 100644 --- a/apps/templates/_foot_js.html +++ b/apps/templates/_foot_js.html @@ -1,79 +1,56 @@ {% load i18n %} {% load static %} - - - - - - - - - - {% if INTERFACE.footer_content %} - - + .markdown-footer p{ margin: 0; } + .markdown-footer a{ color: #428bca; text-decoration: none; } + .markdown-footer a:hover{ text-decoration: underline; } + + {% endif %} + - + var html = md.render(src); + if (window.DOMPurify) { + html = window.DOMPurify.sanitize(html); + } + container.innerHTML = html; + container.querySelectorAll('a').forEach(function (a) { + a.setAttribute('target', '_blank'); + a.setAttribute('rel', 'noopener noreferrer'); + }); + })(); + \ No newline at end of file