Add backend routing for feed updates
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import logging
|
||||
|
||||
from django.http import JsonResponse
|
||||
from django.http import JsonResponse, HttpRequest
|
||||
|
||||
from py_jwt_validator import PyJwtValidator, PyJwtException
|
||||
|
||||
@@ -68,3 +68,21 @@ class TwitterClass:
|
||||
class FeedViewSet(ModelViewSet):
|
||||
queryset = Feed.objects.all()
|
||||
serializer_class = FeedSerializer
|
||||
|
||||
@staticmethod
|
||||
@api_view(['PUT'])
|
||||
def update_feed(request: HttpRequest, feed_id):
|
||||
logger.debug('update_feed called for feed %d', feed_id)
|
||||
feed_instance = Feed.objects.get(pk=feed_id)
|
||||
if 'url' in request.data:
|
||||
feed_instance.url = request.data['url']
|
||||
if 'active' in request.data:
|
||||
feed_instance.active = request.data['active']
|
||||
if 'icon' in request.data:
|
||||
feed_instance.icon = request.FILES['icon']
|
||||
if 'keywords' in request.data:
|
||||
feed_instance.keywords = request.data['keywords']
|
||||
if 'match_all_keywords' in request.data:
|
||||
feed_instance.match_all_keywords = request.data['match_all_keywords']
|
||||
feed_instance.save()
|
||||
return JsonResponse(status=200, data={})
|
||||
|
||||
Reference in New Issue
Block a user