]> git.ipfire.org Git - pbs.git/commitdiff
users: Rename quota to storage quota
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 20 Sep 2023 14:08:10 +0000 (14:08 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 20 Sep 2023 14:08:10 +0000 (14:08 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/uploads.py
src/buildservice/users.py
src/database.sql
src/templates/users/show.html
tests/test.py

index 733baef464304f963f49597bf3b42e8ea638aa62..398d801c891eac5f05df0a6d7c064622ce101b2e 100644 (file)
@@ -63,7 +63,7 @@ class Uploads(base.Object):
                # Check quota for users
                if user:
                        # This will raise an exception if the quota has been exceeded
-                       user.check_quota(size)
+                       user.check_storage_quota(size)
 
                # Allocate a new temporary file
                async with self.backend.tempfile(delete=False) as f:
index 5bc1e1b6d277fe163771c1d0538b5ae85050028a..de9eea04b28e4c989a313603c4b1bf0477717b52 100644 (file)
@@ -631,33 +631,33 @@ class User(base.DataObject):
                if self.data.bugzilla_api_key:
                        return bugtracker.Bugzilla(self.backend, self.data.bugzilla_api_key)
 
-       # Quota
+       # Storage Quota
 
-       def get_quota(self):
-               return self.data.quota
+       def get_storage_quota(self):
+               return self.data.storage_quota
 
-       def set_quota(self, quota):
-               self._set_attribute("quota", quota)
+       def set_storage_quota(self, quota):
+               self._set_attribute("storage_quota", quota)
 
-       quota = property(get_quota, set_quota)
+       storage_quota = property(get_storage_quota, set_storage_quota)
 
-       def has_exceeded_quota(self, size=None):
+       def has_exceeded_storage_quota(self, size=None):
                """
                        Returns True if this user has exceeded their quota
                """
                # Skip quota check if this user has no quota
-               if not self.quota:
+               if not self.storage_quota:
                        return
 
-               return self.disk_usage + (size or 0) >= self.quota
+               return self.disk_usage + (size or 0) >= self.storage_quota
 
-       def check_quota(self, size=None):
+       def check_storage_quota(self, size=None):
                """
                        Determines the user's disk usage
                        and raises an exception when the user is over quota.
                """
                # Raise QuotaExceededError if this user is over quota
-               if self.has_exceeded_quota(size=size):
+               if self.has_exceeded_storage_quota(size=size):
                        raise QuotaExceededError
 
        @lazy_property
index 9aa58164d86e2eef4b4c73df28c1e9d50f1e43f7..d88aa10810dc0c3015cab472f4a0906950f847be 100644 (file)
@@ -1120,7 +1120,7 @@ CREATE TABLE public.users (
     deleted_at timestamp without time zone,
     registered_at timestamp without time zone DEFAULT now() NOT NULL,
     admin boolean DEFAULT false NOT NULL,
-    quota bigint,
+    storage_quota bigint,
     perms text[] DEFAULT ARRAY[]::text[] NOT NULL,
     _attrs bytea,
     bugzilla_api_key text
index d9e2579661eea35ca6d2ed8de9395a33a613c3c5..b4b5c56387b1957fbe3665cb2a2d357de6ab1b41 100644 (file)
                                                {% if user.has_perm(current_user) %}
                                                        <div class="level-item has-text-centered">
                                                                <div>
-                                                                       {% if user.quota %}
+                                                                       {% if user.storage_quota %}
                                                                                <p class="heading">{{ _("Disk Quota") }}</p>
-                                                                               <p class="title {% if user.has_exceeded_quota() %}has-text-danger{% end %}">
-                                                                                       {{ format_size(user.disk_usage) }}/{{ format_size(user.quota) }}
+                                                                               <p class="title {% if user.has_exceeded_storage_quota() %}has-text-danger{% end %}">
+                                                                                       {{ format_size(user.disk_usage) }}/{{ format_size(user.storage_quota) }}
                                                                                </p>
                                                                        {% else %}
                                                                                <p class="heading">{{ _("Disk Usage") }}</p>
index 6dd65a74630cb60057bdb114a294d0a3bfc83613..d8b2b11e96dd488cc452d5af023a0859f5bed6b5 100644 (file)
@@ -125,8 +125,8 @@ class TestCase(unittest.IsolatedAsyncioTestCase):
                        "email" : [b"joe.tester@ipfire.org"],
                })
 
-               # Set a quota
-               self.user.quota = 104857600 # 100 MiB
+               # Set storage quota
+               self.user.storage_quota = 104857600 # 100 MiB
 
                # Create a distribution
                self.distro = self.backend.distros.create("Default Test Distribution", "test", 1)