diff --git a/app/urls.py b/app/urls.py index b81555e..87be357 100644 --- a/app/urls.py +++ b/app/urls.py @@ -74,6 +74,11 @@ urlpatterns = [ path( f"{settings.HOOK_PATH}//", hooks.HookAPI.as_view(), name="hook" ), + path( + f"{settings.ASSET_PATH}//", + assets.AssetRestrictionAPI.as_view(), + name="asset", + ), path("signals//", signals.SignalList.as_view(), name="signals"), path( "signals//create/", diff --git a/core/migrations/0054_assetrestriction_webhook_id_alter_assetgroup_allowed.py b/core/migrations/0054_assetrestriction_webhook_id_alter_assetgroup_allowed.py index 0d5a824..aaaeeac 100644 --- a/core/migrations/0054_assetrestriction_webhook_id_alter_assetgroup_allowed.py +++ b/core/migrations/0054_assetrestriction_webhook_id_alter_assetgroup_allowed.py @@ -1,8 +1,9 @@ # Generated by Django 4.1.6 on 2023-02-10 21:07 -from django.db import migrations, models import uuid +from django.db import migrations, models + class Migration(migrations.Migration): diff --git a/core/templates/partials/assetrestriction-list.html b/core/templates/partials/assetrestriction-list.html index 6ebb1da..32e753c 100644 --- a/core/templates/partials/assetrestriction-list.html +++ b/core/templates/partials/assetrestriction-list.html @@ -28,7 +28,7 @@ + onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{settings.URL}}/{{settings.ASSET_PATH}}/{{ item.webhook_id }}/');"> diff --git a/core/templates/partials/hook-list.html b/core/templates/partials/hook-list.html index e867b33..52d4907 100644 --- a/core/templates/partials/hook-list.html +++ b/core/templates/partials/hook-list.html @@ -23,7 +23,7 @@ + onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{settings.URL}}/{{settings.HOOK_PATH}}/{{ item.hook }}/');"> diff --git a/core/views/assets.py b/core/views/assets.py index 993a6fe..9ce76fd 100644 --- a/core/views/assets.py +++ b/core/views/assets.py @@ -1,5 +1,9 @@ from django.contrib.auth.mixins import LoginRequiredMixin +from django.http import HttpResponse from mixins.views import AbortSave, ObjectCreate, ObjectDelete, ObjectList, ObjectUpdate +from rest_framework import status +from rest_framework.parsers import JSONParser +from rest_framework.views import APIView from core.forms import AssetGroupForm, AssetRestrictionForm from core.models import AssetGroup, AssetRestriction @@ -99,3 +103,18 @@ class AssetRestrictionDelete( LoginRequiredMixin, AssetRestrictionsPermissionMixin, ObjectDelete ): model = AssetRestriction + + +class AssetRestrictionAPI(APIView): + parser_classes = [JSONParser] + + def post(self, request, webhook_id): + log.debug(f"AssetAPI POST {webhook_id}: {request.data}") + + try: + webhook = AssetRestriction.objects.get(webhook_id=webhook_id) + except AssetRestriction.DoesNotExist: + log.error(f"AssetRestriction {webhook_id} does not exist") + return HttpResponse(status=status.HTTP_404_NOT_FOUND) + + return HttpResponse(status=status.HTTP_200_OK)