mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
edit post with hashtags
This commit is contained in:
parent
b635dc5ee8
commit
ea4df1d2f0
1 changed files with 17 additions and 1 deletions
|
@ -426,7 +426,7 @@ def save_post(form, post: Post, type: int):
|
|||
db.session.add(post)
|
||||
else:
|
||||
db.session.execute(text('DELETE FROM "post_tag" WHERE post_id = :post_id'), {'post_id': post.id})
|
||||
post.tags = tags_from_string(form.tags.data)
|
||||
post.tags = tags_from_string_old(form.tags.data)
|
||||
db.session.commit()
|
||||
|
||||
# Save poll choices. NB this will delete all votes whenever a poll is edited. Partially because it's easier to code but also to stop malicious alterations to polls after people have already voted
|
||||
|
@ -500,6 +500,22 @@ def tags_from_string(tags: str) -> List[dict]:
|
|||
return return_value
|
||||
|
||||
|
||||
def tags_from_string_old(tags: str) -> List[Tag]:
|
||||
return_value = []
|
||||
tags = tags.strip()
|
||||
if tags == '':
|
||||
return []
|
||||
tag_list = tags.split(',')
|
||||
tag_list = [tag.strip() for tag in tag_list]
|
||||
for tag in tag_list:
|
||||
if tag[0] == '#':
|
||||
tag = tag[1:]
|
||||
tag_to_append = find_hashtag_or_create(tag)
|
||||
if tag_to_append:
|
||||
return_value.append(tag_to_append)
|
||||
return return_value
|
||||
|
||||
|
||||
def delete_post_from_community(post_id):
|
||||
if current_app.debug:
|
||||
delete_post_from_community_task(post_id)
|
||||
|
|
Loading…
Add table
Reference in a new issue