2019-06-05 07:59:51 +00:00
|
|
|
{% macro hero(title, description, has_access, back) %}
|
2019-05-21 06:35:19 +00:00
|
|
|
<div class='container pb-5'>
|
2019-06-05 07:59:51 +00:00
|
|
|
<div class="mb-3">
|
|
|
|
<a href="{{ back.url }}" class="text-muted">
|
2020-06-22 05:36:12 +00:00
|
|
|
{{_('Back to')}} {{ _(back.name) }}
|
2019-06-05 07:59:51 +00:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<h1>{{ title }}</h1>
|
2019-06-05 12:19:42 +00:00
|
|
|
<p class='lead' style="max-width: 100%;">{{ description or ''}}</p>
|
2019-05-21 06:35:19 +00:00
|
|
|
<p class="mt-4">
|
2019-05-29 07:41:34 +00:00
|
|
|
{% if frappe.session.user == 'Guest' %}
|
2020-06-22 05:36:12 +00:00
|
|
|
<a id="signup" class="btn btn-primary btn-lg" href="/login#signup">{{_('Sign Up')}}</a>
|
2019-05-30 11:05:15 +00:00
|
|
|
{% elif not has_access %}
|
2022-02-21 17:23:29 +00:00
|
|
|
<button id="enroll" class="btn btn-primary btn-lg" onclick="enroll()">{{_('Enroll')}}</button>
|
2019-05-29 07:41:34 +00:00
|
|
|
{% endif %}
|
2019-05-21 06:35:19 +00:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{% block script %}
|
|
|
|
<script type="text/javascript">
|
2019-05-30 11:05:15 +00:00
|
|
|
frappe.ready(() => {
|
|
|
|
btn = document.getElementById('enroll');
|
|
|
|
})
|
|
|
|
|
2019-05-29 13:08:09 +00:00
|
|
|
function enroll() {
|
2019-05-30 11:05:15 +00:00
|
|
|
let params = frappe.utils.get_query_params()
|
2019-05-30 12:34:36 +00:00
|
|
|
|
2019-05-30 11:05:15 +00:00
|
|
|
let btn = document.getElementById('enroll');
|
|
|
|
|
|
|
|
let opts = {
|
|
|
|
method: 'erpnext.education.utils.enroll_in_program',
|
|
|
|
args: {
|
|
|
|
program_name: params.program
|
2022-02-21 17:23:29 +00:00
|
|
|
},
|
|
|
|
freeze: true,
|
|
|
|
freeze_message: __('Enrolling...')
|
2019-05-30 11:05:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
frappe.call(opts).then(res => {
|
|
|
|
let success_dialog = new frappe.ui.Dialog({
|
|
|
|
title: __('Success'),
|
2022-03-10 04:36:07 +00:00
|
|
|
primary_action_label: __('OK'),
|
2022-02-21 17:23:29 +00:00
|
|
|
primary_action: function() {
|
|
|
|
window.location.reload();
|
2019-05-30 11:05:15 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
success_dialog.show();
|
2022-03-10 04:36:07 +00:00
|
|
|
success_dialog.set_message(__('You have successfully enrolled for the program.'));
|
2019-05-30 11:05:15 +00:00
|
|
|
})
|
2019-05-29 13:08:09 +00:00
|
|
|
}
|
2019-05-21 06:35:19 +00:00
|
|
|
</script>
|
|
|
|
{% endblock %}
|
|
|
|
{% endmacro %}
|