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
d872147a
Commit
d872147a
authored
Nov 13, 2017
by
Asad Azam
Committed by
AsadAzam
Nov 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add instructor outside organization using org_override
parent
25e3abf6
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
91 additions
and
47 deletions
+91
-47
course_discovery/apps/api/serializers.py
+3
-2
course_discovery/apps/api/tests/test_serializers.py
+1
-0
course_discovery/apps/course_metadata/admin.py
+5
-0
course_discovery/apps/publisher/templates/publisher/_add_instructor_popup.html
+37
-26
course_discovery/apps/publisher/templates/publisher/_personFieldLabel.html
+4
-6
course_discovery/apps/publisher/templates/publisher/course_run/edit_run_form.html
+1
-0
course_discovery/conf/locale/en/LC_MESSAGES/django.po
+4
-0
course_discovery/conf/locale/eo/LC_MESSAGES/django.po
+4
-0
course_discovery/static/js/publisher/instructors.js
+32
-13
No files found.
course_discovery/apps/api/serializers.py
View file @
d872147a
...
...
@@ -238,7 +238,7 @@ class PositionSerializer(serializers.ModelSerializer):
class
Meta
(
object
):
model
=
Position
fields
=
(
'title'
,
'organization_name'
,
'organization'
,
'organization_id'
)
fields
=
(
'title'
,
'organization_name'
,
'organization'
,
'organization_id'
,
'organization_override'
)
extra_kwargs
=
{
'organization'
:
{
'write_only'
:
True
}
}
...
...
@@ -301,7 +301,8 @@ class PersonSerializer(serializers.ModelSerializer):
urls_data
=
validated_data
.
pop
(
'urls'
,
{})
instance
.
position
.
title
=
position_data
[
'title'
]
instance
.
position
.
organization
=
position_data
[
'organization'
]
instance
.
position
.
organization
=
position_data
.
get
(
'organization'
)
instance
.
position
.
organization_override
=
position_data
.
get
(
'organization_override'
)
instance
.
position
.
save
()
for
url_type
in
[
PersonSocialNetwork
.
FACEBOOK
,
PersonSocialNetwork
.
TWITTER
,
PersonSocialNetwork
.
BLOG
]:
...
...
course_discovery/apps/api/tests/test_serializers.py
View file @
d872147a
...
...
@@ -1153,6 +1153,7 @@ class PositionSerializerTests(TestCase):
'title'
:
str
(
position
.
title
),
'organization_name'
:
position
.
organization_name
,
'organization_id'
:
position
.
organization_id
,
'organization_override'
:
position
.
organization_override
}
self
.
assertDictEqual
(
serializer
.
data
,
expected
)
...
...
course_discovery/apps/course_metadata/admin.py
View file @
d872147a
...
...
@@ -240,6 +240,11 @@ class PersonAdmin(admin.ModelAdmin):
search_fields
=
(
'uuid'
,
'family_name'
,
'given_name'
,
'slug'
,)
@admin.register
(
Position
)
class
PositionAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'person'
,
'organization'
,
'organization_override'
,)
@admin.register
(
Video
)
class
VideoAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'src'
,
'description'
,)
...
...
course_discovery/apps/publisher/templates/publisher/_add_instructor_popup.html
View file @
d872147a
...
...
@@ -9,82 +9,93 @@
<fieldset
class=
"form-group"
>
<div
class=
"staff-image-icon"
>
<span>
{% trans "Click here to upload your image" %}
</span>
<img
src=
"data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
class=
"select-image"
/>
<img
src=
"data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
class=
"select-image"
/>
<input
name=
"staff-image"
id=
"staffImageSelect"
type=
"file"
accept=
"image/*"
onchange=
"loadSelectedImage(this);"
>
</div>
<ul>
<li><span
class=
"required"
>
{% trans "The image dimensions must be less than 110 x 110" %}
</span></li>
<li><span
class=
"required"
>
{% trans "The image size must be less than 256KB" %}
</span></li>
<li><span
class=
"required"
>
{% trans "The image dimensions must be less than 110 x 110" %}
</span>
</li>
<li><span
class=
"required"
>
{% trans "The image size must be less than 256KB" %}
</span></li>
</ul>
<label
class=
"field-label"
for=
"given-name"
>
{% trans "First Name" %}
<span
class=
"required"
>
* {% trans "required" %}
</span>
</label>
<input
class=
"field-input input-text"
type=
"text"
id=
"given-name"
name=
"given-name"
/>
<input
class=
"field-input input-text"
type=
"text"
id=
"given-name"
name=
"given-name"
/>
<label
class=
"field-label"
for=
"family-name"
>
{% trans "Last Name" %}
<span
class=
"required"
>
* {% trans "required" %}
</span>
</label>
<input
class=
"field-input input-text"
type=
"text"
id=
"family-name"
name=
"family-name"
/>
<input
class=
"field-input input-text"
type=
"text"
id=
"family-name"
name=
"family-name"
/>
<label
class=
"field-label"
for=
"title"
>
{% trans "Title" %}
<span
class=
"required"
>
* {% trans "required" %}
</span>
</label>
<input
class=
"field-input input-text"
type=
"text"
id=
"title"
name=
"title"
/>
<input
class=
"field-input input-text"
type=
"text"
id=
"title"
name=
"title"
/>
<label
class=
"field-label"
for=
"email"
>
{% trans "Email" %}
<span
class=
"required"
>
* {% trans "required" %}
</span>
</label>
<div
class=
"email-field"
>
<input
class=
"field-input input-text"
aria-describedby=
"email-hint"
type=
"email"
id=
"email"
name=
"email"
/>
<input
class=
"field-input input-text"
aria-describedby=
"email-hint"
type=
"email"
id=
"email"
name=
"email"
/>
<span
id=
"email-hint"
>
{% trans "Institution email is preferred" %}
</span>
</div>
<label
class=
"field-label"
>
{% trans "Organization" %}
<span
class=
"required"
>
* {% trans "required" %}
</span>
</label>
<div
id=
"org_container"
>
{% if organizations.count > 1 %}
<select
class=
"field-input input-select"
id=
"id_organization"
name=
"organization"
>
<option
value=
"------"
>
-----
</option>
{% for organization in organizations %}
<option
value=
"{{ organization.id }}"
>
{{ organization.name }}
</option>
{% endfor %}
</select>
{% else %}
{% with organizations|first as organization %}
<span
class=
"read-only-field"
>
{{ organization.name }}
</span>
<input
id=
"id_organization"
name=
"organization"
type=
"hidden"
value=
"{{ organization.id }}"
>
{% endwith %}
{% endif %}
</div>
<div
id=
"org_override_container"
>
<input
class=
"field-input input-text"
type=
"text"
id=
"organization_override"
name=
"organization_override"
/>
</div>
<span
id=
"override_toggle"
class=
"read-only-field"
>
<a>
{% trans "Enter a different organization" %}
</a></span>
{% if organizations.count > 1 %}
<select
class=
"field-input input-select"
id=
"id_organization"
name=
"organization"
>
<option
value=
"------"
>
-----
</option>
{% for organization in organizations %}
<option
value=
"{{ organization.id }}"
>
{{ organization.name }}
</option>
{% endfor%}
</select>
{% else %}
{% with organizations|first as organization %}
<span
class=
"read-only-field"
>
{{ organization.name }}
</span>
<input
id=
"id_organization"
name=
"organization"
type=
"hidden"
value=
"{{ organization.id }}"
>
{% endwith %}
{% endif %}
<label
class=
"field-label"
for=
"bio"
>
{% trans "Bio" %}
<span
class=
"required"
>
* {% trans "required (1-2 paragraphs)" %}
</span>
</label>
<textarea
class=
"field-textarea input-textarea textarea-medium textarea-block"
id=
"bio"
name=
"bio"
></textarea>
<textarea
class=
"field-textarea input-textarea textarea-medium textarea-block"
id=
"bio"
name=
"bio"
></textarea>
<label
class=
"field-label"
for=
"facebook"
>
{% trans "Facebook URL" %}
<span
class=
"optional"
>
{% trans "optional" %}
</span>
</label>
<input
class=
"field-input input-text"
type=
"text"
id=
"facebook"
name=
"facebook"
/>
<input
class=
"field-input input-text"
type=
"text"
id=
"facebook"
name=
"facebook"
/>
<label
class=
"field-label"
for=
"twitter"
>
{% trans "Twitter URL" %}
<span
class=
"optional"
>
{% trans "optional" %}
</span>
</label>
<input
class=
"field-input input-text"
type=
"text"
id=
"twitter"
name=
"twitter"
/>
<input
class=
"field-input input-text"
type=
"text"
id=
"twitter"
name=
"twitter"
/>
<label
class=
"field-label"
for=
"blog"
>
{% trans "Blog URL" %}
<span
class=
"optional"
>
{% trans "optional" %}
</span>
</label>
<input
class=
"field-input input-text"
type=
"text"
id=
"blog"
name=
"blog"
/>
<input
class=
"field-input input-text"
type=
"text"
id=
"blog"
name=
"blog"
/>
<label
class=
"field-label"
for=
"majorWorks"
>
{% trans "Major Works" %}
<span
class=
"optional"
>
({% trans "optional - one per line" %} )
</span>
</label>
<textarea
class=
"field-textarea input-textarea textarea-medium textarea-block"
id=
"majorWorks"
name=
"major-works"
></textarea>
<textarea
class=
"field-textarea input-textarea textarea-medium textarea-block"
id=
"majorWorks"
name=
"major-works"
></textarea>
</fieldset>
<div
class=
"actions"
>
<a
class=
"btn-cancel closeModal"
href=
"#"
>
{% trans "Cancel" %}
</a>
<button
class=
"btn-brand btn-base btn-save"
type=
"button"
data-url=
"{% url 'api:v1:person-list' %}"
id=
"add-instructor-btn"
>
{% trans "Add Staff Member" %}
</button>
<button
class=
"btn-brand btn-base btn-save"
type=
"button"
data-url=
"{% url 'api:v1:person-list' %}"
id=
"add-instructor-btn"
>
{% trans "Add Staff Member" %}
</button>
</div>
</form>
</div>
...
...
course_discovery/apps/publisher/templates/publisher/_personFieldLabel.html
View file @
d872147a
...
...
@@ -2,12 +2,10 @@
<input
type=
"hidden"
id=
"staff_{{ staff.id }}"
name=
"staff"
value=
"{{ staff.id }}"
>
<div><img
src=
"{{ staff.get_profile_image_url }}"
></div>
<div><a
class=
"delete"
id=
"{{ staff.id }}"
href=
"#"
><i
class=
"fa fa-trash-o fa-fw"
></i></a>
{% if course_user_role == 'course_team' %}
{% if staff.position %}
{% if staff.position.organization_id in organizations_ids and staff.uuid %}
<a
class=
"edit"
id=
"{{ staff.uuid }}"
href=
"#"
><i
class=
"fa fa-pencil-square-o fa-fw"
></i></a>
{% endif %}
{% endif %}
{% if (course_user_role == 'course_team' and (staff.position and staff.uuid and
staff.position.organization_id in organizations_ids or staff.position.organization_id is None)) or is_internal_user %}
<a
class=
"edit"
id=
"{{ staff.uuid }}"
href=
"#"
><i
class=
"fa fa-pencil-square-o fa-fw"
></i></a>
{% endif %}
{% else %}
{% if not staff.profile_image_url %}
<a
class=
"edit"
id=
"{{ staff.uuid }}"
href=
"#"
><i
class=
"fa fa-pencil-square-o fa-fw"
></i></a>
...
...
course_discovery/apps/publisher/templates/publisher/course_run/edit_run_form.html
View file @
d872147a
...
...
@@ -213,6 +213,7 @@
</div>
<div
id=
"user_organizations_ids"
class=
"hidden"
>
{{ organizations_ids|safe }}
</div>
<div
id=
"course_user_role"
class=
"hidden"
>
{{ course_user_role }}
</div>
<div
id=
"is_internal_user"
class=
"hidden"
>
{{ is_internal_user }}
</div>
<div
class=
"col col-6 instructor-select"
>
<label
class=
"field-label "
>
{% trans "Search for Instructor:" %}
...
...
course_discovery/conf/locale/en/LC_MESSAGES/django.po
View file @
d872147a
...
...
@@ -1021,6 +1021,10 @@ msgid "Organization"
msgstr ""
#: apps/publisher/templates/publisher/_add_instructor_popup.html
msgid "Enter a different organization"
msgstr ""
#: apps/publisher/templates/publisher/_add_instructor_popup.html
#: apps/publisher/templates/publisher/course_run_detail/_instructor_profile.html
msgid "Bio"
msgstr ""
...
...
course_discovery/conf/locale/eo/LC_MESSAGES/django.po
View file @
d872147a
...
...
@@ -1196,6 +1196,10 @@ msgid "Organization"
msgstr "Örgänïzätïön Ⱡ'σяєм ιρѕυм ∂σłσя ѕ#"
#: apps/publisher/templates/publisher/_add_instructor_popup.html
msgid "Enter a different organization"
msgstr "Éntér ä dïfférént örgänïzätïön Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє¢т#"
#: apps/publisher/templates/publisher/_add_instructor_popup.html
#: apps/publisher/templates/publisher/course_run_detail/_instructor_profile.html
msgid "Bio"
msgstr "Bïö Ⱡ'σяєм#"
...
...
course_discovery/static/js/publisher/instructors.js
View file @
d872147a
...
...
@@ -13,9 +13,16 @@ $(document).ready(function () {
});
$
(
"#override_toggle"
).
click
(
function
(
e
)
{
$
(
'#org_override_container'
).
toggle
();
$
(
'#org_container'
).
toggle
();
});
$
(
'#add-new-instructor'
).
click
(
function
(
e
)
{
clearModalError
();
var
btnInstructor
=
$
(
'#add-instructor-btn'
);
$
(
'#org_container'
).
show
();
$
(
'#org_override_container'
).
hide
();
$
(
'#addInstructorModal'
).
show
();
$
(
'body'
).
addClass
(
'stopScroll'
);
$
(
'.new-instructor-heading'
).
text
(
gettext
(
'New Instructor'
));
...
...
@@ -34,16 +41,15 @@ $(document).ready(function () {
addModalError
(
gettext
(
"Please upload a instructor image."
));
return
;
}
var
position
=
getFormInstructorPosition
()
personData
=
{
'given_name'
:
$
(
'#given-name'
).
val
(),
'family_name'
:
$
(
'#family-name'
).
val
(),
'bio'
:
$
(
'#bio'
).
val
(),
'email'
:
$
(
'#email'
).
val
(),
'profile_image'
:
$
(
'.select-image'
).
attr
(
'src'
),
'position'
:
{
title
:
$
(
'#title'
).
val
(),
organization
:
parseInt
(
$
(
'#id_organization'
).
val
())
},
'position'
:
position
,
'works'
:
$
(
'#majorWorks'
).
val
().
split
(
'
\
n'
),
'urls'
:
{
facebook
:
$
(
'#facebook'
).
val
(),
...
...
@@ -96,6 +102,21 @@ $(document).ready(function () {
});
});
function
getFormInstructorPosition
()
{
if
(
$
(
'#organization_override'
).
val
())
{
return
{
title
:
$
(
'#title'
).
val
(),
organization_override
:
$
(
'#organization_override'
).
val
(),
organization
:
null
};
}
return
{
title
:
$
(
'#title'
).
val
(),
organization_override
:
null
,
organization
:
parseInt
(
$
(
'#id_organization'
).
val
())
};
}
function
loadSelectedImage
(
input
)
{
var
maxFileSize
=
256
,
// Size in KB's
imageFile
=
input
.
files
[
0
],
...
...
@@ -149,21 +170,19 @@ $(document).on('click', '.selected-instructor a.delete', function (e) {
function
renderSelectedInstructor
(
id
,
name
,
image
,
uuid
,
organization_id
,
edit_instructor
)
{
var
user_organizations_ids
=
$
(
'#user_organizations_ids'
).
text
(),
course_user_role
=
$
(
'#course_user_role'
).
text
(),
is_internal_user
=
$
(
'#is_internal_user'
).
text
(),
staff
=
'<input type="hidden" id="staff_'
+
id
+
'"name="staff" value="'
+
id
+
'">'
,
instructorHtmlStart
=
'<div class="instructor" id= "instructor_'
+
id
+
'"><div><img src="'
+
image
+
'"></div><div>'
,
instructorHtmlEnd
=
'<b>'
+
name
+
'</b></div></div>'
,
controlOptions
=
'<a class="delete" id="'
+
id
+
'"href="#"><i class="fa fa-trash-o fa-fw"></i></a>'
;
if
(
course_user_role
==
"course_team"
)
{
if
(
$
.
inArray
(
parseInt
(
organization_id
),
JSON
.
parse
(
user_organizations_ids
))
>
-
1
&&
uuid
)
{
controlOptions
+=
'<a class="edit" id="'
+
uuid
+
'"href="#"><i class="fa fa-pencil-square-o fa-fw"></i></a>'
;
}
}
else
{
if
(
edit_instructor
)
{
controlOptions
+=
'<a class="edit" id="'
+
uuid
+
'"href="#"><i class="fa fa-pencil-square-o fa-fw"></i></a>'
;
}
var
user_is_course_team
=
course_user_role
===
"course_team"
;
var
user_is_in_similar_org_as_instructor
=
$
.
inArray
(
parseInt
(
organization_id
),
JSON
.
parse
(
user_organizations_ids
))
>
-
1
;
var
org_is_none
=
organization_id
===
"None"
;
if
((
user_is_course_team
&&
(
user_is_in_similar_org_as_instructor
&&
uuid
||
org_is_none
))
||
is_internal_user
||
edit_instructor
)
{
controlOptions
+=
'<a class="edit" id="'
+
uuid
+
'"href="#"><i class="fa fa-pencil-square-o fa-fw"></i></a>'
;
}
$
(
'.selected-instructor'
).
append
(
staff
+
instructorHtmlStart
+
controlOptions
+
instructorHtmlEnd
);
}
...
...
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