Modify some select2 box
This commit is contained in:
parent
847e8b6660
commit
695fa85b19
13 changed files with 50 additions and 31 deletions
|
@ -84,6 +84,7 @@ from judge.views.select2 import (
|
||||||
TicketUserSelect2View,
|
TicketUserSelect2View,
|
||||||
UserSearchSelect2View,
|
UserSearchSelect2View,
|
||||||
UserSelect2View,
|
UserSelect2View,
|
||||||
|
ProblemAuthorSearchSelect2View,
|
||||||
)
|
)
|
||||||
|
|
||||||
admin.autodiscover()
|
admin.autodiscover()
|
||||||
|
@ -887,6 +888,11 @@ urlpatterns = [
|
||||||
AssigneeSelect2View.as_view(),
|
AssigneeSelect2View.as_view(),
|
||||||
name="ticket_assignee_select2_ajax",
|
name="ticket_assignee_select2_ajax",
|
||||||
),
|
),
|
||||||
|
url(
|
||||||
|
r"^problem_authors$",
|
||||||
|
ProblemAuthorSearchSelect2View.as_view(),
|
||||||
|
name="problem_authors_select2_ajax",
|
||||||
|
),
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -664,12 +664,6 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView
|
||||||
|
|
||||||
if self.request.profile:
|
if self.request.profile:
|
||||||
context["organizations"] = self.request.profile.organizations.all()
|
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["category"] = self.category
|
||||||
context["categories"] = ProblemGroup.objects.all()
|
context["categories"] = ProblemGroup.objects.all()
|
||||||
if self.show_types:
|
if self.show_types:
|
||||||
|
@ -677,7 +671,7 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView
|
||||||
context["problem_types"] = ProblemType.objects.all()
|
context["problem_types"] = ProblemType.objects.all()
|
||||||
context["has_fts"] = settings.ENABLE_FTS
|
context["has_fts"] = settings.ENABLE_FTS
|
||||||
context["org_query"] = self.org_query
|
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["search_query"] = self.search_query
|
||||||
context["completed_problem_ids"] = self.get_completed_problems()
|
context["completed_problem_ids"] = self.get_completed_problems()
|
||||||
context["attempted_problems"] = self.get_attempted_problems()
|
context["attempted_problems"] = self.get_attempted_problems()
|
||||||
|
|
|
@ -200,3 +200,17 @@ class ChatUserSearchSelect2View(UserSearchSelect2View):
|
||||||
),
|
),
|
||||||
"display_rank": display_rank,
|
"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,
|
||||||
|
}
|
||||||
|
|
|
@ -739,11 +739,6 @@ math {
|
||||||
z-index: 1000 !important;
|
z-index: 1000 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
|
||||||
visibility: hidden;
|
|
||||||
max-height: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @media (max-width: 500px) {
|
// @media (max-width: 500px) {
|
||||||
// #notification {
|
// #notification {
|
||||||
// margin-top: 0.6em;
|
// margin-top: 0.6em;
|
||||||
|
|
|
@ -324,10 +324,6 @@ ul.problem-list {
|
||||||
padding: 4px 10px;
|
padding: 4px 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#category, #types {
|
|
||||||
visibility: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
#filter-form .form-label {
|
#filter-form .form-label {
|
||||||
margin-top: 0.5em;
|
margin-top: 0.5em;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
|
|
|
@ -522,7 +522,9 @@
|
||||||
$('#search-handle').select2({
|
$('#search-handle').select2({
|
||||||
placeholder: '<i class="fa fa-search"></i> {{ _('Search by handle...') }}',
|
placeholder: '<i class="fa fa-search"></i> {{ _('Search by handle...') }}',
|
||||||
ajax: {
|
ajax: {
|
||||||
url: '{{ url('chat_user_search_select2_ajax') }}'
|
url: '{{ url('chat_user_search_select2_ajax') }}',
|
||||||
|
delay: 250,
|
||||||
|
cache: true,
|
||||||
},
|
},
|
||||||
minimumInputLength: 1,
|
minimumInputLength: 1,
|
||||||
escapeMarkup: function (markup) {
|
escapeMarkup: function (markup) {
|
||||||
|
|
|
@ -161,7 +161,9 @@
|
||||||
$('#search-contest').select2({
|
$('#search-contest').select2({
|
||||||
placeholder: placeholder,
|
placeholder: placeholder,
|
||||||
ajax: {
|
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,
|
minimumInputLength: 1,
|
||||||
escapeMarkup: function (markup) {
|
escapeMarkup: function (markup) {
|
||||||
|
|
|
@ -128,12 +128,14 @@
|
||||||
|
|
||||||
{% block before_table %}
|
{% block before_table %}
|
||||||
{% include "contest/contest-datetime.html" %}
|
{% include "contest/contest-datetime.html" %}
|
||||||
<div style="margin-bottom: 0.5em">
|
{% if page_type == 'participation' %}
|
||||||
{% if page_type == 'participation' %}
|
{% if contest.can_see_full_scoreboard(request.user) %}
|
||||||
{% if contest.can_see_full_scoreboard(request.user) %}
|
<div style="margin-bottom: 0.5em">
|
||||||
<input id="search-contest" type="text" placeholder="{{ _('View user participation') }}">
|
<input id="search-contest" type="text" placeholder="{{ _('View user participation') }}">
|
||||||
{% endif %}
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
<div style="margin-bottom: 0.5em">
|
||||||
<input id="show-schools-checkbox" type="checkbox" style="vertical-align: bottom">
|
<input id="show-schools-checkbox" type="checkbox" style="vertical-align: bottom">
|
||||||
<label for="show-schools-checkbox" style="vertical-align: bottom; margin-right: 1em;">{{ _('Show schools') }}</label>
|
<label for="show-schools-checkbox" style="vertical-align: bottom; margin-right: 1em;">{{ _('Show schools') }}</label>
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,15 @@
|
||||||
.css({'visibility': 'visible'});
|
.css({'visibility': 'visible'});
|
||||||
$('#search-org').select2({multiple: 1, placeholder: '{{ _('Groups') }}...'})
|
$('#search-org').select2({multiple: 1, placeholder: '{{ _('Groups') }}...'})
|
||||||
.css({'visibility': 'visible'});
|
.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'});
|
.css({'visibility': 'visible'});
|
||||||
|
|
||||||
// This is incredibly nasty to do but it's needed because otherwise the select2 steals the focus
|
// This is incredibly nasty to do but it's needed because otherwise the select2 steals the focus
|
||||||
|
|
|
@ -49,9 +49,9 @@
|
||||||
<div class="filter-form-group">
|
<div class="filter-form-group">
|
||||||
<label class="bold-text margin-label" for="type"><i class="non-italics">{{ _('Author') }}</i></label>
|
<label class="bold-text margin-label" for="type"><i class="non-italics">{{ _('Author') }}</i></label>
|
||||||
<select id="search-author" name="authors" multiple>
|
<select id="search-author" name="authors" multiple>
|
||||||
{% for author in all_authors %}
|
{% for author in author_query %}
|
||||||
<option value="{{ author.id }}"{% if author.id in author_query %} selected{% endif %}>
|
<option value="{{ author.id }}" selected>
|
||||||
{{ author.user__username }}
|
{{ author.username }}
|
||||||
</option>
|
</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -275,10 +275,6 @@
|
||||||
col.sub-info, td.sub-info {
|
col.sub-info, td.sub-info {
|
||||||
width: 78%
|
width: 78%
|
||||||
}
|
}
|
||||||
|
|
||||||
#status, #language {
|
|
||||||
visibility: hidden;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
|
@ -193,6 +193,8 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
delay: 250,
|
||||||
|
cache: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,9 @@
|
||||||
$('#search-handle').select2({
|
$('#search-handle').select2({
|
||||||
placeholder: '{{ _('Search by handle...') }}',
|
placeholder: '{{ _('Search by handle...') }}',
|
||||||
ajax: {
|
ajax: {
|
||||||
url: '{{ url('user_search_select2_ajax') }}'
|
url: '{{ url('user_search_select2_ajax') }}',
|
||||||
|
delay: 250,
|
||||||
|
cache: true,
|
||||||
},
|
},
|
||||||
minimumInputLength: 1,
|
minimumInputLength: 1,
|
||||||
escapeMarkup: function (markup) {
|
escapeMarkup: function (markup) {
|
||||||
|
|
Loading…
Reference in a new issue