From d2b6ecef4d0434aa6315e20a322991477f084ca8 Mon Sep 17 00:00:00 2001 From: neobooru <50623835+neobooru@users.noreply.github.com> Date: Wed, 23 Sep 2020 13:48:47 +0200 Subject: [PATCH] server+client: update tag category api + fix formatting --- client/js/models/tag_category.js | 6 +++--- server/szurubooru/api/tag_category_api.py | 3 ++- server/szurubooru/func/tag_categories.py | 3 ++- .../c97dc1bf184a_add_order_column_to_tag_categories.py | 4 +--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/client/js/models/tag_category.js b/client/js/models/tag_category.js index cc81f674..1641862b 100644 --- a/client/js/models/tag_category.js +++ b/client/js/models/tag_category.js @@ -78,9 +78,9 @@ class TagCategory extends events.EventTarget { let promise = this._origName ? api.put( - uri.formatApiLink("tag-category", this._origName), - detail - ) + uri.formatApiLink("tag-category", this._origName), + detail + ) : api.post(uri.formatApiLink("tag-categories"), detail); return promise.then((response) => { diff --git a/server/szurubooru/api/tag_category_api.py b/server/szurubooru/api/tag_category_api.py index 432d2d03..95d0ed8d 100644 --- a/server/szurubooru/api/tag_category_api.py +++ b/server/szurubooru/api/tag_category_api.py @@ -37,7 +37,8 @@ def create_tag_category( auth.verify_privilege(ctx.user, "tag_categories:create") name = ctx.get_param_as_string("name") color = ctx.get_param_as_string("color") - category = tag_categories.create_category(name, color) + order = ctx.get_param_as_int("order") + category = tag_categories.create_category(name, color, order) ctx.session.add(category) ctx.session.flush() snapshots.create(category, ctx.user) diff --git a/server/szurubooru/func/tag_categories.py b/server/szurubooru/func/tag_categories.py index 27c5e48e..16962d9a 100644 --- a/server/szurubooru/func/tag_categories.py +++ b/server/szurubooru/func/tag_categories.py @@ -78,10 +78,11 @@ def serialize_category( return TagCategorySerializer(category).serialize(options) -def create_category(name: str, color: str) -> model.TagCategory: +def create_category(name: str, color: str, order: int) -> model.TagCategory: category = model.TagCategory() update_category_name(category, name) update_category_color(category, color) + update_category_order(category, order) if not get_all_categories(): category.default = True return category diff --git a/server/szurubooru/migrations/versions/c97dc1bf184a_add_order_column_to_tag_categories.py b/server/szurubooru/migrations/versions/c97dc1bf184a_add_order_column_to_tag_categories.py index e878355b..c5a31249 100644 --- a/server/szurubooru/migrations/versions/c97dc1bf184a_add_order_column_to_tag_categories.py +++ b/server/szurubooru/migrations/versions/c97dc1bf184a_add_order_column_to_tag_categories.py @@ -19,9 +19,7 @@ def upgrade(): "tag_category", sa.Column("order", sa.Integer, nullable=True) ) op.execute( - sa.table("tag_category", sa.column("order")) - .update() - .values(order=1) + sa.table("tag_category", sa.column("order")).update().values(order=1) ) op.alter_column("tag_category", "order", nullable=False)