-
Notifications
You must be signed in to change notification settings - Fork 85
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
base: master
Are you sure you want to change the base?
Conversation
oioioi/contests/models.py
Outdated
@@ -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="" |
There was a problem hiding this comment.
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
oioioi/contests/views.py
Outdated
contests = sorted(contests, key=lambda x: x.creation_date, reverse=True) | ||
context = { | ||
'contests' : contests, | ||
'filter' : filter_value, |
There was a problem hiding this comment.
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
oioioi/contests/views.py
Outdated
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: |
There was a problem hiding this comment.
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)
There was a problem hiding this 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
Also, since we are adding searching for contest, would it be possible to paginate contests in /contests/ |
Closes #452. The filter field in the select contest page allows to search for contest by id, name or school year.