diff --git a/docs/changelog.rst b/docs/changelog.rst index c8a6893..89721cb 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,9 +1,6 @@ Changelog ========= -* :release:`0.15.1 <2023-07-23> -* :bug:`-` remove stale disk usage stats older than 30 minutes - * :release:`0.15.0 <2023-07-23> * :feature:`10` add disk usage details for mail and web diff --git a/gnuviechadmin/gnuviechadmin/__init__.py b/gnuviechadmin/gnuviechadmin/__init__.py index b31a146..d1d1bd2 100644 --- a/gnuviechadmin/gnuviechadmin/__init__.py +++ b/gnuviechadmin/gnuviechadmin/__init__.py @@ -1,4 +1,4 @@ # import celery_app to initialize it from gnuviechadmin.celery import app as celery_app # NOQA -__version__ = "0.15.1" +__version__ = "0.15.0" diff --git a/gnuviechadmin/hostingpackages/views.py b/gnuviechadmin/hostingpackages/views.py index 37cd749..ea5b4ac 100644 --- a/gnuviechadmin/hostingpackages/views.py +++ b/gnuviechadmin/hostingpackages/views.py @@ -6,7 +6,6 @@ from __future__ import absolute_import import http import logging -from datetime import timedelta from django.conf import settings from django.contrib import messages @@ -14,7 +13,6 @@ from django.contrib.auth import get_user_model from django.contrib.auth.mixins import PermissionRequiredMixin, UserPassesTestMixin from django.http import Http404 from django.shortcuts import get_object_or_404, redirect -from django.utils import timezone from django.utils.translation import gettext as _ from django.views.generic import DetailView, ListView from django.views.generic.edit import CreateView, FormView @@ -280,8 +278,8 @@ class AddHostingOption(StaffUserRequiredMixin, FormView): class HasDiskUsageUploadPermission(BasePermission): def has_permission(self, request, view): return ( - request.user.has_perm("hostingpackages.add_customerpackagediskusage") - and request.method == "POST" + request.user.has_perm("hostingpackages.add_customerpackagediskusage") + and request.method == "POST" ) @@ -294,15 +292,12 @@ class UploadCustomerPackageDiskUsage(APIView): if request.content_type != "application/json": return Response("Unacceptable", status=http.HTTPStatus.BAD_REQUEST) - submitted_sources = set() - for row in request.data: user = row["user"] for key in row: if key == "user": continue else: - submitted_sources.add(key) for item, size in row[key].items(): try: package = CustomerHostingPackage.objects.get( @@ -320,9 +315,7 @@ class UploadCustomerPackageDiskUsage(APIView): if key == "mail": try: - ma_mb = package.mailboxes.get( - username=item - ).mailaddressmailbox_set.first() + ma_mb = package.mailboxes.get(username=item).mailaddressmailbox_set.first() if ma_mb: metric.email_address_id = ma_mb.mailaddress_id except Mailbox.DoesNotExist: @@ -334,12 +327,6 @@ class UploadCustomerPackageDiskUsage(APIView): "hosting package for user %s does not exist", user ) - if submitted_sources: - CustomerPackageDiskUsage.objects.filter( - source__in=submitted_sources, - modified__lt=timezone.now() - timedelta(minutes=30), - ).delete() - logger.info("usage data submitted by %s", request.user) return Response("Accepted", status=http.HTTPStatus.ACCEPTED) @@ -369,7 +356,7 @@ class CustomerHostingPackageDiskUsageDetails(StaffOrSelfLoginRequiredMixin, Deta mail_usage, web_usage, mysql_usage, pgsql_usage = [], [], [], [] for usage in self.get_object().customerpackagediskusage_set.order_by( - "-used_kb" + "-used_kb" ): if usage.used_kb <= 0: continue diff --git a/pyproject.toml b/pyproject.toml index 2bde72f..48a9242 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "gva" -version = "0.15.1" +version = "0.15.0" description = "gnuviechadmin web interface" authors = ["Jan Dittberner "] license = "AGPL-3+"