Skip to content

Commit

Permalink
New settings for disabling comments and social
Browse files Browse the repository at this point in the history
  • Loading branch information
FherStk authored Feb 9, 2024
1 parent 86c234f commit df99fe3
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 17 deletions.
3 changes: 3 additions & 0 deletions dmoj/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@
}
DMOJ_SELECT2_THEME = 'dmoj'

DMOJ_ENABLE_COMMENTS = True
DMOJ_ENABLE_SOCIAL = True

MARKDOWN_STYLES = {}
MARKDOWN_DEFAULT_STYLE = {}

Expand Down
2 changes: 2 additions & 0 deletions judge/views/blog.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def get_context_data(self, **kwargs):
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

Expand Down
2 changes: 2 additions & 0 deletions judge/views/contests.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ def get_context_data(self, **kwargs):
problem_count=Count('id'),
),
)
context['enable_comments'] = settings.DMOJ_ENABLE_COMMENTS
context['enable_social'] = settings.DMOJ_ENABLE_SOCIAL
return context


Expand Down
2 changes: 2 additions & 0 deletions judge/views/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def get_context_data(self, **kwargs):
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):
Expand Down Expand Up @@ -201,6 +202,7 @@ def get_context_data(self, **kwargs):
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():
Expand Down
2 changes: 1 addition & 1 deletion resources/libs
18 changes: 12 additions & 6 deletions templates/blog/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
16 changes: 10 additions & 6 deletions templates/contest/contest.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,17 @@ <h2 style="margin-bottom: 0.2em"><i class="fa fa-fw fa-question-circle"></i>{{ _
</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 %}
Expand Down
9 changes: 6 additions & 3 deletions templates/problem/editorial.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@
{% endif %}
{% endwith %}
{{ solution.content|markdown('solution', MATH_ENGINE)|reference|str|safe }}
</div>
<hr>
{% include "comments/list.html" %}
</div>

{% if enable_comments %}
<hr>
{% include "comments/list.html" %}
{% endif %}
{% endblock %}

{% block bodyend %}
Expand Down
2 changes: 1 addition & 1 deletion templates/problem/problem.html
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ <h2><i class="fa fa-question-circle"></i> {{ _('Clarifications') }}</h2>
<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 %}
Expand Down

0 comments on commit df99fe3

Please sign in to comment.