Added Repository Quota setting
This commit is contained in:
parent
755e313c61
commit
3a4f5a0394
10 changed files with 102 additions and 2 deletions
|
|
@ -0,0 +1,28 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
from ...models import BorgRepository
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Update the used quota values"
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument("--user-id", type=int)
|
||||
parser.add_argument("--repository-id", type=int, nargs="+")
|
||||
|
||||
def handle(self, *args, **options):
|
||||
print(options)
|
||||
|
||||
qs = BorgRepository.objects.all()
|
||||
|
||||
if options.get("user_id"):
|
||||
qs = qs.filter(user__pk=options.get("user_id"))
|
||||
|
||||
if options.get("repository_id"):
|
||||
qs = qs.filter(pk__in=options.get("repository_id"))
|
||||
|
||||
print(qs)
|
||||
|
||||
for repo in qs:
|
||||
repo.refresh_quota()
|
||||
|
||||
BorgRepository.objects.bulk_update(qs, ["used_quota"])
|
||||
Loading…
Add table
Add a link
Reference in a new issue