<%page args="credit_status" />
<%!
    import datetime
    import pytz
    from django.utils.translation import ugettext as _
    from util.date_utils import get_default_time_display
%>
<%namespace name='static' file='../static_content.html'/>

% if credit_status["eligible"]:
    <div class="message message-status is-shown credit-message">
    % if credit_status["error"]:
        <p class="message-copy credit-error-msg">
            ${_("An error occurred with this transaction. For help, contact {support_email}.").format(
                support_email=u'<a href="mailto:{address}">{address}</a>'.format(
                    address=settings.DEFAULT_FEEDBACK_EMAIL
                )
            )}
        </p>
    % elif not credit_status["purchased"]:
        <p class="credit-eligibility-msg">
            % if credit_status["deadline"] < datetime.datetime.now(pytz.UTC) + datetime.timedelta(days=30):
                ${_("The opportunity to purchase credit for this course expires on {deadline}. You've worked hard - don't miss out!").format(deadline=get_default_time_display(credit_status["deadline"]))}
            % else:
                ${_("Congratulations - you have met the requirements for credit in this course!")}
            % endif
        </p>
        <div class="purchase_credit">
            ## TODO: set the URL for the link to the provider selection page on the E-Commerce service
            <a class="btn purchase-credit-btn" href="#" target="_blank" data-course-key="${credit_status["course_key"]}">${_("Purchase Course Credit")}</a>
        </div>
    % elif credit_status["request_status"] in [None, "pending"]:
        <p class="message-copy credit-request-pending-msg">
        ${_("Thanks for your payment! We are currently processing your course credit. You'll see a message here when the transaction is complete. For more information, see {provider_link}.").format(
                provider_link=u'<a href="{provider_url}">{provider_name}</a>'.format(
                    provider_url=credit_status["provider_status_url"],
                    provider_name=credit_status["provider_name"],
                )
            )
        }
        </p>
    % elif credit_status["request_status"] == "approved":
        <p class="message-copy credit-request-approved-msg">
        ${_("Congratulations - you have received credit for this course! For more information, see {provider_link}.").format(
                provider_link=u'<a href="{provider_url}">{provider_name}</a>'.format(
                    provider_url=credit_status["provider_status_url"],
                    provider_name=credit_status["provider_name"],
                )
            )
        }
        </p>
    % elif credit_status["request_status"] == "rejected":
        <p class="message-copy credit-request-rejected-msg">
        ${_("{provider_name} has declined your request for course credit. For more information, contact {provider_link}.").format(
                provider_name=credit_status["provider_name"],
                provider_link=u'<a href="{provider_url}">{provider_name}</a>'.format(
                    provider_url=credit_status["provider_status_url"],
                    provider_name=credit_status["provider_name"],
                )
            )
        }
        </p>
    % endif
    </div>
% endif
