Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
1f23b08f
Commit
1f23b08f
authored
Nov 29, 2017
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a dropdown to filter schedules by course_id, rather than forcing the use of search
parent
64dd633f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
3 deletions
+74
-3
openedx/core/djangoapps/schedules/admin.py
+59
-3
openedx/core/djangoapps/schedules/templates/dropdown_filter.html
+15
-0
No files found.
openedx/core/djangoapps/schedules/admin.py
View file @
1f23b08f
...
@@ -8,6 +8,8 @@ from django.utils.translation import ugettext_lazy as _
...
@@ -8,6 +8,8 @@ from django.utils.translation import ugettext_lazy as _
from
openedx.core.djangolib.markup
import
HTML
from
openedx.core.djangolib.markup
import
HTML
from
.
import
models
from
.
import
models
from
openedx.core.djangoapps.content.course_overviews.models
import
CourseOverview
from
opaque_keys.edx.keys
import
CourseKey
class
ScheduleExperienceAdminInline
(
admin
.
StackedInline
):
class
ScheduleExperienceAdminInline
(
admin
.
StackedInline
):
...
@@ -45,7 +47,10 @@ for (db_name, human_name) in models.ScheduleExperience.EXPERIENCES:
...
@@ -45,7 +47,10 @@ for (db_name, human_name) in models.ScheduleExperience.EXPERIENCES:
class
KnownErrorCases
(
admin
.
SimpleListFilter
):
class
KnownErrorCases
(
admin
.
SimpleListFilter
):
title
=
_
(
'KnownErrorCases'
)
"""
Filter schedules by a list of known error cases.
"""
title
=
_
(
'Known Error Case'
)
parameter_name
=
'error'
parameter_name
=
'error'
...
@@ -59,14 +64,65 @@ class KnownErrorCases(admin.SimpleListFilter):
...
@@ -59,14 +64,65 @@ class KnownErrorCases(admin.SimpleListFilter):
return
queryset
.
filter
(
start__lt
=
F
(
'enrollment__course__start'
))
return
queryset
.
filter
(
start__lt
=
F
(
'enrollment__course__start'
))
class
CourseIdFilter
(
admin
.
SimpleListFilter
):
"""
Filter schedules to by course id using a dropdown list.
"""
template
=
"dropdown_filter.html"
title
=
_
(
"Course Id"
)
parameter_name
=
"course_id"
def
__init__
(
self
,
request
,
params
,
model
,
model_admin
):
super
(
CourseIdFilter
,
self
)
.
__init__
(
request
,
params
,
model
,
model_admin
)
self
.
unused_parameters
=
params
.
copy
()
self
.
unused_parameters
.
pop
(
self
.
parameter_name
,
None
)
def
value
(
self
):
value
=
super
(
CourseIdFilter
,
self
)
.
value
()
if
value
==
"None"
or
value
is
None
:
return
None
else
:
return
CourseKey
.
from_string
(
value
)
def
lookups
(
self
,
request
,
model_admin
):
return
(
(
overview
.
id
,
unicode
(
overview
.
id
))
for
overview
in
CourseOverview
.
objects
.
all
()
.
order_by
(
'id'
)
)
def
queryset
(
self
,
request
,
queryset
):
value
=
self
.
value
()
if
value
is
None
:
return
queryset
else
:
return
queryset
.
filter
(
enrollment__course_id
=
value
)
def
choices
(
self
,
changelist
):
# pylint: disable=unused-argument
yield
{
'selected'
:
self
.
value
()
is
None
,
'value'
:
None
,
'display'
:
_
(
'All'
),
}
for
lookup
,
title
in
self
.
lookup_choices
:
yield
{
'selected'
:
self
.
value
()
==
lookup
,
'value'
:
unicode
(
lookup
),
'display'
:
title
,
}
@admin.register
(
models
.
Schedule
)
@admin.register
(
models
.
Schedule
)
class
ScheduleAdmin
(
admin
.
ModelAdmin
):
class
ScheduleAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'username'
,
'course_id'
,
'active'
,
'start'
,
'upgrade_deadline'
,
'experience_display'
)
list_display
=
(
'username'
,
'course_id'
,
'active'
,
'start'
,
'upgrade_deadline'
,
'experience_display'
)
list_display_links
=
(
'start'
,
'upgrade_deadline'
,
'experience_display'
)
list_display_links
=
(
'start'
,
'upgrade_deadline'
,
'experience_display'
)
list_filter
=
(
'experience__experience_type'
,
'active'
,
KnownErrorCases
)
list_filter
=
(
CourseIdFilter
,
'experience__experience_type'
,
'active'
,
KnownErrorCases
)
raw_id_fields
=
(
'enrollment'
,)
raw_id_fields
=
(
'enrollment'
,)
readonly_fields
=
(
'modified'
,)
readonly_fields
=
(
'modified'
,)
search_fields
=
(
'enrollment__user__username'
,
'enrollment__course__id'
,
)
search_fields
=
(
'enrollment__user__username'
,)
inlines
=
(
ScheduleExperienceAdminInline
,)
inlines
=
(
ScheduleExperienceAdminInline
,)
actions
=
[
'deactivate_schedules'
,
'activate_schedules'
]
+
experience_actions
actions
=
[
'deactivate_schedules'
,
'activate_schedules'
]
+
experience_actions
...
...
openedx/core/djangoapps/schedules/templates/dropdown_filter.html
0 → 100644
View file @
1f23b08f
{% load i18n %}
<h3>
{% blocktrans with filter_title=title %} By {{ filter_title }} {% endblocktrans %}
</h3>
<form
method=
"GET"
>
{% for name, param in spec.unused_parameters.items %}
<input
type=
"hidden"
name=
"{{ name }}"
value=
"{{ param }}"
/>
{% endfor %}
<select
name=
"{{ spec.parameter_name }}"
>
{% for choice in choices %}
<option
{%
if
choice
.
selected
%}
selected=
"selected"
{%
endif
%}
value=
"{{ choice.value }}"
>
{{ choice.display }}
</option>
{% endfor %}
</select>
<input
type=
"submit"
value=
"Filter!"
/>
</form>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment