mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
server: add tagme flag on upload, clear on edit
To easily filter through posts that haven't been retagged since initial upload.
This commit is contained in:
@ -161,7 +161,9 @@ def update_post(ctx: rest.Context, params: Dict[str, str]) -> rest.Response:
|
||||
posts.update_post_notes(post, ctx.get_param_as_list("notes"))
|
||||
if ctx.has_param("flags"):
|
||||
auth.verify_privilege(ctx.user, "posts:edit:flags")
|
||||
posts.update_post_flags(post, ctx.get_param_as_string_list("flags"))
|
||||
posts.update_post_flags(post, ctx.get_param_as_string_list("flags"), remove=True)
|
||||
else:
|
||||
posts.update_post_flags(post, post.flags, remove=True)
|
||||
if ctx.has_file("thumbnail"):
|
||||
auth.verify_privilege(ctx.user, "posts:edit:thumbnail")
|
||||
posts.update_post_thumbnail(post, ctx.get_file("thumbnail"))
|
||||
|
@ -94,6 +94,7 @@ TYPE_MAP = {
|
||||
FLAG_MAP = {
|
||||
model.Post.FLAG_LOOP: "loop",
|
||||
model.Post.FLAG_SOUND: "sound",
|
||||
model.Post.FLAG_TAGME: "tagme",
|
||||
}
|
||||
|
||||
|
||||
@ -539,6 +540,7 @@ def get_default_flags(content: bytes) -> List[str]:
|
||||
elif mime.is_video(mime.get_mime_type(content)):
|
||||
if images.Image(content).check_for_sound():
|
||||
ret.append(model.Post.FLAG_SOUND)
|
||||
ret.append(model.Post.FLAG_TAGME)
|
||||
return ret
|
||||
|
||||
|
||||
@ -783,10 +785,12 @@ def update_post_notes(post: model.Post, notes: Any) -> None:
|
||||
)
|
||||
|
||||
|
||||
def update_post_flags(post: model.Post, flags: List[str]) -> None:
|
||||
def update_post_flags(post: model.Post, flags: List[str], remove: bool = False) -> None:
|
||||
assert post
|
||||
target_flags = []
|
||||
for flag in flags:
|
||||
if remove and flag == model.Post.FLAG_TAGME:
|
||||
continue
|
||||
flag = util.flip(FLAG_MAP).get(flag, None)
|
||||
if not flag:
|
||||
raise InvalidPostFlagError(
|
||||
|
@ -197,6 +197,7 @@ class Post(Base):
|
||||
|
||||
FLAG_LOOP = "loop"
|
||||
FLAG_SOUND = "sound"
|
||||
FLAG_TAGME = "tagme"
|
||||
|
||||
# basic meta
|
||||
post_id = sa.Column("id", sa.Integer, primary_key=True)
|
||||
|
@ -47,6 +47,7 @@ def _flag_transformer(value: str) -> str:
|
||||
available_values = {
|
||||
"loop": model.Post.FLAG_LOOP,
|
||||
"sound": model.Post.FLAG_SOUND,
|
||||
"tagme": model.Post.FLAG_TAGME,
|
||||
}
|
||||
return "%" + search_util.enum_transformer(available_values, value) + "%"
|
||||
|
||||
|
Reference in New Issue
Block a user