GdriveFolder code

This commit is contained in:
2026-05-13 09:32:22 +10:00
parent 504c2ee56b
commit 7d041e1fd0
11 changed files with 414 additions and 15 deletions
+25
View File
@@ -0,0 +1,25 @@
from django.core.management.base import BaseCommand, CommandError
from library.models import Work, Collection
from library.gdrive import sync_work, sync_collection
class Command(BaseCommand):
help = "Synchronizes folders and works"
def add_arguments(self, parser):
parser.add_argument("type", type=str, choices=["work", "collection"])
parser.add_argument("pk", nargs="?", type=int)
def handle(self, *args, **options):
if options["type"] == "work":
work = Work.objects.get(pk=options["pk"])
sync_work(work)
return
if options["type"] == "collection":
collection = Collection.objects.get(pk=options["pk"])
sync_collection(collection)
return
raise CommandError("Unknown object type")