Add asset restriction webhook API
This commit is contained in:
parent
aa227c53ac
commit
c283c6c192
|
@ -74,6 +74,11 @@ urlpatterns = [
|
|||
path(
|
||||
f"{settings.HOOK_PATH}/<str:hook_name>/", hooks.HookAPI.as_view(), name="hook"
|
||||
),
|
||||
path(
|
||||
f"{settings.ASSET_PATH}/<str:webhook_id>/",
|
||||
assets.AssetRestrictionAPI.as_view(),
|
||||
name="asset",
|
||||
),
|
||||
path("signals/<str:type>/", signals.SignalList.as_view(), name="signals"),
|
||||
path(
|
||||
"signals/<str:type>/create/",
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
<td>
|
||||
<a
|
||||
class="has-text-grey"
|
||||
onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{settings.URL}}/{{settings.ASSET_PATH}}/{{ item.webhook_id }}');">
|
||||
onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{settings.URL}}/{{settings.ASSET_PATH}}/{{ item.webhook_id }}/');">
|
||||
<span class="icon" data-tooltip="Copy to clipboard">
|
||||
<i class="fa-solid fa-copy" aria-hidden="true"></i>
|
||||
</span>
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<td>
|
||||
<a
|
||||
class="has-text-grey"
|
||||
onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{settings.URL}}/{{settings.HOOK_PATH}}/{{ item.hook }}');">
|
||||
onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{settings.URL}}/{{settings.HOOK_PATH}}/{{ item.hook }}/');">
|
||||
<span class="icon" data-tooltip="Copy to clipboard">
|
||||
<i class="fa-solid fa-copy" aria-hidden="true"></i>
|
||||
</span>
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue