diff --git a/dmoj/settings.py b/dmoj/settings.py index 5c1b97bda..9c8893417 100644 --- a/dmoj/settings.py +++ b/dmoj/settings.py @@ -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 = {} diff --git a/judge/views/blog.py b/judge/views/blog.py index d71d43555..df09839b9 100644 --- a/judge/views/blog.py +++ b/judge/views/blog.py @@ -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 diff --git a/judge/views/contests.py b/judge/views/contests.py index 880e128f7..25d357562 100644 --- a/judge/views/contests.py +++ b/judge/views/contests.py @@ -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 diff --git a/judge/views/problem.py b/judge/views/problem.py index 3fb2365f4..20be48b6d 100644 --- a/judge/views/problem.py +++ b/judge/views/problem.py @@ -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(): diff --git a/resources/libs b/resources/libs index 399f213b1..2681309a5 160000 --- a/resources/libs +++ b/resources/libs @@ -1 +1 @@ -Subproject commit 399f213b192a267dd6783c0ba257392081dd37e9 +Subproject commit 2681309a5ddd3482e699761488c75d9a62a626ec diff --git a/templates/blog/content.html b/templates/blog/content.html index 062e19e7c..6c5a77672 100644 --- a/templates/blog/content.html +++ b/templates/blog/content.html @@ -35,12 +35,18 @@ {% endcache %} -
- - {{ post_to_facebook(request, post, '') }} - {{ post_to_twitter(request, SITE_NAME + ':', post, '') }} - - {% include "comments/list.html" %} + + {% if enable_social %} +
+ + {{ post_to_facebook(request, contest, '') }} + {{ post_to_twitter(request, SITE_NAME + ':', contest, '') }} + + {% endif %} + + {% if enable_comments %} + {% include "comments/list.html" %} + {% endif %} {% endblock %} {% block bodyend %} diff --git a/templates/contest/contest.html b/templates/contest/contest.html index 2c8768472..141da24d7 100644 --- a/templates/contest/contest.html +++ b/templates/contest/contest.html @@ -234,13 +234,17 @@ {% endif %} -
- - {{ post_to_facebook(request, contest, '') }} - {{ post_to_twitter(request, SITE_NAME + ':', contest, '') }} - + {% if enable_social %} +
+ + {{ post_to_facebook(request, contest, '') }} + {{ post_to_twitter(request, SITE_NAME + ':', contest, '') }} + + {% endif %} - {% include "comments/list.html" %} + {% if enable_comments %} + {% include "comments/list.html" %} + {% endif %} {% endblock %} {% block description_end %}{% endblock %} diff --git a/templates/problem/editorial.html b/templates/problem/editorial.html index 820182bf6..1599cd372 100644 --- a/templates/problem/editorial.html +++ b/templates/problem/editorial.html @@ -37,9 +37,12 @@ {% endif %} {% endwith %} {{ solution.content|markdown('solution', MATH_ENGINE)|reference|str|safe }} - -
- {% include "comments/list.html" %} + + + {% if enable_comments %} +
+ {% include "comments/list.html" %} + {% endif %} {% endblock %} {% block bodyend %} diff --git a/templates/problem/problem.html b/templates/problem/problem.html index d9909d984..713571765 100644 --- a/templates/problem/problem.html +++ b/templates/problem/problem.html @@ -342,7 +342,7 @@

{{ _('No clarifications have been made at this time.') }}

{% endif %} - {% else %} + {% elif enable_comments %} {% include "comments/list.html" %} {% endif %} {% endblock %}