Skip to content

Commit 34ad904

Browse files
committed
chore: formatting
1 parent 23fddf9 commit 34ad904

File tree

3 files changed

+39
-23
lines changed

3 files changed

+39
-23
lines changed

invenio_rdm_records/proxies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@
4343
current_rdm_records_storage_service = LocalProxy(
4444
lambda: current_app.extensions["invenio-rdm-records"].storage_service
4545
)
46-
"""Helper proxy to get the current RDM-Records storage service."""
46+
"""Helper proxy to get the current RDM-Records storage service."""

invenio_rdm_records/services/storage/service.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66
# it under the terms of the MIT License; see LICENSE file for more details.
77

88
import logging
9+
910
from flask import current_app
1011
from invenio_access.permissions import system_identity
1112
from invenio_search.engine import dsl
13+
1214
from invenio_rdm_records.records.models import RDMRecordQuota
1315

1416
logger = logging.getLogger(__name__)
1517

18+
1619
class StorageService:
1720
"""Service providing per-user storage quota information."""
1821

@@ -28,7 +31,10 @@ def default_quota(self):
2831
@property
2932
def max_additional_quota(self):
3033
"""Get the maximum additional quota allowed per user."""
31-
return current_app.config.get("RDM_FILES_DEFAULT_MAX_ADDITIONAL_QUOTA_SIZE") or 150 * 10**9
34+
return (
35+
current_app.config.get("RDM_FILES_DEFAULT_MAX_ADDITIONAL_QUOTA_SIZE")
36+
or 150 * 10**9
37+
)
3238

3339
def _search_user_resources(self, user, drafts=False):
3440
"""Fetch user records or drafts."""
@@ -47,7 +53,9 @@ def _search_user_resources(self, user, drafts=False):
4753

4854
def _resolve_records_and_quotas(self, items, draft=False):
4955
"""Resolve search hits and fetch quotas."""
50-
cls = self.records_service.draft_cls if draft else self.records_service.record_cls
56+
cls = (
57+
self.records_service.draft_cls if draft else self.records_service.record_cls
58+
)
5159

5260
records = []
5361
parent_ids = set()
@@ -90,14 +98,16 @@ def _compute_usage(self, records, quotas):
9098
total_extra += extra_quota
9199
total_used += additional_used
92100

93-
results.append({
94-
"item": item,
95-
"record": record,
96-
"quota": quota,
97-
"used_bytes": used_bytes,
98-
"extra_quota": extra_quota,
99-
"additional_used": additional_used,
100-
})
101+
results.append(
102+
{
103+
"item": item,
104+
"record": record,
105+
"quota": quota,
106+
"used_bytes": used_bytes,
107+
"extra_quota": extra_quota,
108+
"additional_used": additional_used,
109+
}
110+
)
101111

102112
return results, total_extra, total_used
103113

@@ -115,8 +125,7 @@ def get_user_storage_usage(self, user, include_drafts=True):
115125
draft_data, extra_d, used_d = [], 0, 0
116126
if include_drafts:
117127
draft_data, extra_d, used_d = self._process_resources(
118-
self._search_user_resources(user, drafts=True),
119-
draft=True
128+
self._search_user_resources(user, drafts=True), draft=True
120129
)
121130

122131
return {

invenio_rdm_records/views.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from flask import Blueprint, abort, current_app, render_template
1616
from flask_login import current_user, login_required
1717
from invenio_records_resources.services.files.transfer import constants
18+
1819
from .proxies import current_rdm_records_storage_service
1920

2021
blueprint = Blueprint("invenio_rdm_records_ext", __name__)
@@ -120,6 +121,7 @@ def file_transfer_type():
120121

121122
return {"transfer_types": file_transfer_type_constants}
122123

124+
123125
def _format_storage(data):
124126
"""Format storage data for UI."""
125127
BYTES_TO_GB = 1e9
@@ -129,15 +131,19 @@ def _format_storage(data):
129131
item = e["item"]
130132
record = e["record"]
131133

132-
rows.append({
133-
"title": item.get("metadata", {}).get("title", "Empty title"),
134-
"url": item["links"]["self_html"],
135-
"additional_quota": round(e["extra_quota"] / BYTES_TO_GB, 1),
136-
"used": round(e["used_bytes"] / BYTES_TO_GB, 1),
137-
"total": round((data["default_quota"] + e["extra_quota"]) / BYTES_TO_GB, 1),
138-
"date": item.get("metadata", {}).get("publication_date", ""),
139-
"status": "Draft" if not record.is_published else "Published",
140-
})
134+
rows.append(
135+
{
136+
"title": item.get("metadata", {}).get("title", "Empty title"),
137+
"url": item["links"]["self_html"],
138+
"additional_quota": round(e["extra_quota"] / BYTES_TO_GB, 1),
139+
"used": round(e["used_bytes"] / BYTES_TO_GB, 1),
140+
"total": round(
141+
(data["default_quota"] + e["extra_quota"]) / BYTES_TO_GB, 1
142+
),
143+
"date": item.get("metadata", {}).get("publication_date", ""),
144+
"status": "Draft" if not record.is_published else "Published",
145+
}
146+
)
141147

142148
return {
143149
"default_quota": round(data["default_quota"] / BYTES_TO_GB, 1),
@@ -150,6 +156,7 @@ def _format_storage(data):
150156
"records": rows,
151157
}
152158

159+
153160
@blueprint.route("/account/settings/quota/", endpoint="storage_settings")
154161
@login_required
155162
def storage_settings():
@@ -164,4 +171,4 @@ def storage_settings():
164171
return render_template(
165172
"invenio_rdm_records/settings/storage.html",
166173
storage=storage,
167-
)
174+
)

0 commit comments

Comments
 (0)