Implemented Enrollment Email Feature

There was a need to notify students via email upon enrolling in a course, since
they were confused that they did not receive any confirmation of their course
enrollments.

Since the scope of this feature is pretty narrow (confined to course
enrollments only), this commit does not focus on building a general
email-notification system.

================ Changes to the Model =============

This commit adds two new fields(booleans) to the Course model:

	- enable_enrollment_email
	- enable_default_enrollment_email

that allows course administrators to enable / disable the enrollment emailing
feature, and  upon enabling, decide whether they want to use the default
enrollment email template.

These new fields are linked to the CourseDetails object, so that course
administrators can edit these two flag settings in the Settings -
Schedule&Details Tab through a friendly UI.

This commit also adds the following four new documents to CourseDetails:

	- pre_enrollment_email
	- pre_enrollment_email_subject
	- post_enrollment_email
	- post_enrollment_email_subject

================ Changes to the controller ===============

This commit adds notify_enrollment_by_email function to:

	- common/djangoapps/student/views.py

and calls it from the change_enrollment controller that receives requests upon
a student's clicking of the Registration button. It is called after enrolling
the student to the course in the database.

This function first checks to make sure that it's not in automated testing env,
and that enable_enrollment_email field of the specified course is set to True.

Then it checkes whether the enable_default_enrollment_email field is set to
True or not, and handles the email message accordingly by either:

	1) Pulling the default static enrollment_email template
	2) Using the template specified by the Course Admin

When using the configured template, it checks if the course has already started
or not and appropriately chooses between pre_enrollment_email & subject and
post_enrollment_email & subject.

At the end of the function, it returns a json object specifying whether the
emailing was successful or not, so that the students are notified of the
error, and for unit testing.

================ Changes to the view (frontend ) =========

This commit applies a few changes to the front-end javascript:

	- cms/static/js/views/settings/main.js

so that upon receiving a modified CourseDetail Object via ajax,
the template gets updated appropriately, and also so that it
makes put ajax requests back to the server when the Course Admin applies
changes to enrollment email settings.

================ Unit Tests ============================

The written unit tests are very basic, and is done by checking the json
response object returned by the notify_enrollment_by_email method.

========================================================
Implemented Enrollment Email Feature

There was a need to notify students via email upon enrolling in a course, since
they were confused that they did not receive any confirmation of their course
enrollments.

Since the scope of this feature is pretty narrow (confined to course
enrollments only), this commit does not focus on building a general
email-notification system.

================ Changes to the Model =============

This commit adds two new fields(booleans) to the Course model:

	- enable_enrollment_email
	- enable_default_enrollment_email

that allows course administrators to enable / disable the enrollment emailing
feature, and  upon enabling, decide whether they want to use the default
enrollment email template.

These new fields are linked to the CourseDetails object, so that course
administrators can edit these two flag settings in the Settings -
Schedule&Details Tab through a friendly UI.

This commit also adds the following four new documents to CourseDetails:

	- pre_enrollment_email
	- pre_enrollment_email_subject
	- post_enrollment_email
	- post_enrollment_email_subject

================ Changes to the controller ===============

This commit adds notify_enrollment_by_email function to:

	- common/djangoapps/student/views.py

and calls it from the change_enrollment controller that receives requests upon
a student's clicking of the Registration button. It is called after enrolling
the student to the course in the database.

This function first checks to make sure that it's not in automated testing env,
and that enable_enrollment_email field of the specified course is set to True.

Then it checkes whether the enable_default_enrollment_email field is set to
True or not, and handles the email message accordingly by either:

	1) Pulling the default static enrollment_email template
	2) Using the template specified by the Course Admin

When using the configured template, it checks if the course has already started
or not and appropriately chooses between pre_enrollment_email & subject and
post_enrollment_email & subject.

At the end of the function, it returns a json object specifying whether the
emailing was successful or not, so that the students are notified of the
error, and for unit testing.

================ Changes to the view (frontend ) =========

This commit applies a few changes to the front-end javascript:

	- cms/static/js/views/settings/main.js

so that upon receiving a modified CourseDetail Object via ajax,
the template gets updated appropriately, and also so that it
makes put ajax requests back to the server when the Course Admin applies
changes to enrollment email settings.

================ Unit Tests ============================

The written unit tests are very basic, and is done by checking the json
response object returned by the notify_enrollment_by_email method.

bugfix: line 69 & 75 in course_details.py. course->course_details

added update_user_by_email to CourseEnrollment Model. Still implementing

fixed a few indentation errors with vim

pushing enrollment email functionality from model to the view

added email boolean to course_details, modified courseware/courses.py to be able to throw pre & post_enrollment_email attributes

course enrollment email functionality implemented. TODO: What to put as the from_address / subject. + access enable_enrollment_email column in the CourseDetails Object

changed datetime calculation method to use given function from CourseDescriptor Objectw

added enable_enrollment_email field to the course descriptor & course details. Changing the frontend to store the value.

fixed frontend to send appropriate ajax calls. Not being saved correctly tho...

added settings option to the enable_enrollment_email in course_module.py. editted course_details to turn dirty flag to true upon receiving enable_enrollment_email edit flag

got rid of comments

cleaned up modules, ran module tests & passed all

adding feature: use default enrollment emails. Changed front-end. TODO: add fields to course & course details models

implemented default course enrollment notification settings & views

writing unit_tests

finished writing up unit tests for enrollment_emails

applied some changes to thes test_email

fixing with Joe's styling guide :)

changed url managing from hardcoding to reverse()

views changed..?

fetched from upstream master

passing all tests

applying sef's PR comment to break lines at courses.py