'Redirect the user to a more appropriate page if necessary.
In some cases, a user may visit this page with
verification / enrollment / payment state that
we don\'t anticipate.  For example, a user may unenroll
from the course after paying for it, then visit the
"verify now" page to complete verification.
When this happens, we try to redirect the user to
the most appropriate page.
Arguments:
message (string): The messaging of the page.  Should be a key
in `MESSAGES`.
already_verified (bool): Whether the user has submitted
a verification request recently.
already_paid (bool): Whether the user is enrolled in a paid
course mode.
is_enrolled (bool): Whether the user has an active enrollment
in the course.
course_key (CourseKey): The key for the course.
Returns:
HttpResponse or None'

def _redirect_if_necessary(self, message, already_verified, already_paid, is_enrolled, course_key, user_is_trying_to_pay, user, sku):

    url = None
    course_kwargs = {'course_id': unicode(course_key)}
    if (already_verified and already_paid):
        if (message != self.PAYMENT_CONFIRMATION_MSG):
            url = reverse('dashboard')
    elif (message in [self.VERIFY_NOW_MSG, self.VERIFY_LATER_MSG, self.PAYMENT_CONFIRMATION_MSG]):
        if is_enrolled:
            if (not already_paid):
                url = reverse('verify_student_upgrade_and_verify', kwargs=course_kwargs)
        else:
            url = reverse('verify_student_start_flow', kwargs=course_kwargs)
    elif (message == self.UPGRADE_MSG):
        if is_enrolled:
            if already_paid:
                url = reverse('verify_student_verify_now', kwargs=course_kwargs)
        else:
            url = reverse('verify_student_start_flow', kwargs=course_kwargs)
    if (user_is_trying_to_pay and self._get_user_active_status(user) and (not already_paid)):
        ecommerce_service = EcommerceService()
        if ecommerce_service.is_enabled(user):
            url = ecommerce_service.get_checkout_page_url(sku)
    if (url is not None):
        url = self.add_utm_params_to_url(url)
        return redirect(url)
