Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New settings for disable comments and social #2304

Merged
merged 10 commits into from
Feb 9, 2024
3 changes: 3 additions & 0 deletions dmoj/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@
FONTAWESOME_CSS = '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css'
DMOJ_CANONICAL = ''

DMOJ_DISABLE_COMMENTS = False
FherStk marked this conversation as resolved.
Show resolved Hide resolved
DMOJ_DISABLE_SOCIAL = False

# Application definition

INSTALLED_APPS = ()
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['disable_comments'] = settings.DMOJ_DISABLE_COMMENTS
context['disable_social'] = settings.DMOJ_DISABLE_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['disable_comments'] = settings.DMOJ_DISABLE_COMMENTS
context['disable_social'] = settings.DMOJ_DISABLE_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['disable_comments'] = settings.DMOJ_DISABLE_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['disable_comments'] = settings.DMOJ_DISABLE_COMMENTS

context['vote_perm'] = self.object.vote_permission_for_user(user)
if context['vote_perm'].can_vote():
Expand Down
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 not disable_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 not disable_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 not disable_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 not disable_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 not disable_comments %}
Xyene marked this conversation as resolved.
Show resolved Hide resolved
<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 not disable_comments %}
{% include "comments/list.html" %}
{% endif %}
{% endblock %}
Expand Down
Loading