Skip to content

Commit

Permalink
Fix inconsistent naming.
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff128 committed Mar 15, 2024
1 parent 460ea63 commit dfedf14
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions oioioi/contests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def get_submit_message(request):

@make_request_condition
@request_cached
def is_archived(request):
def is_contest_archived(request):
return (
hasattr(request, 'contest')
and request.contest.is_archived
Expand All @@ -483,7 +483,7 @@ def is_archived(request):
@make_request_condition
@request_cached
def is_not_archived(request):
return not is_archived(request)
return not is_contest_archived(request)


def get_inline_for_contest(inline, contest):
Expand Down
4 changes: 2 additions & 2 deletions oioioi/contests/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
contest_exists,
get_submission_or_error,
has_any_submittable_problem,
is_archived,
is_contest_archived,
is_contest_admin,
is_contest_basicadmin,
is_contest_observer,
Expand Down Expand Up @@ -327,7 +327,7 @@ def my_submissions_view(request):
'submissions': submissions,
'show_scores': show_scores,
'submissions_on_page': getattr(settings, 'SUBMISSIONS_ON_PAGE', 100),
'is_archived': is_archived(request),
'is_contest_archived': is_contest_archived(request),
'message': get_submissions_message(request),
'is_admin': is_contest_basicadmin(request),
},
Expand Down
26 changes: 13 additions & 13 deletions oioioi/forum/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from oioioi.base import admin
from oioioi.base.utils import make_html_link
from oioioi.contests.admin import contest_site
from oioioi.contests.utils import is_archived, is_contest_admin
from oioioi.contests.utils import is_contest_archived, is_contest_admin
from oioioi.forum.models import Ban, Category, Forum, Post, Thread

def string_concat(*strings):
Expand Down Expand Up @@ -94,15 +94,15 @@ def has_add_permission(self, request):
return False

def has_change_permission(self, request, obj=None):
if is_archived(request):
if is_contest_archived(request):
return False
return get_permission(self, request)

def has_delete_permission(self, request, obj=None):
return False

def has_view_permission(self, request, obj=None):
if is_archived(request):
if is_contest_archived(request):
return get_permission(self, request)
return super().has_view_permission(request, obj)

Expand Down Expand Up @@ -144,22 +144,22 @@ def save_model(self, request, obj, form, change):
obj.save()

def has_add_permission(self, request):
if is_archived(request):
if is_contest_archived(request):
return False
return get_permission(self, request)

def has_change_permission(self, request, obj=None):
if is_archived(request):
if is_contest_archived(request):
return False
return get_permission(self, request)

def has_delete_permission(self, request, obj=None):
if is_archived(request):
if is_contest_archived(request):
return False
return get_permission(self, request)

def has_view_permission(self, request, obj=None):
if is_archived(request):
if is_contest_archived(request):
return get_permission(self, request)
return super().has_view_permission(request, obj)

Expand Down Expand Up @@ -218,17 +218,17 @@ def has_add_permission(self, request):
return False

def has_change_permission(self, request, obj=None):
if is_archived(request):
if is_contest_archived(request):
return False
return get_permission(self, request)

def has_delete_permission(self, request, obj=None):
if is_archived(request):
if is_contest_archived(request):
return False
return get_permission(self, request)

def has_view_permission(self, request, obj=None):
if is_archived(request):
if is_contest_archived(request):
return get_permission(self, request)
return super().has_view_permission(request, obj)

Expand Down Expand Up @@ -296,17 +296,17 @@ def has_add_permission(self, request):
return False

def has_change_permission(self, request, obj=None):
if is_archived(request):
if is_contest_archived(request):
return False
return get_permission(self, request)

def has_delete_permission(self, request, obj=None):
if is_archived(request):
if is_contest_archived(request):
return False
return get_permission(self, request)

def has_view_permission(self, request, obj=None):
if is_archived(request):
if is_contest_archived(request):
return get_permission(self, request)
return super().has_view_permission(request, obj)

Expand Down
2 changes: 1 addition & 1 deletion oioioi/forum/templates/forum/category.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

{% block forum-head %}
<div class="clearfix">
{% if user.is_authenticated and can_interact_with_users and not is_archived %}
{% if user.is_authenticated and can_interact_with_users and not is_contest_archived %}
<div class="float-right">
<a role="button" class="btn btn-sm btn-outline-secondary"
href="{% url 'forum_add_thread' contest_id=contest.id category_id=category.id %}">
Expand Down
4 changes: 2 additions & 2 deletions oioioi/forum/templates/forum/thread-element-footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

