diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 49c3b87c..70385dcd 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -24,7 +24,9 @@ env: jobs: deploy: name: Run Tests - runs-on: ubuntu-20.04 + # runs-on: ubuntu-20.04 + runs-on: [self-hosted] + steps: - name: Checkout uses: actions/checkout@v2 diff --git a/apps/core/admin.py b/apps/core/admin.py index 16f680d3..d6d29883 100644 --- a/apps/core/admin.py +++ b/apps/core/admin.py @@ -32,9 +32,9 @@ def lookups(self, request, model_admin): def queryset(self, request, queryset): if self.value() == "hidden": - return queryset.exclude(hidden_at=MIN_TIME) + return queryset.exclude(hidden_at=None) if self.value() == "not_hidden": - return queryset.filter(hidden_at=MIN_TIME) + return queryset.filter(hidden_at=None) @admin.register(Board) @@ -81,6 +81,7 @@ class FAQAdmin(MetaDataModelAdmin): @admin.register(Article) class ArticleAdmin(MetaDataModelAdmin): + actions = ("restore_hidden_articles",) list_filter = ( "name_type", "is_content_sexual", @@ -91,28 +92,63 @@ class ArticleAdmin(MetaDataModelAdmin): ) list_display = ( "title", + "parent_board", + "user_nickname", + "user_email", "hit_count", - "positive_vote_count", - "negative_vote_count", - "name_type", - "is_content_sexual", - "is_content_social", "report_count", + "created_at", "hidden_at", ) - raw_id_fields = ( + raw_id_fields = ("created_by",) + search_fields = ( + "title", + "content", + "hidden_at", + "created_by__email", + ) + fields = ( + "title", + "content", "created_by", - "parent_topic", "parent_board", + "parent_topic", + "name_type", + ("is_content_sexual", "is_content_social"), + ("hit_count", "migrated_hit_count"), + ("positive_vote_count", "migrated_positive_vote_count"), + ("negative_vote_count", "migrated_negative_vote_count"), + ("comment_count", "report_count"), + "attachments", + "content_updated_at", + "commented_at", + "url", + "hidden_at", ) - search_fields = ("title", "content", "hidden_at", "created_by__email") - actions = ("restore_hidden_articles",) + readonly_fields = ( + "hit_count", + "positive_vote_count", + "negative_vote_count", + "comment_count", + "report_count", + "commented_at", + "content_updated_at", + ) + filter_horizontal = ("attachments",) @admin.action(description=gettext("Restore hidden articles")) def restore_hidden_articles(self, request, queryset): - rows_updated = queryset.update(hidden_at=MIN_TIME) + rows_updated = queryset.update(hidden_at=None) self.message_user(request, f"{rows_updated}개의 게시물(들)이 성공적으로 복구되었습니다.") + @admin.display(description="닉네임") + def user_nickname(self, obj: Article): + return obj.created_by_nickname + + @admin.display(description="이메일") + def user_email(self, obj: Article): + return obj.created_by.email + @admin.register(Comment) class CommentAdmin(MetaDataModelAdmin): @@ -138,7 +174,7 @@ class CommentAdmin(MetaDataModelAdmin): @admin.action(description=gettext("Restore hidden comments")) def restore_hidden_comments(self, request, queryset): - rows_updated = queryset.update(hidden_at=MIN_TIME) + rows_updated = queryset.update(hidden_at=None) self.message_user(request, f"{rows_updated}개의 댓글(들)이 성공적으로 복구되었습니다.") diff --git a/apps/core/migrations/0044_alter_article_url.py b/apps/core/migrations/0044_alter_article_url.py new file mode 100644 index 00000000..95f642eb --- /dev/null +++ b/apps/core/migrations/0044_alter_article_url.py @@ -0,0 +1,20 @@ +# Generated by Django 3.2.16 on 2023-03-29 20:08 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("core", "0043_board_comment_access_mask"), + ] + + operations = [ + migrations.AlterField( + model_name="article", + name="url", + field=models.URLField( + blank=True, default=None, null=True, verbose_name="포탈 링크" + ), + ), + ] diff --git a/apps/core/migrations/0045_alter_hidden_at_to_nullable.py b/apps/core/migrations/0045_alter_hidden_at_to_nullable.py new file mode 100644 index 00000000..f2dad329 --- /dev/null +++ b/apps/core/migrations/0045_alter_hidden_at_to_nullable.py @@ -0,0 +1,27 @@ +# Generated by Django 3.2.16 on 2023-03-30 22:56 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("core", "0044_alter_article_url"), + ] + + operations = [ + migrations.AlterField( + model_name="article", + name="hidden_at", + field=models.DateTimeField( + blank=True, default=None, null=True, verbose_name="숨김 시간" + ), + ), + migrations.AlterField( + model_name="comment", + name="hidden_at", + field=models.DateTimeField( + blank=True, default=None, null=True, verbose_name="숨김 시간" + ), + ), + ] diff --git a/apps/core/migrations/0046_update_hidden_at_min_time_to_null.py b/apps/core/migrations/0046_update_hidden_at_min_time_to_null.py new file mode 100644 index 00000000..0c2f294d --- /dev/null +++ b/apps/core/migrations/0046_update_hidden_at_min_time_to_null.py @@ -0,0 +1,24 @@ +# Generated by yuwol + +from django.db import migrations + +from ara.settings import MIN_TIME + + +def update_hidden_at(apps, schema_editor): + Article = apps.get_model("core", "Article") + Article.objects.filter(hidden_at=MIN_TIME).update(hidden_at=None) + + Comment = apps.get_model("core", "Comment") + Comment.objects.filter(hidden_at=MIN_TIME).update(hidden_at=None) + + +class Migration(migrations.Migration): + + dependencies = [ + ("core", "0045_alter_hidden_at_to_nullable"), + ] + + operations = [ + migrations.RunPython(update_hidden_at, atomic=True), + ] diff --git a/apps/core/models/article.py b/apps/core/models/article.py index bf7fb7d1..c80b4de3 100644 --- a/apps/core/models/article.py +++ b/apps/core/models/article.py @@ -138,11 +138,12 @@ class Meta(MetaDataModel.Meta): verbose_name="마지막 댓글 시간", ) - url = models.TextField( + url = models.URLField( null=True, + max_length=200, blank=True, default=None, - verbose_name="링크", + verbose_name="포탈 링크", ) content_updated_at = models.DateTimeField( @@ -152,7 +153,9 @@ class Meta(MetaDataModel.Meta): ) hidden_at = models.DateTimeField( - default=MIN_TIME, + null=True, + blank=True, + default=None, verbose_name="숨김 시간", ) @@ -247,7 +250,7 @@ def update_vote_status(self): self.save() def is_hidden_by_reported(self) -> bool: - return self.hidden_at != MIN_TIME + return self.hidden_at is not None @property def created_by_nickname(self): diff --git a/apps/core/models/attachment.py b/apps/core/models/attachment.py index 528108a9..63f938a6 100644 --- a/apps/core/models/attachment.py +++ b/apps/core/models/attachment.py @@ -24,3 +24,6 @@ class Meta(MetaDataModel.Meta): max_length=128, verbose_name="타입", ) + + def __str__(self) -> str: + return self.file.name diff --git a/apps/core/models/comment.py b/apps/core/models/comment.py index c6f022a3..e08cbc78 100644 --- a/apps/core/models/comment.py +++ b/apps/core/models/comment.py @@ -94,7 +94,9 @@ class Meta(MetaDataModel.Meta): verbose_name="댓글", ) hidden_at = models.DateTimeField( - default=MIN_TIME, + null=True, + blank=True, + default=None, verbose_name="숨김 시간", ) @@ -147,7 +149,7 @@ def get_parent_article(self): return self.parent_comment.parent_article def is_hidden_by_reported(self) -> bool: - return self.hidden_at != MIN_TIME + return self.hidden_at is not None def is_deleted(self) -> bool: return self.deleted_at != MIN_TIME diff --git a/ara/firebase.py b/ara/firebase.py index 055c1ade..851baf39 100644 --- a/ara/firebase.py +++ b/ara/firebase.py @@ -4,6 +4,9 @@ def fcm_notify_comment(user, title, body, open_url): + ################## Disable FCM #################### + return + targets = FCMToken.objects.filter(user=user) for i in targets: try: @@ -16,6 +19,9 @@ def fcm_notify_comment(user, title, body, open_url): def fcm_simple(FCM_token, title="Title", body="Body", open_url="/"): # This registration token comes from the client FCM SDKs. # See documentation on defining a message payload. + + ################## Disable FCM #################### + return message = messaging.Message( notification=messaging.Notification( title=title,