Skip to content

Commit df99fe3

Browse files
authored
New settings for disabling comments and social
1 parent 86c234f commit df99fe3

File tree

9 files changed

+39
-17
lines changed

9 files changed

+39
-17
lines changed

dmoj/settings.py

+3
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@
129129
}
130130
DMOJ_SELECT2_THEME = 'dmoj'
131131

132+
DMOJ_ENABLE_COMMENTS = True
133+
DMOJ_ENABLE_SOCIAL = True
134+
132135
MARKDOWN_STYLES = {}
133136
MARKDOWN_DEFAULT_STYLE = {}
134137

judge/views/blog.py

+2
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ def get_context_data(self, **kwargs):
107107
self.object.summary or self.object.content, 'blog')
108108
context['meta_description'] = metadata[0]
109109
context['og_image'] = self.object.og_image or metadata[1]
110+
context['enable_comments'] = settings.DMOJ_ENABLE_COMMENTS
111+
context['enable_social'] = settings.DMOJ_ENABLE_SOCIAL
110112

111113
return context
112114

judge/views/contests.py

+2
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ def get_context_data(self, **kwargs):
293293
problem_count=Count('id'),
294294
),
295295
)
296+
context['enable_comments'] = settings.DMOJ_ENABLE_COMMENTS
297+
context['enable_social'] = settings.DMOJ_ENABLE_SOCIAL
296298
return context
297299

298300

judge/views/problem.py

+2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def get_context_data(self, **kwargs):
127127
raise Http404()
128128
context['solution'] = solution
129129
context['has_solved_problem'] = self.object.id in self.get_completed_problems()
130+
context['enable_comments'] = settings.DMOJ_ENABLE_COMMENTS
130131
return context
131132

132133
def get_comment_page(self):
@@ -201,6 +202,7 @@ def get_context_data(self, **kwargs):
201202
context['description'], 'problem')
202203
context['meta_description'] = self.object.summary or metadata[0]
203204
context['og_image'] = self.object.og_image or metadata[1]
205+
context['enable_comments'] = settings.DMOJ_ENABLE_COMMENTS
204206

205207
context['vote_perm'] = self.object.vote_permission_for_user(user)
206208
if context['vote_perm'].can_vote():

templates/blog/content.html

+12-6
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,18 @@
3535
{% endcache %}
3636
</div>
3737
</div>
38-
<hr>
39-
<span class="social">
40-
{{ post_to_facebook(request, post, '<i class="fa fa-facebook-official"></i>') }}
41-
{{ post_to_twitter(request, SITE_NAME + ':', post, '<i class="fa fa-twitter"></i>') }}
42-
</span>
43-
{% include "comments/list.html" %}
38+
39+
{% if enable_social %}
40+
<hr>
41+
<span class="social">
42+
{{ post_to_facebook(request, contest, '<i class="fa fa-facebook-official"></i>') }}
43+
{{ post_to_twitter(request, SITE_NAME + ':', contest, '<i class="fa fa-twitter"></i>') }}
44+
</span>
45+
{% endif %}
46+
47+
{% if enable_comments %}
48+
{% include "comments/list.html" %}
49+
{% endif %}
4450
{% endblock %}
4551

4652
{% block bodyend %}

templates/contest/contest.html

+10-6
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,17 @@ <h2 style="margin-bottom: 0.2em"><i class="fa fa-fw fa-question-circle"></i>{{ _
234234
</div>
235235
{% endif %}
236236

237-
<hr>
238-
<span class="social">
239-
{{ post_to_facebook(request, contest, '<i class="fa fa-facebook-official"></i>') }}
240-
{{ post_to_twitter(request, SITE_NAME + ':', contest, '<i class="fa fa-twitter"></i>') }}
241-
</span>
237+
{% if enable_social %}
238+
<hr>
239+
<span class="social">
240+
{{ post_to_facebook(request, contest, '<i class="fa fa-facebook-official"></i>') }}
241+
{{ post_to_twitter(request, SITE_NAME + ':', contest, '<i class="fa fa-twitter"></i>') }}
242+
</span>
243+
{% endif %}
242244

243-
{% include "comments/list.html" %}
245+
{% if enable_comments %}
246+
{% include "comments/list.html" %}
247+
{% endif %}
244248
{% endblock %}
245249

246250
{% block description_end %}{% endblock %}

templates/problem/editorial.html

+6-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@
3737
{% endif %}
3838
{% endwith %}
3939
{{ solution.content|markdown('solution', MATH_ENGINE)|reference|str|safe }}
40-
</div>
41-
<hr>
42-
{% include "comments/list.html" %}
40+
</div>
41+
42+
{% if enable_comments %}
43+
<hr>
44+
{% include "comments/list.html" %}
45+
{% endif %}
4346
{% endblock %}
4447

4548
{% block bodyend %}

templates/problem/problem.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ <h2><i class="fa fa-question-circle"></i> {{ _('Clarifications') }}</h2>
342342
<p class="no-comments-message">{{ _('No clarifications have been made at this time.') }}</p>
343343
{% endif %}
344344
</div>
345-
{% else %}
345+
{% elif enable_comments %}
346346
{% include "comments/list.html" %}
347347
{% endif %}
348348
{% endblock %}

0 commit comments

Comments
 (0)