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_SELECT2_THEME = 'dmoj'
DMOJ_ENABLE_COMMENTS = True
DMOJ_ENABLE_SOCIAL = True
MARKDOWN_STYLES = {} MARKDOWN_STYLES = {}
MARKDOWN_DEFAULT_STYLE = {} MARKDOWN_DEFAULT_STYLE = {}

View File

@ -107,6 +107,8 @@ class PostView(TitleMixin, CommentedDetailView):
self.object.summary or self.object.content, 'blog') self.object.summary or self.object.content, 'blog')
context['meta_description'] = metadata[0] context['meta_description'] = metadata[0]
context['og_image'] = self.object.og_image or metadata[1] 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 return context

View File

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

View File

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

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

View File

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

View File

@ -234,13 +234,17 @@
</div> </div>
{% endif %} {% endif %}
<hr> {% if enable_social %}
<span class="social"> <hr>
{{ post_to_facebook(request, contest, '<i class="fa fa-facebook-official"></i>') }} <span class="social">
{{ post_to_twitter(request, SITE_NAME + ':', contest, '<i class="fa fa-twitter"></i>') }} {{ post_to_facebook(request, contest, '<i class="fa fa-facebook-official"></i>') }}
</span> {{ 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 %} {% endblock %}
{% block description_end %}{% endblock %} {% block description_end %}{% endblock %}

View File

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

View File

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