{% block links_to_post %}<a href="#forum-anchor-{{ post.id }}">#{{ post.id }}</a>{% endblock %}

{% if category.reactions_enabled and not is_archived %}
{% if category.reactions_enabled and not is_contest_archived %}
<span class="post_reactions">|
{% if can_interact_with_users %}
<a href="#" data-post-url="{{ forum_post_toggle_reaction_url }}?reaction=upvote">
Expand Down Expand Up @@ -54,7 +54,7 @@
| {% trans "Last edit" %}: {{ post.last_edit_date }}
{% endif %}

{% if can_interact_with_users and post.author == user and not is_archived or is_admin %}
{% if can_interact_with_users and post.author == user and not is_contest_archived or is_admin %}
| <a href="{{ forum_post_edit_url }}">
{% trans "edit" %}
</a>
Expand Down
8 changes: 4 additions & 4 deletions oioioi/forum/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
can_admin_contest,
can_enter_contest,
contest_exists,
is_archived,
is_contest_archived,
is_contest_admin,
is_not_archived,
)
Expand Down Expand Up @@ -83,7 +83,7 @@ def forum_view(request):
'can_interact_with_users': can_interact_with_users(request),
'can_interact_with_admins': can_interact_with_admins(request),
'is_locked': request.contest.forum.is_locked(),
'is_contest_archived': is_archived(request),
'is_contest_archived': is_contest_archived(request),
'category_set': category_set,
'message': get_forum_message(request),
},
Expand Down Expand Up @@ -134,7 +134,7 @@ def category_view(request, category_id):
'msgs': get_msgs(request),
'can_interact_with_users': can_interact_with_users(request),
'can_interact_with_admins': can_interact_with_admins(request),
'is_archived': is_archived(request),
'is_contest_archived': is_contest_archived(request),
'forum_threads_per_page': getattr(settings, 'FORUM_THREADS_PER_PAGE', 30),
},
)
Expand Down Expand Up @@ -235,7 +235,7 @@ def edit_post_view(request, category_id, thread_id, post_id):
raise PermissionDenied

# Only admins can edit posts when contest is archived.
if not is_admin and is_archived(request):
if not is_admin and is_contest_archived(request):
raise PermissionDenied

if request.method == 'POST':
Expand Down
6 changes: 3 additions & 3 deletions oioioi/participants/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from oioioi.base.utils.redirect import safe_redirect
from oioioi.contests.controllers import ContestController, RegistrationController
from oioioi.contests.models import RegistrationAvailabilityConfig
from oioioi.contests.utils import can_see_personal_data, is_contest_admin, is_archived
from oioioi.contests.utils import can_see_personal_data, is_contest_admin, is_contest_archived
from oioioi.participants.models import (
OnsiteRegistration,
Participant,
Expand Down Expand Up @@ -200,7 +200,7 @@ def can_change_terms_accepted_phrase(self, request):
return True

def is_registration_open(self, request):
if is_archived(request):
if is_contest_archived(request):
return False
try:
rvc = RegistrationAvailabilityConfig.objects.get(contest=request.contest)
Expand Down Expand Up @@ -232,7 +232,7 @@ def visible_contests_query(self, request):
return Q_always_true()

def can_register(self, request):
if is_archived(request):
if is_contest_archived(request):
return False
return True

Expand Down
2 changes: 1 addition & 1 deletion oioioi/questions/templates/questions/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
</button>
{% endif %}
{% check_perm 'contests.contest_basicadmin' for contest as is_admin %}
{% if not is_archived %}
{% if not is_contest_archived %}
{% if is_admin %}
<a role="button" class="btn btn-sm btn-outline-secondary"
href="{% url 'add_contest_message' contest_id=contest.id %}">
Expand Down
4 changes: 2 additions & 2 deletions oioioi/questions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from oioioi.contests.utils import (
can_enter_contest,
contest_exists,
is_archived,
is_contest_archived,
is_contest_basicadmin,
is_not_archived,
visible_rounds,
Expand Down Expand Up @@ -211,7 +211,7 @@ def messages_view(request):
'no_email': no_email,
'onsite': request.contest.controller.is_onsite(),
'message': get_news_message(request),
'is_archived': is_archived(request),
'is_contest_archived': is_contest_archived(request),
**template_kwargs,
},
)
Expand Down

0 comments on commit dfedf14

Please sign in to comment.