fetch steam collection from event path

This commit is contained in:
2026-10-23 18:53:28 +02:00
parent 6e7a68d509
commit bc3d8158ec
2 changed files with 19 additions and 2 deletions
@@ -4,6 +4,7 @@ Django management command to fetch Steam Workshop collections
from django.core.management.base import BaseCommand, CommandError
from opus_magnum.utils import create_or_update_collection
from events.models import Event
from opus_magnum.models import SteamAPIKey, SteamCollection
@@ -12,6 +13,12 @@ class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument("url", type=str, help="Steam Workshop collection URL")
parser.add_argument(
"--event",
type=str,
required=True,
help="Path of the event the collection belongs to",
)
parser.add_argument(
"--force",
action="store_true",
@@ -22,6 +29,11 @@ class Command(BaseCommand):
url = options["url"]
force = options["force"]
try:
event = Event.objects.get(path=options["event"])
except Event.DoesNotExist:
raise CommandError(f"No event with path '{options['event']}'")
self.stdout.write(f"Fetching Steam collection from: {url}")
api_key = SteamAPIKey.objects.filter(is_active=True).first()
@@ -53,7 +65,7 @@ class Command(BaseCommand):
return
# Fetch and create/update collection
collection, created = create_or_update_collection(url)
collection, created = create_or_update_collection(url, event)
if created:
self.stdout.write(