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

Archive contest - Issue/176 #322

Merged
merged 33 commits into from
Mar 20, 2024
Merged

Archive contest - Issue/176 #322

merged 33 commits into from
Mar 20, 2024

Conversation

PPiotrek12
Copy link
Contributor

Added archive functionality to contests.
Participants cannot send submissions, ask questions, write on forum while contest is archived.

@PPiotrek12 PPiotrek12 requested a review from twalen as a code owner January 23, 2024 20:58
@geoff128 geoff128 marked this pull request as draft January 23, 2024 21:03
@twalen
Copy link
Contributor

twalen commented Jan 24, 2024

please let me know when this PR is ready for review

@geoff128 geoff128 marked this pull request as ready for review February 26, 2024 13:45
@twalen twalen changed the title Issue/176 Archive contest - Issue/176 Feb 28, 2024
@geoff128 geoff128 linked an issue Mar 12, 2024 that may be closed by this pull request
@twalen
Copy link
Contributor

twalen commented Mar 13, 2024

have you found second reviewer?

Copy link
Contributor

@NadiaHoffmann NadiaHoffmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most, if not all of the changes suggested by me are formatting or readability ones. Other than that I didn't find any bugs or issues. Nice variable naming, good formatting, some clever solutions. Maybe some comments could be added.

@@ -131,6 +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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistency in naming the variables: see line 86 in the same file

@@ -5,6 +5,11 @@

{% block main-content %}
{% for header in headers %}{{ header }}{% endfor %}
{% if contest.is_archived %}
<div class="alert alert-info">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if yellow wouldn't be a better choice for the div's color, as it would be harder to miss... But it is a personal choice after all.


@make_request_condition
@request_cached
def is_not_archived(request):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why there're two almost the same functions and "not is_archived" is used? Is that because it is used in decorators, or just for readability?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know you can negate condition in enforce_condition. Fixed!

return not is_archived(request)


def get_inline_for_contest(inline, contest):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever! A short comment with explanation could be useful though.



@enforce_condition(contest_exists & is_contest_basicadmin)
def confirm_archive_contest(request):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, clever again!

@@ -58,6 +58,9 @@ def categories(self, obj):
categories.short_description = _("Categories")

def add_category(self, obj):
if obj.contest.is_archived:
return _("Unarchive the contest to add category.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it could look a bit more clear and visible? Easier to distinguish? The text could be made bold, or underlined, or maybe in a box? Just some ideas.
Looking at the code I'm not sure it's an easy fix, so maybe the effort wouldn't be worth the outcome.

@@ -230,6 +234,10 @@ def edit_post_view(request, category_id, thread_id, post_id):
if not (post.author == request.user or is_admin):
raise PermissionDenied

# Only admins can edit posts when contest is archived.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments are always a plus!

@@ -300,7 +309,9 @@ def delete_post_view(request, category_id, thread_id, post_id):
)


@enforce_condition(not_anonymous & contest_exists & can_enter_contest)
@enforce_condition(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it in 3 lines, not in 1? Inconsistency with formatting above.

@@ -24,6 +24,7 @@ def registration_notice_fragment(request):
and request.user.is_authenticated
and not is_contest_admin(request)
and not is_participant(request)
and rc.can_register(request)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this change in code is connected with this issue - good that you fixed that, though!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, it's only indirectly related with our issue. Without this, archived contest would still have the registration alert.

@geoff128
Copy link
Contributor

Improved naming, formatting, added some comment. Changed the archived contest alert background to yellow.

apparently, you can negate condition in enforce_condition
Copy link
Contributor

@NadiaHoffmann NadiaHoffmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some minor changes, the code looks good to me. Good job!

Copy link
Contributor

@twalen twalen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@PPiotrek12 PPiotrek12 merged commit c3c399b into sio2project:master Mar 20, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an option to archive a contest
4 participants