#31 API basic implementation Token Authentication
* adds token checking to AbstractModelAPIView * adds user accessibility filtering for intervention API v1 * extends fetch_and_serialize() method to take a dict for db filtering instead of a single field and value * organizes urlnames into supporting formats like "api:v1:intervention"
This commit is contained in:
@@ -13,15 +13,16 @@ from api.views.v1.general import AbstractModelAPIViewV1
|
||||
from intervention.models import Intervention
|
||||
|
||||
|
||||
class APIInterventionView(AbstractModelAPIViewV1):
|
||||
class APIInterventionViewV1(AbstractModelAPIViewV1):
|
||||
model = Intervention
|
||||
fields_to_serialize = {
|
||||
"identifier",
|
||||
"title",
|
||||
}
|
||||
|
||||
def get(self, request: HttpRequest, identifier):
|
||||
data = self.fetch_and_serialize("identifier", identifier)
|
||||
_filter = {
|
||||
"identifier": identifier,
|
||||
"users__in": [self.user],
|
||||
"deleted__isnull": True,
|
||||
}
|
||||
data = self.fetch_and_serialize(_filter)
|
||||
return JsonResponse(data)
|
||||
|
||||
def model_to_json(self, entry: Intervention):
|
||||
|
||||
Reference in New Issue
Block a user