/files/: internally restructure API names

This commit is contained in:
dogeystamp 2023-04-23 22:03:41 -04:00
parent 03a51ddbc4
commit 3473156417
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
2 changed files with 5 additions and 7 deletions

View File

@ -9,9 +9,7 @@ from sachet.server import storage, db
files_blueprint = Blueprint("files_blueprint", __name__) files_blueprint = Blueprint("files_blueprint", __name__)
class FilesAPI(ModelAPI): class FilesMetadataAPI(ModelAPI):
"""Files metadata API."""
@auth_required(required_permissions=(Permissions.READ,)) @auth_required(required_permissions=(Permissions.READ,))
def get(self, share_id, auth_user=None): def get(self, share_id, auth_user=None):
share = Share.query.filter_by(share_id=share_id).first() share = Share.query.filter_by(share_id=share_id).first()
@ -35,12 +33,12 @@ class FilesAPI(ModelAPI):
files_blueprint.add_url_rule( files_blueprint.add_url_rule(
"/files/<share_id>", "/files/<share_id>",
view_func=FilesAPI.as_view("files_api"), view_func=FilesMetadataAPI.as_view("files_metadata_api"),
methods=["PUT", "PATCH", "GET", "DELETE"], methods=["PUT", "PATCH", "GET", "DELETE"],
) )
class FileCreationAPI(ModelAPI): class FilesAPI(ModelAPI):
@auth_required(required_permissions=(Permissions.CREATE,)) @auth_required(required_permissions=(Permissions.CREATE,))
def post(self, auth_user=None): def post(self, auth_user=None):
data = request.get_json() data = request.get_json()
@ -50,7 +48,7 @@ class FileCreationAPI(ModelAPI):
files_blueprint.add_url_rule( files_blueprint.add_url_rule(
"/files", "/files",
view_func=FileCreationAPI.as_view("files_creation_api"), view_func=FilesAPI.as_view("files_api"),
methods=["POST"], methods=["POST"],
) )

View File

@ -238,7 +238,7 @@ class Share(db.Model):
self.owner = User.query.filter_by(username=owner_name).first() self.owner = User.query.filter_by(username=owner_name).first()
self.owner_name = self.owner.username self.owner_name = self.owner.username
self.share_id = uuid.uuid4() self.share_id = uuid.uuid4()
self.url = url_for("files_blueprint.files_api", share_id=self.share_id) self.url = url_for("files_blueprint.files_metadata_api", share_id=self.share_id)
self.create_date = datetime.datetime.now() self.create_date = datetime.datetime.now()
if file_name: if file_name:
self.file_name = file_name self.file_name = file_name