diff --git a/dmoj/urls.py b/dmoj/urls.py index e7c62cf..bece26c 100644 --- a/dmoj/urls.py +++ b/dmoj/urls.py @@ -84,6 +84,7 @@ from judge.views.select2 import ( TicketUserSelect2View, UserSearchSelect2View, UserSelect2View, + ProblemAuthorSearchSelect2View, ) admin.autodiscover() @@ -887,6 +888,11 @@ urlpatterns = [ AssigneeSelect2View.as_view(), name="ticket_assignee_select2_ajax", ), + url( + r"^problem_authors$", + ProblemAuthorSearchSelect2View.as_view(), + name="problem_authors_select2_ajax", + ), ] ), ), diff --git a/judge/views/problem.py b/judge/views/problem.py index 7ba04ab..d86909a 100644 --- a/judge/views/problem.py +++ b/judge/views/problem.py @@ -664,12 +664,6 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView if self.request.profile: context["organizations"] = self.request.profile.organizations.all() - all_authors_ids = Problem.objects.values_list("authors", flat=True) - context["all_authors"] = ( - Profile.objects.filter(id__in=all_authors_ids) - .select_related("user") - .values("id", "user__username") - ) context["category"] = self.category context["categories"] = ProblemGroup.objects.all() if self.show_types: @@ -677,7 +671,7 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView context["problem_types"] = ProblemType.objects.all() context["has_fts"] = settings.ENABLE_FTS context["org_query"] = self.org_query - context["author_query"] = self.author_query + context["author_query"] = Profile.objects.filter(id__in=self.author_query) context["search_query"] = self.search_query context["completed_problem_ids"] = self.get_completed_problems() context["attempted_problems"] = self.get_attempted_problems() diff --git a/judge/views/select2.py b/judge/views/select2.py index 187d68a..1aea075 100644 --- a/judge/views/select2.py +++ b/judge/views/select2.py @@ -200,3 +200,17 @@ class ChatUserSearchSelect2View(UserSearchSelect2View): ), "display_rank": display_rank, } + + +class ProblemAuthorSearchSelect2View(UserSearchSelect2View): + def get_queryset(self): + return Profile.objects.filter( + authored_problems__isnull=False, user__username__icontains=self.term + ).distinct() + + def get_json_result_from_object(self, user_tuple): + pk, username, email, display_rank, profile_image = user_tuple + return { + "text": username, + "id": pk, + } diff --git a/resources/base.scss b/resources/base.scss index 501d5a1..aee3a97 100644 --- a/resources/base.scss +++ b/resources/base.scss @@ -739,11 +739,6 @@ math { z-index: 1000 !important; } -select { - visibility: hidden; - max-height: 0; -} - // @media (max-width: 500px) { // #notification { // margin-top: 0.6em; diff --git a/resources/problem.scss b/resources/problem.scss index d10c50e..ff2d615 100644 --- a/resources/problem.scss +++ b/resources/problem.scss @@ -324,10 +324,6 @@ ul.problem-list { padding: 4px 10px; } -#category, #types { - visibility: hidden; -} - #filter-form .form-label { margin-top: 0.5em; font-style: italic; diff --git a/templates/chat/chat_js.html b/templates/chat/chat_js.html index e259b87..fee3984 100644 --- a/templates/chat/chat_js.html +++ b/templates/chat/chat_js.html @@ -522,7 +522,9 @@ $('#search-handle').select2({ placeholder: ' {{ _('Search by handle...') }}', ajax: { - url: '{{ url('chat_user_search_select2_ajax') }}' + url: '{{ url('chat_user_search_select2_ajax') }}', + delay: 250, + cache: true, }, minimumInputLength: 1, escapeMarkup: function (markup) { diff --git a/templates/contest/media-js.html b/templates/contest/media-js.html index 9016b7d..5a72e4c 100644 --- a/templates/contest/media-js.html +++ b/templates/contest/media-js.html @@ -161,7 +161,9 @@ $('#search-contest').select2({ placeholder: placeholder, ajax: { - url: '{{ url('contest_user_search_select2_ajax', contest.key) }}' + url: '{{ url('contest_user_search_select2_ajax', contest.key) }}', + cache: true, + delay: 250, }, minimumInputLength: 1, escapeMarkup: function (markup) { diff --git a/templates/contest/ranking.html b/templates/contest/ranking.html index baea8db..237cd5b 100644 --- a/templates/contest/ranking.html +++ b/templates/contest/ranking.html @@ -128,12 +128,14 @@ {% block before_table %} {% include "contest/contest-datetime.html" %} -
- {% if page_type == 'participation' %} - {% if contest.can_see_full_scoreboard(request.user) %} + {% if page_type == 'participation' %} + {% if contest.can_see_full_scoreboard(request.user) %} +
- {% endif %} +
{% endif %} + {% endif %} +
diff --git a/templates/problem/list-base.html b/templates/problem/list-base.html index 181a48a..3a747b7 100644 --- a/templates/problem/list-base.html +++ b/templates/problem/list-base.html @@ -90,7 +90,15 @@ .css({'visibility': 'visible'}); $('#search-org').select2({multiple: 1, placeholder: '{{ _('Groups') }}...'}) .css({'visibility': 'visible'}); - $('#search-author').select2({multiple: 1, placeholder: '{{ _('Authors') }}...'}) + $('#search-author').select2({ + multiple: 1, + placeholder: '{{ _('Authors') }}...', + ajax: { + url: '{{ url('problem_authors_select2_ajax') }}', + delay: 250, + cache: true, + } + }) .css({'visibility': 'visible'}); // This is incredibly nasty to do but it's needed because otherwise the select2 steals the focus diff --git a/templates/problem/search-form.html b/templates/problem/search-form.html index 53c9e84..97a3c35 100644 --- a/templates/problem/search-form.html +++ b/templates/problem/search-form.html @@ -49,9 +49,9 @@
diff --git a/templates/submission/list.html b/templates/submission/list.html index 53e63ce..b4ab3a8 100644 --- a/templates/submission/list.html +++ b/templates/submission/list.html @@ -275,10 +275,6 @@ col.sub-info, td.sub-info { width: 78% } - - #status, #language { - visibility: hidden; - } {% endif %} diff --git a/templates/ticket/list.html b/templates/ticket/list.html index cd07280..16d1e8e 100644 --- a/templates/ticket/list.html +++ b/templates/ticket/list.html @@ -193,6 +193,8 @@ } }; }, + delay: 250, + cache: true, }, }; diff --git a/templates/user/base-users-js.html b/templates/user/base-users-js.html index d162f24..e84685a 100644 --- a/templates/user/base-users-js.html +++ b/templates/user/base-users-js.html @@ -9,7 +9,9 @@ $('#search-handle').select2({ placeholder: '{{ _('Search by handle...') }}', ajax: { - url: '{{ url('user_search_select2_ajax') }}' + url: '{{ url('user_search_select2_ajax') }}', + delay: 250, + cache: true, }, minimumInputLength: 1, escapeMarkup: function (markup) {