fix: join batch, removed code revision, redirects for other pages if batch missing
This commit is contained in:
@@ -4,3 +4,5 @@ from . import utils
|
||||
def get_context(context):
|
||||
utils.get_common_context(context)
|
||||
context.messages = context.batch.get_messages()
|
||||
if not context.batch:
|
||||
utils.redirect_to_lesson(context.course)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% set invite_link = frappe.utils.get_url() + "/courses/" + course.name + "/" + batch.name + "/join" %}
|
||||
{% set invite_link = frappe.utils.get_url() + "/courses/" + course.name + "/join?batch=" + batch.name %}
|
||||
<div class="container mt-5">
|
||||
{{ widgets.BatchTabs(course=course, batch=batch) }}
|
||||
<!-- <div>
|
||||
@@ -34,7 +34,7 @@
|
||||
<h3> Invite Members </h3>
|
||||
<a href="" class="" id="invite-link" data-link="{{ invite_link }}">Get Batch Invitation
|
||||
Link</a>
|
||||
<small id="copy-message" class="text-muted pull-right" style="display: none;">Copied to Clipboard.</small>
|
||||
<small id="copy-message" class="text-muted" style="display: none;">Copied to Clipboard.</small>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
$("#copy-message").slideDown(function () {
|
||||
setTimeout(function () {
|
||||
$("#copy-message").slideUp();
|
||||
}, 5000);
|
||||
}, 2000);
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
@@ -3,3 +3,5 @@ from . import utils
|
||||
|
||||
def get_context(context):
|
||||
utils.get_common_context(context)
|
||||
if not context.batch:
|
||||
utils.redirect_to_lesson(context.course)
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
<div class='page-card-head'>
|
||||
<span class='indicator blue password-box'>Login Required</span>
|
||||
</div>
|
||||
<div class=''>Please log in to confirm to join the course {{ batch.course_title }}.</div>
|
||||
<div class=''>Please log in to confirm joining the course {{ batch.course_title }}.</div>
|
||||
<a type="submit" id="login" class="btn btn-primary w-100"
|
||||
href="/login?redirect-to=/courses/{{ batch.course }}/{{ batch.name }}/join">{{_("Login")}}</a>
|
||||
href="/login?redirect-to=/courses/{{ batch.course }}/join?batch={{ batch.name }}">{{_("Login")}}</a>
|
||||
</div>
|
||||
|
||||
{% elif already_a_member %}
|
||||
@@ -26,7 +26,7 @@
|
||||
</div>
|
||||
<div class=''>You are already a member of the batch {{ batch.title }} for the course {{ batch.course_title }}.
|
||||
</div>
|
||||
<a type="submit" id="batch-home" class="btn btn-primary w-100" href="/courses/{{batch.course}}/{{batch.name}}/home">{{_("Go to Batch Home")}}</a>
|
||||
<a type="submit" id="batch-home" class="btn btn-primary w-100" href="">{{_("Go to Batch Home")}}</a>
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
@@ -38,23 +38,20 @@
|
||||
<div>Please provide your confirmation to be a part of the batch {{ batch.title }} for the course
|
||||
{{ batch.course_title }}.
|
||||
</div>
|
||||
<a type="submit" id="confirm" class="btn btn-primary w-100" data-batch="{{ batch.name | urlencode }}"
|
||||
data-course="{{ batch.course | urlencode }}">{{_("Confirm")}}</a>
|
||||
<a type="submit" id="confirm" class="btn btn-primary w-100">{{_("Confirm")}}</a>
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block script %}
|
||||
<script>
|
||||
frappe.ready(() => {
|
||||
var confirm_element = $("#confirm");
|
||||
var batch = decodeURIComponent(confirm_element.attr("data-batch"));
|
||||
var course = decodeURIComponent(confirm_element.attr("data-course"));
|
||||
|
||||
confirm_element.click((e) => {
|
||||
frappe.ready(() => {
|
||||
$("#confirm").click((e) => {
|
||||
frappe.call({
|
||||
"method": "community.lms.doctype.lms_batch_membership.lms_batch_membership.create_membership",
|
||||
"args": {
|
||||
"batch": batch
|
||||
"batch": "{{ batch.name }}"
|
||||
},
|
||||
"callback": (data) => {
|
||||
if (data.message == "OK") {
|
||||
@@ -63,12 +60,25 @@
|
||||
clear: true
|
||||
});
|
||||
setTimeout(function () {
|
||||
window.location.href = "/courses/" + course + "/" + batch + "/home";
|
||||
window.location.href = "/courses/{{ batch.course }}/home";
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
$("#batch-home").click((e) => {
|
||||
frappe.call({
|
||||
method: "community.lms.doctype.lms_batch_membership.lms_batch_membership.update_current_membership",
|
||||
args: {
|
||||
"batch": "{{ batch.name }}",
|
||||
"course": "{{ batch.course}}"
|
||||
},
|
||||
callback: (data) => {
|
||||
window.location.href = "/courses/{{ batch.course }}/home"
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -3,4 +3,5 @@ from . import utils
|
||||
|
||||
def get_context(context):
|
||||
utils.get_common_context(context)
|
||||
print(context.members[0].bio)
|
||||
if not context.batch:
|
||||
utils.redirect_to_lesson(context.course)
|
||||
|
||||
@@ -25,3 +25,6 @@ def get_common_context(context):
|
||||
def get_livecode_url():
|
||||
return frappe.db.get_single_value("LMS Settings", "livecode_url")
|
||||
|
||||
def redirect_to_lesson(course, index_="1.1"):
|
||||
frappe.local.flags.redirect_location = course.get_learn_url(index_)
|
||||
raise frappe.Redirect
|
||||
|
||||
@@ -96,6 +96,8 @@
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div class="mt-5 upcoming">There are no Upcoming Batches for this course currently.</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
Reference in New Issue
Block a user