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
0e5c1ed0
Commit
0e5c1ed0
authored
Sep 25, 2017
by
attiyaishaque
Committed by
Attiya Ishaque
Sep 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Course team would be able to edit existing instructor of same org.
parent
3029daf8
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
42 additions
and
14 deletions
+42
-14
course_discovery/apps/course_metadata/lookups.py
+3
-1
course_discovery/apps/publisher/forms.py
+2
-1
course_discovery/apps/publisher/templates/publisher/_personFieldLabel.html
+1
-1
course_discovery/apps/publisher/templates/publisher/_personLookup.html
+1
-0
course_discovery/apps/publisher/templates/publisher/course_run/edit_run_form.html
+2
-0
course_discovery/apps/publisher/tests/test_forms.py
+2
-1
course_discovery/apps/publisher/views.py
+5
-0
course_discovery/static/js/publisher/instructors.js
+23
-10
course_discovery/static/sass/publisher/publisher.scss
+3
-0
No files found.
course_discovery/apps/course_metadata/lookups.py
View file @
0e5c1ed0
...
@@ -71,7 +71,9 @@ class PersonAutocomplete(LoginRequiredMixin, autocomplete.Select2QuerySetView):
...
@@ -71,7 +71,9 @@ class PersonAutocomplete(LoginRequiredMixin, autocomplete.Select2QuerySetView):
'uuid'
:
result
.
uuid
,
'uuid'
:
result
.
uuid
,
'profile_image'
:
result
.
get_profile_image_url
,
'profile_image'
:
result
.
get_profile_image_url
,
'full_name'
:
result
.
full_name
,
'full_name'
:
result
.
full_name
,
'position'
:
result
.
position
if
hasattr
(
result
,
'position'
)
else
None
'position'
:
result
.
position
if
hasattr
(
result
,
'position'
)
else
None
,
'organization_id'
:
result
.
position
.
organization_id
if
hasattr
(
result
,
'position'
)
else
None
}
}
return
render_to_string
(
'publisher/_personLookup.html'
,
context
=
context
)
return
render_to_string
(
'publisher/_personLookup.html'
,
context
=
context
)
course_discovery/apps/publisher/forms.py
View file @
0e5c1ed0
...
@@ -29,7 +29,8 @@ class PersonModelMultipleChoice(forms.ModelMultipleChoiceField):
...
@@ -29,7 +29,8 @@ class PersonModelMultipleChoice(forms.ModelMultipleChoiceField):
context
=
{
context
=
{
'profile_image'
:
obj
.
get_profile_image_url
,
'profile_image'
:
obj
.
get_profile_image_url
,
'full_name'
:
obj
.
full_name
,
'full_name'
:
obj
.
full_name
,
'uuid'
:
obj
.
uuid
if
not
obj
.
profile_image_url
else
None
'uuid'
:
obj
.
uuid
,
'organization_id'
:
obj
.
position
.
organization_id
if
hasattr
(
obj
,
'position'
)
else
None
}
}
return
str
(
render_to_string
(
'publisher/_personFieldLabel.html'
,
context
=
context
))
return
str
(
render_to_string
(
'publisher/_personFieldLabel.html'
,
context
=
context
))
...
...
course_discovery/apps/publisher/templates/publisher/_personFieldLabel.html
View file @
0e5c1ed0
<img
src=
"{{ profile_image }}"
/><span
{%
if
uuid
%}
data-uuid=
"{{ uuid }}"
{%
endif
%}
>
{{ full_name }}
</span>
<img
src=
"{{ profile_image }}"
/><span
{%
if
uuid
%}
data-uuid=
"{{ uuid }}"
{%
endif
%}
>
{{ full_name }}
</span>
{% if organization_id %}
<span>
{{ organization_id }}
</span>
{% endif %}
course_discovery/apps/publisher/templates/publisher/_personLookup.html
View file @
0e5c1ed0
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
<b>
{{ full_name }}
</b>
<b>
{{ full_name }}
</b>
{% if position %}
{% if position %}
<p>
{{ position }}
</p>
<p>
{{ position }}
</p>
<span
class=
"hidden"
>
{{ organization_id }}
</span>
{% endif %}
{% endif %}
</td>
</td>
</tr>
</tr>
...
...
course_discovery/apps/publisher/templates/publisher/course_run/edit_run_form.html
View file @
0e5c1ed0
...
@@ -208,6 +208,8 @@
...
@@ -208,6 +208,8 @@
<div
class=
"col col-6 help-text"
>
<div
class=
"col col-6 help-text"
>
{% trans "The primary instructor or instructors for the course." %}
{% trans "The primary instructor or instructors for the course." %}
</div>
</div>
<div
id=
"user_organizations_ids"
class=
"hidden"
>
{{ organizations_ids|safe }}
</div>
<div
id=
"course_user_role"
class=
"hidden"
>
{{ course_user_role }}
</div>
<div
class=
"col col-6 instructor-select"
>
<div
class=
"col col-6 instructor-select"
>
<label
class=
"field-label "
>
{{ run_form.staff.label_tag }}
<span
class=
"required"
>
*
</span></label>
<label
class=
"field-label "
>
{{ run_form.staff.label_tag }}
<span
class=
"required"
>
*
</span></label>
{{ run_form.staff }}
{{ run_form.staff }}
...
...
course_discovery/apps/publisher/tests/test_forms.py
View file @
0e5c1ed0
...
@@ -58,8 +58,9 @@ class PersonModelMultipleChoiceTests(TestCase):
...
@@ -58,8 +58,9 @@ class PersonModelMultipleChoiceTests(TestCase):
# we need to loop through choices because it is a ModelChoiceIterator
# we need to loop through choices because it is a ModelChoiceIterator
for
__
,
choice_label
in
course_form
.
fields
[
'staff'
]
.
choices
:
for
__
,
choice_label
in
course_form
.
fields
[
'staff'
]
.
choices
:
expected
=
'<img src="{url}"/><span>{full_name}</span>'
.
format
(
expected
=
'<img src="{url}"/><span
data-uuid="{uuid}"
>{full_name}</span>'
.
format
(
full_name
=
person
.
full_name
,
full_name
=
person
.
full_name
,
uuid
=
person
.
uuid
,
url
=
person
.
get_profile_image_url
url
=
person
.
get_profile_image_url
)
)
self
.
assertEqual
(
choice_label
.
strip
(),
expected
)
self
.
assertEqual
(
choice_label
.
strip
(),
expected
)
...
...
course_discovery/apps/publisher/views.py
View file @
0e5c1ed0
...
@@ -702,7 +702,12 @@ class CourseRunEditView(mixins.LoginRequiredMixin, mixins.PublisherPermissionMix
...
@@ -702,7 +702,12 @@ class CourseRunEditView(mixins.LoginRequiredMixin, mixins.PublisherPermissionMix
context
=
self
.
get_context_data
()
context
=
self
.
get_context_data
()
course_run
=
context
.
get
(
'course_run'
)
course_run
=
context
.
get
(
'course_run'
)
course
=
course_run
.
course
course
=
course_run
.
course
course_user_role
=
course
.
get_user_role
(
user
=
self
.
request
.
user
)
if
course_user_role
==
PublisherUserRole
.
CourseTeam
:
context
[
'organizations_ids'
]
=
list
(
mixins
.
get_user_organizations
(
self
.
request
.
user
)
.
values_list
(
'id'
,
flat
=
True
))
context
[
'course_user_role'
]
=
course_user_role
context
[
'run_form'
]
=
self
.
run_form
(
context
[
'run_form'
]
=
self
.
run_form
(
instance
=
course_run
,
is_project_coordinator
=
context
.
get
(
'is_project_coordinator'
)
instance
=
course_run
,
is_project_coordinator
=
context
.
get
(
'is_project_coordinator'
)
)
)
...
...
course_discovery/static/js/publisher/instructors.js
View file @
0e5c1ed0
...
@@ -4,9 +4,10 @@ $(document).ready(function(){
...
@@ -4,9 +4,10 @@ $(document).ready(function(){
var
id
=
this
.
value
,
var
id
=
this
.
value
,
label
=
$
.
parseHTML
(
this
.
label
),
label
=
$
.
parseHTML
(
this
.
label
),
image_source
=
$
(
label
[
0
]).
attr
(
'src'
),
image_source
=
$
(
label
[
0
]).
attr
(
'src'
),
name
=
$
(
label
[
1
]).
text
();
name
=
$
(
label
[
1
]).
text
(),
uuid
=
$
(
label
[
1
]).
data
(
'uuid'
);
uuid
=
$
(
label
[
1
]).
data
(
'uuid'
),
renderSelectedInstructor
(
id
,
name
,
image_source
,
uuid
);
organization_id
=
$
(
label
[
2
]).
text
();
renderSelectedInstructor
(
id
,
name
,
image_source
,
uuid
,
organization_id
);
});
});
$
(
"#id_staff"
).
on
(
"select2:select"
,
function
(
e
)
{
$
(
"#id_staff"
).
on
(
"select2:select"
,
function
(
e
)
{
...
@@ -14,8 +15,10 @@ $(document).ready(function(){
...
@@ -14,8 +15,10 @@ $(document).ready(function(){
id
=
$instructorSelector
.
id
,
id
=
$instructorSelector
.
id
,
selectedInstructorData
=
$
.
parseHTML
(
$instructorSelector
.
text
)[
0
],
selectedInstructorData
=
$
.
parseHTML
(
$instructorSelector
.
text
)[
0
],
image_source
=
$
(
selectedInstructorData
).
find
(
'img'
).
attr
(
'src'
),
image_source
=
$
(
selectedInstructorData
).
find
(
'img'
).
attr
(
'src'
),
name
=
$
(
selectedInstructorData
).
find
(
'b'
).
text
();
name
=
$
(
selectedInstructorData
).
find
(
'b'
).
text
(),
renderSelectedInstructor
(
id
,
name
,
image_source
);
uuid
=
$
(
selectedInstructorData
)[
0
].
id
,
organization_id
=
$
(
selectedInstructorData
).
find
(
'span'
).
text
();
renderSelectedInstructor
(
id
,
name
,
image_source
,
uuid
,
organization_id
);
});
});
...
@@ -136,15 +139,19 @@ $(document).on('click', '.selected-instructor a.delete', function (e) {
...
@@ -136,15 +139,19 @@ $(document).on('click', '.selected-instructor a.delete', function (e) {
$
(
'.instructor-select'
).
find
(
'.select2-selection__choice'
).
remove
();
$
(
'.instructor-select'
).
find
(
'.select2-selection__choice'
).
remove
();
});
});
function
renderSelectedInstructor
(
id
,
name
,
image
,
uuid
)
{
function
renderSelectedInstructor
(
id
,
name
,
image
,
uuid
,
organization_id
)
{
var
instructorHtmlStart
=
'<div class="instructor" id= "instructor_'
+
id
+
'"><div><img src="'
+
image
+
'"></div><div>'
,
var
user_organizations_ids
=
$
(
'#user_organizations_ids'
).
text
(),
course_user_role
=
$
(
'#course_user_role'
).
text
(),
instructorHtmlStart
=
'<div class="instructor" id= "instructor_'
+
id
+
'"><div><img src="'
+
image
+
'"></div><div>'
,
instructorHtmlEnd
=
'<b>'
+
name
+
'</b></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>'
;
controlOptions
=
'<a class="delete" id="'
+
id
+
'"href="#"><i class="fa fa-trash-o fa-fw"></i></a>'
;
if
(
uuid
)
{
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>'
;
controlOptions
+=
'<a class="edit" id="'
+
uuid
+
'"href="#"><i class="fa fa-pencil-square-o fa-fw"></i></a>'
;
}
}
}
$
(
'.selected-instructor'
).
append
(
instructorHtmlStart
+
controlOptions
+
instructorHtmlEnd
);
$
(
'.selected-instructor'
).
append
(
instructorHtmlStart
+
controlOptions
+
instructorHtmlEnd
);
}
}
...
@@ -191,6 +198,7 @@ function loadInstructor(uuid, editMode) {
...
@@ -191,6 +198,7 @@ function loadInstructor(uuid, editMode) {
value
:
id
,
value
:
id
,
text
:
name
text
:
name
}).
attr
(
'selected'
,
'selected'
));
}).
attr
(
'selected'
,
'selected'
));
organization_id
=
$
(
label
).
find
(
'span'
).
text
()
if
(
editMode
)
{
if
(
editMode
)
{
// Updating the existing instructor
// Updating the existing instructor
...
@@ -199,7 +207,7 @@ function loadInstructor(uuid, editMode) {
...
@@ -199,7 +207,7 @@ function loadInstructor(uuid, editMode) {
instructor_id
.
find
(
'b'
).
text
(
name
);
instructor_id
.
find
(
'b'
).
text
(
name
);
}
}
else
{
else
{
renderSelectedInstructor
(
id
,
name
,
image_source
,
uuid
);
renderSelectedInstructor
(
id
,
name
,
image_source
,
uuid
,
organization_id
);
}
}
}
}
...
@@ -223,7 +231,12 @@ $(document).on('click', '.selected-instructor a.edit', function (e) {
...
@@ -223,7 +231,12 @@ $(document).on('click', '.selected-instructor a.edit', function (e) {
$
.
getJSON
({
$
.
getJSON
({
url
:
btnInstructor
.
data
(
'url'
)
+
uuid
,
url
:
btnInstructor
.
data
(
'url'
)
+
uuid
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
if
(
$
.
isEmptyObject
(
data
[
'profile_image'
]))
{
$
(
'.select-image'
).
attr
(
'src'
,
data
[
'profile_image_url'
]);
}
else
{
$
(
'.select-image'
).
attr
(
'src'
,
data
[
'profile_image'
][
'medium'
][
'url'
]);
$
(
'.select-image'
).
attr
(
'src'
,
data
[
'profile_image'
][
'medium'
][
'url'
]);
}
$
(
'#given-name'
).
val
(
data
[
'given_name'
]);
$
(
'#given-name'
).
val
(
data
[
'given_name'
]);
$
(
'#family-name'
).
val
(
data
[
'family_name'
]);
$
(
'#family-name'
).
val
(
data
[
'family_name'
]);
$
(
'#title'
).
val
(
data
[
'position'
][
'title'
]);
$
(
'#title'
).
val
(
data
[
'position'
][
'title'
]);
...
...
course_discovery/static/sass/publisher/publisher.scss
View file @
0e5c1ed0
...
@@ -216,6 +216,9 @@
...
@@ -216,6 +216,9 @@
.field-value
{
.field-value
{
margin-bottom
:
20px
;
margin-bottom
:
20px
;
}
}
.hidden
{
display
:
none
;
}
.help-text
{
.help-text
{
p
{
p
{
margin-bottom
:
0
;
margin-bottom
:
0
;
...
...
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