fix: dashboard links, web form redirects and patch for status

This commit is contained in:
Jannat Patel
2022-03-15 16:51:39 +05:30
parent aa9ef65375
commit 27e1aec001
18 changed files with 99 additions and 46 deletions

View File

@@ -29,8 +29,14 @@
{% else %} background-color: var(--gray-200) {% endif %}">
<div class="container pt-10 pb-10">
{% if is_instructor(course.name) %}
<a class="button is-default button-links pull-right" href="/lesson?new=1"> {{ _("New Lesson") }} </a>
<a class="button is-default button-links pull-right mr-2" href="/chapter?new=1"> {{ _("New Chapter") }} </a>
<a class="button is-default button-links pull-right" href="/lesson">
<svg class="icon icon-sm mr-1"><use href="#icon-add"></use></svg>
{{ _("Add Lesson") }}
</a>
<a class="button is-default button-links pull-right mr-2" href="/chapter">
<svg class="icon icon-sm mr-1"><use href="#icon-add"></use></svg>
{{ _("Add Chapter") }}
</a>
<a class="button is-default button-links pull-right mr-2" href="/course?name={{ course.name }}"> {{ _("Edit") }} </a>
{% endif %}
{{ BreadCrumb(course) }}
@@ -131,9 +137,15 @@
<div class="course-home-headings"> {{ course.title }} </div>
<div id="interest-alert" class="{% if not is_user_interested %} hide {% endif %}">
You have opted to be notified for this course. You will receive an email when the course becomes available.
{{ _("You have opted to be notified for this course. You will receive an email when the course becomes available.") }}
</div>
{% if course.status == "Under Review" %}
<div>
{{ _("Your course is currently under review. Once the review is complete, the System Admins will publish it on the website.") }}
</div>
{% endif %}
{% if get_lessons(course.name) | length %}
<div class="mt-3 mb-4">
<img class="mr-3" src="/assets/school/icons/book.svg">
@@ -162,14 +174,13 @@
{% set lesson_index = get_lesson_index(membership.current_lesson) if membership and
membership.current_lesson
else '1.1' %}
{% if show_start_learing_cta %}
<div class="button wide-button is-primary join-batch" data-course="{{ course.name | urlencode }}">
{{ _("Start Learning") }}
<img class="ml-2" src="/assets/school/icons/white-arrow.svg" />
</div>
{% elif is_instructor(course.name) and not course.is_published and status != "Ready for Review" %}
{% elif is_instructor(course.name) and not course.is_published and course.status != "Under Review" %}
<div class="button wide-button is-primary" id="submit-for-review" data-course="{{ course.name | urlencode }}">
{{ _("Submit for Review") }}
<img class="ml-2" src="/assets/school/icons/white-arrow.svg" />

View File

@@ -274,6 +274,7 @@ const submit_for_review = (e) => {
Please add chapters and lessons to your course before you submit it for review.`));
} else if (data.message == "OK") {
frappe.msgprint(__("Your course has been submitted for review."))
window.location.reload();
}
}
})

View File

@@ -13,7 +13,7 @@ def get_context(context):
course = frappe.db.get_value("LMS Course", course_name,
["name", "title", "image", "short_introduction", "description", "is_published", "upcoming",
"disable_self_learning", "video_link", "enable_certification"],
"disable_self_learning", "video_link", "enable_certification", "status"],
as_dict=True)
related_courses = frappe.get_all("Related Courses", {"parent": course.name}, ["course"])
@@ -33,7 +33,7 @@ def get_context(context):
if context.course.upcoming:
context.is_user_interested = get_user_interest(context.course.name)
context.restriction = check_profile_restriction()
context.show_start_learing_cta = show_start_learing_cta(course, membership)
context.show_start_learing_cta = show_start_learing_cta(course, membership, context.restriction)
context.metatags = {
"title": course.title,
"image": course.image,
@@ -48,5 +48,5 @@ def get_user_interest(course):
"user": frappe.session.user
})
def show_start_learing_cta(course, membership):
return not course.disable_self_learning and not membership and not course.upcoming and not restriction.restrict and not is_instructor(course.name)
def show_start_learing_cta(course, membership, restriction):
return not course.disable_self_learning and not membership and not course.upcoming and not restriction.get("restrict") and not is_instructor(course.name)

View File

@@ -3,23 +3,32 @@
{% endblock %}
{% block content %}
{% set portal_course_creation = frappe.db.get_single_value("LMS Settings", "portal_course_creation") %}
<div class="common-page-style dashboard">
<div class="container">
<ul class="nav mb-8">
{% if portal_course_creation %}
<a class="button is-default button-links pull-right hide" id="create-course-link" href="/course">
<svg class="icon icon-sm mr-1"><use href="#icon-add"></use></svg>
{{ _("New Course")}}
</a>
{% endif %}
<ul class="nav" id="courses-tab">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#courses-enrolled"> {{ _("Courses Enrolled") }} </a>
</li>
{% if frappe.db.get_single_value("LMS Settings", "portal_course_creation") %}
{% if portal_course_creation %}
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#courses-created">{{ _("Courses Created") }}</a>
<a class="nav-link" data-toggle="tab" href="#courses-created">{{ _("Courses Created") }}
</a>
</li>
{% endif %}
</ul>
<div class="border-bottom mb-4"></div>
<div class="tab-content">
<div class="tab-pane active" id="courses-enrolled" role="tabpanel" aria-labelledby="courses-enrolled">
{% include "school/lms/web_template/courses_enrolled/courses_enrolled.html" %}
</div>
{% if frappe.db.get_single_value("LMS Settings", "portal_course_creation") %}
{% if portal_course_creation %}
<div class="tab-pane fade" id="courses-created" role="tabpanel" aria-labelledby="courses-created">
{% include "school/templates/courses_created.html" %}
</div>
@@ -29,4 +38,12 @@
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script>
frappe.ready(() => {
$('#courses-tab a[data-toggle="tab"]').on('shown.bs.tab', (e) => {
let link = $("#create-course-link");
$(e.currentTarget).attr("href") == "#courses-created" ? link.removeClass("hide") : link.addClass("hide");
});
})
</script>
{% endblock %}

View File

@@ -29,7 +29,7 @@
{% macro ProfileBanner(member) %}
{% set cover_image = member.cover_image if member.cover_image else "/assets/school/images/profile-banner.png" %}
{% set enrollment = get_course_membership(member_type="Student") | length %}
{% set enrollment = get_course_membership(frappe.session.user, member_type="Student") | length %}
{% set enrollment_suffix = _("Courses") if enrollment > 1 else _("Course") %}
<div class="container">
<div class="profile-banner" style="background-image: url({{ cover_image }})">