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
e6369dc5
Commit
e6369dc5
authored
Apr 12, 2017
by
tasawernawaz
Committed by
Tasawer Nawaz
Apr 12, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove html tags before comparing course fields
ECOM-7694
parent
99efb6c0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
17 deletions
+73
-17
course_discovery/static/js/publisher/comparing-objects.js
+15
-3
course_discovery/static/js/publisher/revision-history.js
+6
-2
course_discovery/templates/publisher/_render_optional_field.html
+1
-1
course_discovery/templates/publisher/_render_required_field.html
+1
-1
course_discovery/templates/publisher/course_revision_history.html
+50
-10
No files found.
course_discovery/static/js/publisher/comparing-objects.js
View file @
e6369dc5
...
...
@@ -15,12 +15,24 @@ $(document).on('click', '.btn-show-changes', function (e) {
}
});
function
getComparableText
(
object
)
{
if
(
$
(
object
).
find
(
'.dont-compare'
).
length
>
0
)
{
return
""
;
}
else
{
return
object
.
text
().
trim
()
}
}
var
dmp
=
new
diff_match_patch
();
dmp
.
Diff_EditCost
=
8
;
function
showDiff
(
$object
,
$historyObject
,
$outputDiv
)
{
var
d
=
dmp
.
diff_main
(
$historyObject
.
text
(),
$object
.
text
());
dmp
.
diff_cleanupEfficiency
(
d
);
$outputDiv
.
html
(
dmp
.
diff_prettyHtml
(
d
));
var
currentText
=
$
(
$
.
parseHTML
(
$object
.
text
())).
text
().
trim
(),
historyText
=
getComparableText
(
$historyObject
),
diff
;
diff
=
dmp
.
diff_main
(
historyText
,
currentText
);
dmp
.
diff_cleanupEfficiency
(
diff
);
$outputDiv
.
html
(
dmp
.
diff_prettyHtml
(
diff
));
$historyObject
.
hide
();
$outputDiv
.
show
();
}
...
...
course_discovery/static/js/publisher/revision-history.js
View file @
e6369dc5
...
...
@@ -12,14 +12,18 @@ $(document).on('change', '#id_select_revisions', function (e) {
});
function
loadRevisionHistory
(
revisionUrl
)
{
var
currentObject
,
currentObjectText
;
$
.
getJSON
({
url
:
revisionUrl
,
success
:
function
(
data
)
{
$
.
each
(
data
,
function
(
key
,
value
)
{
var
currentObject
=
$
(
'.history-field-container'
).
find
(
'.'
+
key
);
currentObject
=
$
(
'.history-field-container'
).
find
(
'.'
+
key
);
if
(
currentObject
.
length
&&
value
!=
null
)
{
showDiffCourseDetails
(
value
,
currentObject
.
text
(),
currentObject
.
siblings
(
'.show-diff'
));
currentObjectText
=
getComparableText
(
currentObject
);
value
=
$
(
$
.
parseHTML
(
value
)).
text
().
trim
();
showDiffCourseDetails
(
value
,
currentObjectText
,
currentObject
.
siblings
(
'.show-diff'
));
currentObject
.
hide
();
}
});
...
...
course_discovery/templates/publisher/_render_optional_field.html
View file @
e6369dc5
...
...
@@ -3,5 +3,5 @@
{% if field %}
{{ field|safe }}
{% else %}
{% trans "(Optional) Not yet added" %}
<div
class=
"dont-compare"
>
{% trans "(Optional) Not yet added" %}
</div>
{% endif %}
course_discovery/templates/publisher/_render_required_field.html
View file @
e6369dc5
...
...
@@ -3,5 +3,5 @@
{% if field %}
{{ field|safe }}
{% else %}
{% trans "(Required) Not yet added" %}
<div
class=
"dont-compare"
>
{% trans "(Required) Not yet added" %}
</div>
{% endif %}
course_discovery/templates/publisher/course_revision_history.html
View file @
e6369dc5
...
...
@@ -45,7 +45,11 @@
<div
class=
"field-container"
>
<div
class=
"field-title"
>
{% trans "Brief Description" %}
</div>
<span
class=
"object"
>
{{ object.short_description }}
</span>
<span
class=
"history-object"
>
{{ history_object.short_description }}
</span>
<span
class=
"history-object"
>
{% with history_object.short_description as field %}
{% include "publisher/_render_required_field.html" %}
{% endwith %}
</span>
<span
class=
"show-diff"
></span>
</div>
...
...
@@ -53,7 +57,11 @@
<div
class=
"field-container"
>
<div
class=
"field-title"
>
{% trans "Full Description" %}
</div>
<span
class=
"object"
>
{{ object.full_description }}
</span>
<span
class=
"history-object"
>
{{ history_object.full_description }}
</span>
<span
class=
"history-object"
>
{% with history_object.full_description as field %}
{% include "publisher/_render_required_field.html" %}
{% endwith %}
</span>
<span
class=
"show-diff"
></span>
</div>
...
...
@@ -61,56 +69,88 @@
<div
class=
"field-container"
>
<div
class=
"field-title"
>
{% trans "Expected Learnings" %}
</div>
<span
class=
"object"
>
{{ object.expected_learnings }}
</span>
<span
class=
"history-object"
>
{{ history_object.expected_learnings }}
</span>
<span
class=
"history-object"
>
{% with history_object.expected_learnings as field %}
{% include "publisher/_render_required_field.html" %}
{% endwith %}
</span>
<span
class=
"show-diff"
></span>
</div>
<div
class=
"field-container"
>
<div
class=
"field-title"
>
{% trans "Primary Subject" %}
</div>
<span
class=
"object"
>
{{ object.primary_subject }}
</span>
<span
class=
"history-object"
>
{{ history_object.primary_subject }}
</span>
<span
class=
"history-object"
>
{% with history_object.primary_subject as field %}
{% include "publisher/_render_required_field.html" %}
{% endwith %}
</span>
<span
class=
"show-diff"
></span>
</div>
<div
class=
"field-container"
>
<div
class=
"field-title"
>
{% trans "Secondary Subject" %}
</div>
<span
class=
"object"
>
{{ object.secondary_subject }}
</span>
<span
class=
"history-object"
>
{{ history_object.secondary_subject }}
</span>
<span
class=
"history-object"
>
{% with history_object.secondary_subject as field %}
{% include "publisher/_render_optional_field.html" %}
{% endwith %}
</span>
<span
class=
"show-diff"
></span>
</div>
<div
class=
"field-container"
>
<div
class=
"field-title"
>
{% trans "Tertiary Subject" %}
</div>
<span
class=
"object"
>
{{ object.tertiary_subject }}
</span>
<span
class=
"history-object"
>
{{ history_object.tertiary_subject }}
</span>
<span
class=
"history-object"
>
{% with history_object.tertiary_subject as field %}
{% include "publisher/_render_optional_field.html" %}
{% endwith %}
</span>
<span
class=
"show-diff"
></span>
</div>
<div
class=
"field-container"
>
<div
class=
"field-title"
>
{% trans "Prerequisites" %}
</div>
<span
class=
"object"
>
{{ object.prerequisites }}
</span>
<span
class=
"history-object"
>
{{ history_object.prerequisites }}
</span>
<span
class=
"history-object"
>
{% with history_object.prerequisites as field %}
{% include "publisher/_render_required_field.html" %}
{% endwith %}
</span>
<span
class=
"show-diff"
></span>
</div>
<div
class=
"field-container"
>
<div
class=
"field-title"
>
{% trans "Course Level" %}
</div>
<span
class=
"object"
>
{{ object.level_type }}
</span>
<span
class=
"history-object"
>
{{ history_object.level_type }}
</span>
<span
class=
"history-object"
>
{% with history_object.level_type as field %}
{% include "publisher/_render_required_field.html" %}
{% endwith %}
</span>
<span
class=
"show-diff"
></span>
</div>
<div
class=
"field-container"
>
<div
class=
"field-title"
>
{% trans "Learner Testimonials" %}
</div>
<span
class=
"object"
>
{{ object.learner_testimonial }}
</span>
<span
class=
"history-object"
>
{{ history_object.learner_testimonial }}
</span>
<span
class=
"history-object"
>
{% with history_object.learner_testimonial as field %}
{% include "publisher/_render_optional_field.html" %}
{% endwith %}
</span>
<span
class=
"show-diff"
></span>
</div>
<div
class=
"field-container"
>
<div
class=
"field-title"
>
{% trans "FAQ" %}
</div>
<span
class=
"object"
>
{{ object.faq }}
</span>
<span
class=
"history-object"
>
{{ history_object.faq }}
</span>
<span
class=
"history-object"
>
{% with history_object.faq as field %}
{% include "publisher/_render_optional_field.html" %}
{% endwith %}
</span>
<span
class=
"show-diff"
></span>
</div>
...
...
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