New settings for disabling comments and social

This commit is contained in:
Fher 2024-02-09 05:47:27 +01:00 committed by GitHub
parent 86c234f2a1
commit df99fe3e23
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 39 additions and 17 deletions

View File

@ -129,6 +129,9 @@ DMOJ_THEME_DEFAULT_ACE_THEME = {
}
DMOJ_SELECT2_THEME = 'dmoj'
DMOJ_ENABLE_COMMENTS = True
DMOJ_ENABLE_SOCIAL = True
MARKDOWN_STYLES = {}
MARKDOWN_DEFAULT_STYLE = {}

View File

@ -107,6 +107,8 @@ class PostView(TitleMixin, CommentedDetailView):
self.object.summary or self.object.content, 'blog')
context['meta_description'] = metadata[0]
context['og_image'] = self.object.og_image or metadata[1]
context['enable_comments'] = settings.DMOJ_ENABLE_COMMENTS
context['enable_social'] = settings.DMOJ_ENABLE_SOCIAL
return context

View File

@ -293,6 +293,8 @@ class ContestDetail(ContestMixin, TitleMixin, CommentedDetailView):
problem_count=Count('id'),
),
)
context['enable_comments'] = settings.DMOJ_ENABLE_COMMENTS
context['enable_social'] = settings.DMOJ_ENABLE_SOCIAL
return context

View File

@ -127,6 +127,7 @@ class ProblemSolution(SolvedProblemMixin, ProblemMixin, TitleMixin, CommentedDet
raise Http404()
context['solution'] = solution
context['has_solved_problem'] = self.object.id in self.get_completed_problems()
context['enable_comments'] = settings.DMOJ_ENABLE_COMMENTS
return context
def get_comment_page(self):
@ -201,6 +202,7 @@ class ProblemDetail(ProblemMixin, SolvedProblemMixin, CommentedDetailView):
context['description'], 'problem')
context['meta_description'] = self.object.summary or metadata[0]
context['og_image'] = self.object.og_image or metadata[1]
context['enable_comments'] = settings.DMOJ_ENABLE_COMMENTS
context['vote_perm'] = self.object.vote_permission_for_user(user)
if context['vote_perm'].can_vote():

@ -1 +1 @@
Subproject commit 399f213b192a267dd6783c0ba257392081dd37e9
Subproject commit 2681309a5ddd3482e699761488c75d9a62a626ec

View File

@ -35,12 +35,18 @@
{% endcache %}
</div>
</div>
<hr>
<span class="social">
{{ post_to_facebook(request, post, '<i class="fa fa-facebook-official"></i>') }}
{{ post_to_twitter(request, SITE_NAME + ':', post, '<i class="fa fa-twitter"></i>') }}
</span>
{% include "comments/list.html" %}
{% if enable_social %}
<hr>
<span class="social">
{{ post_to_facebook(request, contest, '<i class="fa fa-facebook-official"></i>') }}
{{ post_to_twitter(request, SITE_NAME + ':', contest, '<i class="fa fa-twitter"></i>') }}
</span>
{% endif %}
{% if enable_comments %}
{% include "comments/list.html" %}
{% endif %}
{% endblock %}
{% block bodyend %}

View File

@ -234,13 +234,17 @@
</div>
{% endif %}
<hr>
<span class="social">
{{ post_to_facebook(request, contest, '<i class="fa fa-facebook-official"></i>') }}
{{ post_to_twitter(request, SITE_NAME + ':', contest, '<i class="fa fa-twitter"></i>') }}
</span>
{% if enable_social %}
<hr>
<span class="social">
{{ post_to_facebook(request, contest, '<i class="fa fa-facebook-official"></i>') }}
{{ post_to_twitter(request, SITE_NAME + ':', contest, '<i class="fa fa-twitter"></i>') }}
</span>
{% endif %}
{% include "comments/list.html" %}
{% if enable_comments %}
{% include "comments/list.html" %}
{% endif %}
{% endblock %}
{% block description_end %}{% endblock %}

View File

@ -38,8 +38,11 @@
{% endwith %}
{{ solution.content|markdown('solution', MATH_ENGINE)|reference|str|safe }}
</div>
<hr>
{% include "comments/list.html" %}
{% if enable_comments %}
<hr>
{% include "comments/list.html" %}
{% endif %}
{% endblock %}
{% block bodyend %}

View File

@ -342,7 +342,7 @@
<p class="no-comments-message">{{ _('No clarifications have been made at this time.') }}</p>
{% endif %}
</div>
{% else %}
{% elif enable_comments %}
{% include "comments/list.html" %}
{% endif %}
{% endblock %}