|
@@ -1,11 +1,17 @@
|
|
|
+import json
|
|
|
import logging
|
|
|
|
|
|
+from django.conf import settings
|
|
|
+from django.contrib.auth.decorators import login_required
|
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
|
from django.db.models import Avg, Count, F
|
|
|
+from django.http import HttpResponse
|
|
|
from django.views.generic import DetailView, ListView
|
|
|
from django.views.generic.list import MultipleObjectMixin
|
|
|
|
|
|
-from .models import Developer, Game, GameSystem, Genre, Publisher, GameCollection
|
|
|
+from games.tasks import update_roms
|
|
|
+
|
|
|
+from .models import Developer, Game, GameCollection, GameSystem, Genre, Publisher
|
|
|
|
|
|
logger = logging.Logger(__name__)
|
|
|
|
|
@@ -150,3 +156,15 @@ class GameCollectionDetail(DetailView, LoginRequiredMixin):
|
|
|
object_list=object_list, **kwargs
|
|
|
)
|
|
|
return context
|
|
|
+
|
|
|
+
|
|
|
+@login_required
|
|
|
+def trigger_rom_update(request):
|
|
|
+ full_scan = request.GET.get("full_scan")
|
|
|
+ if full_scan == "true":
|
|
|
+ full_scan = True
|
|
|
+ else:
|
|
|
+ full_scan = False
|
|
|
+ all_slugs = settings.GAME_SYSTEM_DEFAULTS.keys()
|
|
|
+ update_roms.delay(all_slugs, full_scan=full_scan)
|
|
|
+ return HttpResponse({"success": "true"}, mimetype="application/json")
|