Compare commits

..

No commits in common. "5e527ef10d0230ab8c54df01755f31a5839b92d1" and "4b74f5d04b67961ca39932f6185fe3c17200a88f" have entirely different histories.

4 changed files with 6 additions and 22 deletions

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -1,6 +1,6 @@
[tool.poetry]
name = "gva"
version = "0.15.1"
version = "0.15.0"
description = "gnuviechadmin web interface"
authors = ["Jan Dittberner <jan@dittberner.info>"]
license = "AGPL-3+"