sachet/server/views_common.py: split off POST from ModelAPI
Now it's in ModelListAPI
This commit is contained in:
parent
3473156417
commit
bfd0cd8fdf
@ -3,7 +3,7 @@ import io
|
||||
from flask import Blueprint, request, jsonify, send_file
|
||||
from flask.views import MethodView
|
||||
from sachet.server.models import Share, Permissions
|
||||
from sachet.server.views_common import ModelAPI, auth_required
|
||||
from sachet.server.views_common import ModelAPI, ModelListAPI, auth_required
|
||||
from sachet.server import storage, db
|
||||
|
||||
files_blueprint = Blueprint("files_blueprint", __name__)
|
||||
@ -38,7 +38,7 @@ files_blueprint.add_url_rule(
|
||||
)
|
||||
|
||||
|
||||
class FilesAPI(ModelAPI):
|
||||
class FilesAPI(ModelListAPI):
|
||||
@auth_required(required_permissions=(Permissions.CREATE,))
|
||||
def post(self, auth_user=None):
|
||||
data = request.get_json()
|
||||
|
@ -94,7 +94,7 @@ def patch(orig, diff):
|
||||
|
||||
|
||||
class ModelAPI(MethodView):
|
||||
"""Generic REST API for interacting with models."""
|
||||
"""Generic REST API for the representation of a model instance."""
|
||||
|
||||
def get(self, model):
|
||||
if not model:
|
||||
@ -190,6 +190,10 @@ class ModelAPI(MethodView):
|
||||
|
||||
return jsonify({"status": "success"})
|
||||
|
||||
|
||||
class ModelListAPI(MethodView):
|
||||
"""Generic API for representing all instances of a given model."""
|
||||
|
||||
def post(self, ModelClass, data={}):
|
||||
"""Create new instance of a class.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user