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

Add school year field to contest model and filter for contest selection #491

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

steewoo
Copy link

@steewoo steewoo commented Mar 20, 2025

Closes #452. The filter field in the select contest page allows to search for contest by id, name or school year.

@steewoo steewoo requested a review from MasloMaslane as a code owner March 20, 2025 20:32
@@ -108,6 +108,9 @@ class Contest(models.Model):
verbose_name=_("is archived"),
default=False
)
school_year = models.CharField(
max_length=255, verbose_name=_("school year"), default=""
Copy link
Contributor

Choose a reason for hiding this comment

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

255 seems to be an overkill

contests = sorted(contests, key=lambda x: x.creation_date, reverse=True)
context = {
'contests' : contests,
'filter' : filter_value,
Copy link
Contributor

Choose a reason for hiding this comment

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

the filtering should be handled by the server

contests = sorted(contests, key=lambda x: x.creation_date, reverse=True)
filtered_contests = []
for contest in contests:
if contest.school_year == filter_value or contest.name.find(filter_value) != -1 or contest.id.find(filter_value) != -1:
Copy link
Member

Choose a reason for hiding this comment

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

Couldn’t this be done in Django ORM? This would probably require adding a function visible_contests_queryset (i don’t think there is one yet)

Copy link
Member

@MasloMaslane MasloMaslane left a comment

Choose a reason for hiding this comment

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

Could you please squash migrations

@MasloMaslane
Copy link
Member

Also, since we are adding searching for contest, would it be possible to paginate contests in /contests/

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 "school year" as a field in the contest model
3 participants