Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
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
course-discovery
Commits
ff0ac78a
Commit
ff0ac78a
authored
Mar 10, 2017
by
Waheed Ahmed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed search/add staff.
ECOM-7416
parent
54bedfae
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
68 additions
and
40 deletions
+68
-40
course_discovery/apps/course_metadata/lookups.py
+13
-13
course_discovery/apps/course_metadata/tests/test_lookups.py
+28
-0
course_discovery/apps/publisher/forms.py
+1
-1
course_discovery/apps/publisher/views.py
+2
-0
course_discovery/conf/locale/en/LC_MESSAGES/django.mo
+0
-0
course_discovery/conf/locale/en/LC_MESSAGES/django.po
+4
-8
course_discovery/conf/locale/en/LC_MESSAGES/djangojs.mo
+0
-0
course_discovery/conf/locale/en/LC_MESSAGES/djangojs.po
+2
-2
course_discovery/conf/locale/eo/LC_MESSAGES/django.mo
+0
-0
course_discovery/conf/locale/eo/LC_MESSAGES/django.po
+5
-9
course_discovery/conf/locale/eo/LC_MESSAGES/djangojs.mo
+0
-0
course_discovery/conf/locale/eo/LC_MESSAGES/djangojs.po
+2
-2
course_discovery/templates/publisher/_add_instructor_popup.html
+11
-5
No files found.
course_discovery/apps/course_metadata/lookups.py
View file @
ff0ac78a
import
uuid
from
dal
import
autocomplete
from
django.contrib.auth.mixins
import
LoginRequiredMixin
from
django.db.models
import
Q
from
django.template.loader
import
render_to_string
...
...
@@ -55,20 +56,19 @@ class VideoAutocomplete(autocomplete.Select2QuerySetView):
return
[]
class
PersonAutocomplete
(
autocomplete
.
Select2QuerySetView
):
class
PersonAutocomplete
(
LoginRequiredMixin
,
autocomplete
.
Select2QuerySetView
):
def
get_queryset
(
self
):
if
self
.
request
.
user
.
is_authenticated
()
and
self
.
request
.
user
.
is_staff
:
queryset
=
Person
.
objects
.
all
()
if
self
.
q
:
qs
=
queryset
.
filter
(
Q
(
given_name__icontains
=
self
.
q
)
|
Q
(
family_name__icontains
=
self
.
q
))
if
not
qs
:
try
:
q_uuid
=
uuid
.
UUID
(
self
.
q
)
.
hex
qs
=
queryset
.
filter
(
uuid
=
q_uuid
)
except
ValueError
:
pass
return
qs
queryset
=
Person
.
objects
.
all
()
if
self
.
q
:
qs
=
queryset
.
filter
(
Q
(
given_name__icontains
=
self
.
q
)
|
Q
(
family_name__icontains
=
self
.
q
))
if
not
qs
:
try
:
q_uuid
=
uuid
.
UUID
(
self
.
q
)
.
hex
qs
=
queryset
.
filter
(
uuid
=
q_uuid
)
except
ValueError
:
pass
return
qs
return
[]
...
...
course_discovery/apps/course_metadata/tests/test_lookups.py
View file @
ff0ac78a
import
json
from
urllib.parse
import
quote
import
ddt
from
django.core.urlresolvers
import
reverse
...
...
@@ -204,3 +205,30 @@ class AutocompleteTests(TestCase):
reverse
(
'admin_metadata:person-autocomplete'
)
+
'?q={q}'
.
format
(
q
=
uuid
)
)
self
.
_assert_response
(
response
,
0
)
def
test_instructor_autocomplete_without_staff_user
(
self
):
""" Verify instructor autocomplete returns the data if user is not staff. """
non_staff_user
=
UserFactory
()
self
.
client
.
logout
()
self
.
client
.
login
(
username
=
non_staff_user
.
username
,
password
=
USER_PASSWORD
)
response
=
self
.
client
.
get
(
reverse
(
'admin_metadata:person-autocomplete'
)
+
'?q={q}'
.
format
(
q
=
'ins'
)
)
self
.
_assert_response
(
response
,
2
)
def
test_instructor_autocomplete_without_login
(
self
):
""" Verify instructor autocomplete returns the zero record if user is not logged in. """
self
.
client
.
logout
()
person_autocomplete_url
=
reverse
(
'admin_metadata:person-autocomplete'
)
+
'?q={q}'
.
format
(
q
=
self
.
instructors
[
0
]
.
uuid
)
response
=
self
.
client
.
get
(
person_autocomplete_url
)
self
.
assertRedirects
(
response
,
expected_url
=
'{url}?next={next}'
.
format
(
url
=
reverse
(
'login'
),
next
=
quote
(
person_autocomplete_url
)),
status_code
=
302
,
target_status_code
=
302
)
course_discovery/apps/publisher/forms.py
View file @
ff0ac78a
...
...
@@ -187,7 +187,7 @@ class CustomCourseRunForm(CourseRunForm):
start
=
forms
.
DateTimeField
(
label
=
_
(
'Course Start Date'
),
required
=
True
)
end
=
forms
.
DateTimeField
(
label
=
_
(
'Course End Date'
),
required
=
True
)
staff
=
PersonModelMultipleChoice
(
label
=
_
(
'
i
nstructor'
),
label
=
_
(
'
I
nstructor'
),
queryset
=
Person
.
objects
.
all
(),
widget
=
autocomplete
.
ModelSelect2Multiple
(
url
=
'admin_metadata:person-autocomplete'
,
...
...
course_discovery/apps/publisher/views.py
View file @
ff0ac78a
...
...
@@ -537,6 +537,7 @@ class CourseRunEditView(mixins.LoginRequiredMixin, mixins.PublisherPermissionMix
course_run
=
context
.
get
(
'course_run'
)
course
=
course_run
.
course
context
[
'course_form'
]
=
self
.
course_form
(
user
=
request
.
user
,
instance
=
course
,
initial
=
context
.
get
(
'initial'
),
organization
=
context
.
get
(
'organization'
),
...
...
@@ -568,6 +569,7 @@ class CourseRunEditView(mixins.LoginRequiredMixin, mixins.PublisherPermissionMix
course_form
=
self
.
course_form
(
request
.
POST
,
request
.
FILES
,
user
=
request
.
user
,
instance
=
course_run
.
course
,
initial
=
context
.
get
(
'initial'
),
organization
=
context
.
get
(
'organization'
),
...
...
course_discovery/conf/locale/en/LC_MESSAGES/django.mo
View file @
ff0ac78a
No preview for this file type
course_discovery/conf/locale/en/LC_MESSAGES/django.po
View file @
ff0ac78a
...
...
@@ -7,14 +7,14 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-03-1
0 12:45
+0500\n"
"POT-Creation-Date: 2017-03-1
3 14:43
+0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: \n"
#: apps/api/filters.py
#, python-brace-format
...
...
@@ -594,8 +594,8 @@ msgstr ""
msgid "Course End Date"
msgstr ""
#: apps/publisher/forms.py
msgid "
i
nstructor"
#: apps/publisher/forms.py
templates/publisher/add_update_course_form.html
msgid "
I
nstructor"
msgstr ""
#: apps/publisher/forms.py
...
...
@@ -1607,10 +1607,6 @@ msgid "Add New"
msgstr ""
#: templates/publisher/add_update_course_form.html
msgid "Instructor"
msgstr ""
#: templates/publisher/add_update_course_form.html
#: templates/publisher/course_edit_form.html
msgid "SUBJECT FIELD"
msgstr ""
...
...
course_discovery/conf/locale/en/LC_MESSAGES/djangojs.mo
View file @
ff0ac78a
No preview for this file type
course_discovery/conf/locale/en/LC_MESSAGES/djangojs.po
View file @
ff0ac78a
...
...
@@ -7,14 +7,14 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-03-1
0 12:45
+0500\n"
"POT-Creation-Date: 2017-03-1
3 14:43
+0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: \n"
#: static/js/catalogs-change-form.js
msgid "Preview"
...
...
course_discovery/conf/locale/eo/LC_MESSAGES/django.mo
View file @
ff0ac78a
No preview for this file type
course_discovery/conf/locale/eo/LC_MESSAGES/django.po
View file @
ff0ac78a
...
...
@@ -7,14 +7,14 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-03-1
0 12:45
+0500\n"
"POT-Creation-Date: 2017-03-1
3 14:43
+0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: apps/api/filters.py
...
...
@@ -722,9 +722,9 @@ msgstr "Çöürsé Stärt Däté Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αм
msgid "Course End Date"
msgstr "Çöürsé Énd Däté Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт α#"
#: apps/publisher/forms.py
msgid "
i
nstructor"
msgstr "
ï
nstrüçtör Ⱡ'σяєм ιρѕυм ∂σłσ#"
#: apps/publisher/forms.py
templates/publisher/add_update_course_form.html
msgid "
I
nstructor"
msgstr "
Ì
nstrüçtör Ⱡ'σяєм ιρѕυм ∂σłσ#"
#: apps/publisher/forms.py
#: templates/publisher/course_run_detail/_preview_accept_popup.html
...
...
@@ -1912,10 +1912,6 @@ msgid "Add New"
msgstr "Àdd Néw Ⱡ'σяєм ιρѕυм #"
#: templates/publisher/add_update_course_form.html
msgid "Instructor"
msgstr "Ìnstrüçtör Ⱡ'σяєм ιρѕυм ∂σłσ#"
#: templates/publisher/add_update_course_form.html
#: templates/publisher/course_edit_form.html
msgid "SUBJECT FIELD"
msgstr "SÛBJÉÇT FÌÉLD Ⱡ'σяєм ιρѕυм ∂σłσя ѕι#"
...
...
course_discovery/conf/locale/eo/LC_MESSAGES/djangojs.mo
View file @
ff0ac78a
No preview for this file type
course_discovery/conf/locale/eo/LC_MESSAGES/djangojs.po
View file @
ff0ac78a
...
...
@@ -7,14 +7,14 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-03-1
0 12:45
+0500\n"
"POT-Creation-Date: 2017-03-1
3 14:43
+0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: static/js/catalogs-change-form.js
...
...
course_discovery/templates/publisher/_add_instructor_popup.html
View file @
ff0ac78a
...
...
@@ -29,13 +29,19 @@
<label
class=
"field-label"
>
{% trans "Organization" %}:
<span
class=
"required"
>
* {% trans "required" %}
</span>
</label>
{% if course_form.organization.field.queryset.all.count > 1 %}
{% if edit_mode %}
<span
class=
"read-only-field"
>
{{ organization_name }}
</span>
{{ course_form.organization }}
{% else %}
{% with course_form.organization.field.queryset|first as organization %}
<span
class=
"read-only-field"
>
{{ organization.name }}
</span>
<input
id=
"id_organization"
name=
"organization"
type=
"hidden"
value=
"{{ organization.id }}"
>
{% endwith %}
{% if course_form.organization.field.queryset.all.count > 1 %}
{{ course_form.organization }}
{% else %}
{% with course_form.organization.field.queryset|first as organization %}
<span
class=
"read-only-field"
>
{{ organization.name }}
</span>
<input
id=
"id_organization"
name=
"organization"
type=
"hidden"
value=
"{{ organization.id }}"
>
{% endwith %}
{% endif %}
{% endif %}
<label
class=
"field-label"
for=
"bio"
>
{% trans "Bio" %}:
...
...
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