'Post function for updating the email opt in preference.
Allows the modification or creation of the email opt in preference at an
organizational level.
Args:
request (Request): The request should contain the following POST parameters:
* course_id: The slash separated course ID. Used to determine the organization
for this preference setting.
* email_opt_in: "True" or "False" to determine if the user is opting in for emails from
this organization. If the string does not match "True" (case insensitive) it will
assume False.'

@method_decorator(require_post_params(['course_id', 'email_opt_in']))
@method_decorator(ensure_csrf_cookie)
def post(self, request):

    course_id = request.data['course_id']
    try:
        org = locator.CourseLocator.from_string(course_id).org
    except InvalidKeyError:
        return HttpResponse(status=400, content="No    course    '{course_id}'    found".format(course_id=course_id), content_type='text/plain')
    email_opt_in = (request.data['email_opt_in'].lower() == 'true')
    update_email_opt_in(request.user, org, email_opt_in)
    return HttpResponse(status=status.HTTP_200_OK)
