diff options
| author | Shyam Sunder | 2019-04-22 18:44:02 -0400 |
|---|---|---|
| committer | Shyam Sunder | 2019-04-22 20:20:19 -0400 |
| commit | 4117f63375c681a800068b56beb201699807801a (patch) | |
| tree | 446475fbd45aecf029c68664925cf38a0a87a545 /server/szurubooru/func/posts.py | |
| parent | 0121b952d1a98cfd9117833f88113ed2cd67ff65 (diff) | |
server/model/posts: Make post flags a hybrid attribute in model
This should (hopefully) fix #250 and #252
Diffstat (limited to 'server/szurubooru/func/posts.py')
| -rw-r--r-- | server/szurubooru/func/posts.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/server/szurubooru/func/posts.py b/server/szurubooru/func/posts.py index 9a5307b..532bd23 100644 --- a/server/szurubooru/func/posts.py +++ b/server/szurubooru/func/posts.py @@ -222,7 +222,7 @@ class PostSerializer(serialization.BaseSerializer): return get_post_thumbnail_url(self.post) def serialize_flags(self) -> Any: - return [x for x in self.post.flags.split(',') if x] + return self.post.flags def serialize_tags(self) -> Any: return [ @@ -356,7 +356,7 @@ def create_post( post.safety = model.Post.SAFETY_SAFE post.user = user post.creation_time = datetime.utcnow() - post.flags = '' + post.flags = [] post.type = '' post.checksum = '' @@ -477,7 +477,7 @@ def test_sound(post: model.Post, content: bytes) -> None: assert content if mime.is_video(mime.get_mime_type(content)): if images.Image(content).check_for_sound(): - flags = [x for x in post.flags.split(',') if x] + flags = post.flags if model.Post.FLAG_SOUND not in flags: flags.append(model.Post.FLAG_SOUND) update_post_flags(post, flags) @@ -637,7 +637,7 @@ def update_post_flags(post: model.Post, flags: List[str]) -> None: raise InvalidPostFlagError( 'Flag must be one of %r.' % list(FLAG_MAP.values())) target_flags.append(flag) - post.flags = ','.join(target_flags) + post.flags = target_flags def feature_post(post: model.Post, user: Optional[model.User]) -> None: |