server+client: update tag category api + fix formatting
This commit is contained in:
parent
368372e36d
commit
d2b6ecef4d
4 changed files with 8 additions and 8 deletions
|
@ -78,9 +78,9 @@ class TagCategory extends events.EventTarget {
|
||||||
|
|
||||||
let promise = this._origName
|
let promise = this._origName
|
||||||
? api.put(
|
? api.put(
|
||||||
uri.formatApiLink("tag-category", this._origName),
|
uri.formatApiLink("tag-category", this._origName),
|
||||||
detail
|
detail
|
||||||
)
|
)
|
||||||
: api.post(uri.formatApiLink("tag-categories"), detail);
|
: api.post(uri.formatApiLink("tag-categories"), detail);
|
||||||
|
|
||||||
return promise.then((response) => {
|
return promise.then((response) => {
|
||||||
|
|
|
@ -37,7 +37,8 @@ def create_tag_category(
|
||||||
auth.verify_privilege(ctx.user, "tag_categories:create")
|
auth.verify_privilege(ctx.user, "tag_categories:create")
|
||||||
name = ctx.get_param_as_string("name")
|
name = ctx.get_param_as_string("name")
|
||||||
color = ctx.get_param_as_string("color")
|
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.add(category)
|
||||||
ctx.session.flush()
|
ctx.session.flush()
|
||||||
snapshots.create(category, ctx.user)
|
snapshots.create(category, ctx.user)
|
||||||
|
|
|
@ -78,10 +78,11 @@ def serialize_category(
|
||||||
return TagCategorySerializer(category).serialize(options)
|
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()
|
category = model.TagCategory()
|
||||||
update_category_name(category, name)
|
update_category_name(category, name)
|
||||||
update_category_color(category, color)
|
update_category_color(category, color)
|
||||||
|
update_category_order(category, order)
|
||||||
if not get_all_categories():
|
if not get_all_categories():
|
||||||
category.default = True
|
category.default = True
|
||||||
return category
|
return category
|
||||||
|
|
|
@ -19,9 +19,7 @@ def upgrade():
|
||||||
"tag_category", sa.Column("order", sa.Integer, nullable=True)
|
"tag_category", sa.Column("order", sa.Integer, nullable=True)
|
||||||
)
|
)
|
||||||
op.execute(
|
op.execute(
|
||||||
sa.table("tag_category", sa.column("order"))
|
sa.table("tag_category", sa.column("order")).update().values(order=1)
|
||||||
.update()
|
|
||||||
.values(order=1)
|
|
||||||
)
|
)
|
||||||
op.alter_column("tag_category", "order", nullable=False)
|
op.alter_column("tag_category", "order", nullable=False)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue