Commit f67faa7c by Ali Committed by Se Won Jang

frontend portion of enrollment emails

parent 44129cc4
...@@ -24,6 +24,8 @@ class CourseDetails(object): ...@@ -24,6 +24,8 @@ class CourseDetails(object):
self.syllabus = None # a pdf file asset self.syllabus = None # a pdf file asset
self.short_description = "" self.short_description = ""
self.overview = "" # html to render as the overview self.overview = "" # html to render as the overview
self.pre_enrollment_email = "" # html to render as the pre-enrollment email
self.post_enrollment_email = "" # html to render as the post-enrollment email
self.intro_video = None # a video pointer self.intro_video = None # a video pointer
self.effort = None # int hours/week self.effort = None # int hours/week
self.course_image_name = "" self.course_image_name = ""
...@@ -62,6 +64,18 @@ class CourseDetails(object): ...@@ -62,6 +64,18 @@ class CourseDetails(object):
except ItemNotFoundError: except ItemNotFoundError:
pass pass
temploc = course_key.make_usage_key('about', 'pre_enrollment_email')
try:
course.pre_enrollment_email = get_modulestore(temploc).get_item(temploc).data
except ItemNotFoundError:
pass
temploc = course_key.make_usage_key('about', 'post_enrollment_email')
try:
course.post_enrollment_email = get_modulestore(temploc).get_item(temploc).data
except ItemNotFoundError:
pass
temploc = course_key.make_usage_key('about', 'effort') temploc = course_key.make_usage_key('about', 'effort')
try: try:
course_details.effort = modulestore().get_item(temploc).data course_details.effort = modulestore().get_item(temploc).data
...@@ -155,7 +169,7 @@ class CourseDetails(object): ...@@ -155,7 +169,7 @@ class CourseDetails(object):
# NOTE: below auto writes to the db w/o verifying that any of the fields actually changed # NOTE: below auto writes to the db w/o verifying that any of the fields actually changed
# to make faster, could compare against db or could have client send over a list of which fields changed. # to make faster, could compare against db or could have client send over a list of which fields changed.
for about_type in ['syllabus', 'overview', 'effort', 'short_description']: for about_type in ['syllabus', 'overview', 'effort', 'short_description', 'pre_enrollment_email', 'post_enrollment_email']:
cls.update_about_item(course_key, about_type, jsondict[about_type], descriptor, user) cls.update_about_item(course_key, about_type, jsondict[about_type], descriptor, user)
recomposed_video_tag = CourseDetails.recompose_video_tag(jsondict['intro_video']) recomposed_video_tag = CourseDetails.recompose_video_tag(jsondict['intro_video'])
......
...@@ -12,6 +12,9 @@ var DetailsView = ValidatingView.extend({ ...@@ -12,6 +12,9 @@ var DetailsView = ValidatingView.extend({
"change textarea" : "updateModel", "change textarea" : "updateModel",
'click .remove-course-introduction-video' : "removeVideo", 'click .remove-course-introduction-video' : "removeVideo",
'focus #course-overview' : "codeMirrorize", 'focus #course-overview' : "codeMirrorize",
'click #enable-enrollment-email' : "toggleEnrollmentEmails",
'focus #pre-enrollment-email' : "codeMirrorize",
'focus #post-enrollment-email' : "codeMirrorize",
'mouseover #timezone' : "updateTime", 'mouseover #timezone' : "updateTime",
// would love to move to a general superclass, but event hashes don't inherit in backbone :-( // would love to move to a general superclass, but event hashes don't inherit in backbone :-(
'focus :input' : "inputFocus", 'focus :input' : "inputFocus",
...@@ -51,6 +54,12 @@ var DetailsView = ValidatingView.extend({ ...@@ -51,6 +54,12 @@ var DetailsView = ValidatingView.extend({
this.$el.find('#' + this.fieldToSelectorMap['overview']).val(this.model.get('overview')); this.$el.find('#' + this.fieldToSelectorMap['overview']).val(this.model.get('overview'));
this.codeMirrorize(null, $('#course-overview')[0]); this.codeMirrorize(null, $('#course-overview')[0]);
this.$el.find('#' + this.fieldToSelectorMap['pre_enrollment_email']).val(this.model.get('pre_enrollment_email'));
this.codeMirrorize(null, $('#pre-enrollment-email')[0]);
this.$el.find('#' + this.fieldToSelectorMap['post_enrollment_email']).val(this.model.get('post_enrollment_email'));
this.codeMirrorize(null, $('#post-enrollment-email')[0]);
this.$el.find('#' + this.fieldToSelectorMap['short_description']).val(this.model.get('short_description')); this.$el.find('#' + this.fieldToSelectorMap['short_description']).val(this.model.get('short_description'));
this.$el.find('.current-course-introduction-video iframe').attr('src', this.model.videosourceSample()); this.$el.find('.current-course-introduction-video iframe').attr('src', this.model.videosourceSample());
...@@ -74,6 +83,8 @@ var DetailsView = ValidatingView.extend({ ...@@ -74,6 +83,8 @@ var DetailsView = ValidatingView.extend({
'enrollment_start' : 'enrollment-start', 'enrollment_start' : 'enrollment-start',
'enrollment_end' : 'enrollment-end', 'enrollment_end' : 'enrollment-end',
'overview' : 'course-overview', 'overview' : 'course-overview',
'pre_enrollment_email' : 'pre-enrollment-email',
'post_enrollment_email' : 'post-enrollment-email',
'short_description' : 'course-short-description', 'short_description' : 'course-short-description',
'intro_video' : 'course-introduction-video', 'intro_video' : 'course-introduction-video',
'effort' : "course-effort", 'effort' : "course-effort",
...@@ -185,6 +196,18 @@ var DetailsView = ValidatingView.extend({ ...@@ -185,6 +196,18 @@ var DetailsView = ValidatingView.extend({
this.$el.find('.remove-course-introduction-video').hide(); this.$el.find('.remove-course-introduction-video').hide();
} }
}, },
toggleEnrollmentEmails: function(event) {
var isChecked = this.$el.find("#enable-enrollment-email").is(':checked');
if(isChecked) {
this.$el.find('#field-pre-enrollment-email').show();
this.$el.find('#field-post-enrollment-email').show();
} else {
this.$el.find('#field-pre-enrollment-email').hide();
this.$el.find('#field-post-enrollment-email').hide();
}
},
codeMirrors : {}, codeMirrors : {},
codeMirrorize: function (e, forcedTarget) { codeMirrorize: function (e, forcedTarget) {
var thisTarget; var thisTarget;
......
...@@ -202,6 +202,26 @@ ...@@ -202,6 +202,26 @@
display: inline-block; display: inline-block;
} }
} }
.list-actions {
//box-shadow: inset 0 1px 1px $shadow-l1;
//border-top: 1px solid $gray-l2;
padding-top: ($baseline/2);
//background: $gray-l5;
.action-primary {
@include blue-button();
@extend %t-action3;
font-weight: 600;
[class^="icon-"] {
@extend %t-icon5;
display: inline-block;
vertical-align: middle;
margin-top: -3px;
}
}
}
} }
.field-group { .field-group {
...@@ -404,6 +424,32 @@ ...@@ -404,6 +424,32 @@
} }
} }
// specific fields - pre-enrollment email
#field-pre-enrollment-email {
#pre-enrollment-email {
height: ($baseline*20);
}
//adds back in CodeMirror border removed due to Unit page styling of component editors
.CodeMirror {
border: 1px solid $gray-l2;
}
}
// specific fields - post-enrollment email
#field-post-enrollment-email {
#post-enrollment-email {
height: ($baseline*20);
}
//adds back in CodeMirror border removed due to Unit page styling of component editors
.CodeMirror {
border: 1px solid $gray-l2;
}
}
// specific fields - video // specific fields - video
#field-course-introduction-video { #field-course-introduction-video {
......
...@@ -205,7 +205,7 @@ require(["domReady!", "jquery", "js/models/settings/course_details", "js/views/s ...@@ -205,7 +205,7 @@ require(["domReady!", "jquery", "js/models/settings/course_details", "js/views/s
<ol class="list-input"> <ol class="list-input">
% if short_description_editable: % if short_description_editable:
<li class="field text" id="field-course-short-description"> <li class="field text" id="field-course-short-description">
<label for="course-overview">${_("Course Short Description")}</label> <label for="course-short-description">${_("Course Short Description")}</label>
<textarea class="text" id="course-short-description"></textarea> <textarea class="text" id="course-short-description"></textarea>
<span class="tip tip-stacked">${_("Appears on the course catalog page when students roll over the course name. Limit to ~150 characters")}</span> <span class="tip tip-stacked">${_("Appears on the course catalog page when students roll over the course name. Limit to ~150 characters")}</span>
</li> </li>
...@@ -225,6 +225,38 @@ require(["domReady!", "jquery", "js/models/settings/course_details", "js/views/s ...@@ -225,6 +225,38 @@ require(["domReady!", "jquery", "js/models/settings/course_details", "js/views/s
</li> </li>
% endif % endif
<li class="field text" id="field-enable-enrollment-email">
<input type="checkbox" id="enable-enrollment-email"/>
<label for="enable-enrollment-email">${_("Enable enrollment emails")}</label>
</li>
<li class="field text" id="field-pre-enrollment-email">
<label for="pre-enrollment-email">${_("Email sent to students who enroll before the course starts")}</label>
<textarea class="tinymce text-editor" id="pre-enrollment-email"></textarea>
<span class="tip tip-stacked">${_("This email will be sent to any student who enrolls in the course before its start date")}</span>
<ul class="list-actions">
<li class="action-item">
<a title="${_('Send me a copy of this via email')}"
href="" class="action action-primary">
${_("Send me a test email")}</a>
</li>
</ul>
</li>
<li class="field text" id="field-post-enrollment-email">
<label for="post-enrollment-email">${_("Email sent to students who enroll after the course starts")}</label>
<textarea class="tinymce text-editor" id="post-enrollment-email"></textarea>
<span class="tip tip-stacked">${_("This email will be sent to any student who enrolls in the course after its start date")}</span>
<ul class="list-actions">
<li class="action-item">
<a title="${_('Send me a copy of this via email')}"
href="" class="action action-primary">
${_("Send me a test email")}</a>
</li>
</ul>
</li>
<li class="field image" id="field-course-image"> <li class="field image" id="field-course-image">
<label>${_("Course Image")}</label> <label>${_("Course Image")}</label>
<div class="current current-course-image"> <div class="current current-course-image">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment