fix: batch registration button conditions

This commit is contained in:
Jannat Patel
2024-03-07 10:21:18 +05:30
parent a5d000f702
commit 4cc27adb8b

View File

@@ -1,246 +1,214 @@
{% extends "lms/templates/lms_base.html" %} {% extends "lms/templates/lms_base.html" %} {% block title %} {{
{% block title %} _(batch_info.title) }} {% endblock %} {% block page_content %}
{{ _(batch_info.title) }}
{% endblock %}
{% block page_content %}
<div class="common-page-style lms-page-style"> <div class="common-page-style lms-page-style">
{{ BatchHeader(batch_info) }} {{ BatchHeader(batch_info) }}
<div class="container"> <div class="container">
{{ BatchOverlay(batch_info, courses, students) }} {{ BatchOverlay(batch_info, courses, students) }}
<div class="pt-10"> <div class="pt-10">
{{ BatchDetails(batch_info) }} {{ BatchDetails(batch_info) }} {{ CourseList(courses) }}
{{ CourseList(courses) }} </div>
</div>
</div> </div>
{{ BatchDetailsRaw() }} {{ BatchDetailsRaw() }}
</div> </div>
{% endblock %} {% endblock %} {% macro BatchHeader(batch_info) %}
{% macro BatchHeader(batch_info) %}
<div class="course-head-container"> <div class="course-head-container">
<div class="container"> <div class="container">
<div class="course-card-wide"> <div class="course-card-wide">
{{ BreadCrumb(batch_info) }} {{ BreadCrumb(batch_info) }} {{ BatchHeaderDetails(batch_info,
{{ BatchHeaderDetails(batch_info, courses, students) }} courses, students) }}
</div> </div>
</div> </div>
</div> </div>
{% endmacro %} {% endmacro %} {% macro BreadCrumb(batch_info) %}
{% macro BreadCrumb(batch_info) %}
<article class="mb-8"> <article class="mb-8">
<a class="dark-links" href="/batches"> <a class="dark-links" href="/batches"> {{ _("All Batches") }} </a>
{{ _("All Batches") }} <img class="" src="/assets/lms/icons/chevron-right.svg" />
</a> <span class="breadcrumb-destination"> {{ _("Batch Details") }} </span>
<img class="" src="/assets/lms/icons/chevron-right.svg">
<span class="breadcrumb-destination">
{{ _("Batch Details") }}
</span>
</article> </article>
{% endmacro %} {% endmacro %} {% macro BatchHeaderDetails(batch_info, courses, students) %}
<div class="class-details" data-batch="{{ batch_info.name }}">
<div class="page-title">{{ batch_info.title }}</div>
{% macro BatchHeaderDetails(batch_info, courses, students) %} <div class="">{{ batch_info.description }}</div>
<div class="class-details" data-batch="{{ batch_info.name }}">
<div class="page-title"> <div class="mt-8">
{{ batch_info.title }} <svg class="icon icon-sm">
</div> <use href="#icon-calendar"></use>
</svg>
<span>
{{ frappe.utils.format_date(batch_info.start_date, "long") }}
</span>
{% if batch_info.start_date != batch_info.end_date %}
<span>
- {{ frappe.utils.format_date(batch_info.end_date, "long") }}
</span>
{% endif %}
</div>
<div class=""> {% if batch_info.start_time and batch_info.end_time %}
{{ batch_info.description }} <div class="mt-1">
</div> <svg class="icon icon-sm">
<use href="#icon-clock"></use>
<div class="mt-8"> </svg>
<svg class="icon icon-sm"> <span>
<use href="#icon-calendar"></use> {{ frappe.utils.format_time(batch_info.start_time, "hh:mm a") }} -
</svg> </span>
<span> <span>
{{ frappe.utils.format_date(batch_info.start_date, "long") }} {{ frappe.utils.format_time(batch_info.end_time, "hh:mm a") }}
</span> </span>
{% if batch_info.start_date != batch_info.end_date %} </div>
<span> {% endif %}
- {{ frappe.utils.format_date(batch_info.end_date, "long") }} </div>
</span> {% endmacro %} {% macro BatchOverlay(batch_info, courses, students) %}
{% endif %}
</div>
{% if batch_info.start_time and batch_info.end_time %}
<div class="mt-1">
<svg class="icon icon-sm">
<use href="#icon-clock"></use>
</svg>
<span>
{{ frappe.utils.format_time(batch_info.start_time, "hh:mm a") }} -
</span>
<span>
{{ frappe.utils.format_time(batch_info.end_time, "hh:mm a") }}
</span>
</div>
{% endif %}
</div>
{% endmacro %}
{% macro BatchOverlay(batch_info, courses, students) %}
<div class="course-overlay-card class-overlay"> <div class="course-overlay-card class-overlay">
<div class="course-overlay-content">
{% if batch_info.seat_count %} {% if seats_left %}
<div class="indicator-pill green pull-right">
{{ _("Seats Available") }}: {{ seats_left }}
</div>
{% else %}
<div class="indicator-pill red pull-right">
{{ _("No seats left") }}
</div>
{% endif %} {% endif %} {% if batch_info.paid_batch %}
<div class="bold-heading">
{{ frappe.utils.fmt_money(batch_info.amount, 0, batch_info.currency)
}}
</div>
{% endif %}
<div class="course-overlay-content"> <div class="vertically-center mt-2">
<svg class="icon icon-md mr-1">
<use href="#icon-education"></use>
</svg>
{{ courses | length }} {{ _("Courses") }}
</div>
{% if batch_info.seat_count %} <div class="mt-2">
{% if seats_left %} <svg class="icon icon-sm">
<div class="indicator-pill green pull-right"> <use href="#icon-calendar"></use>
{{ _("Seats Available") }}: {{ seats_left }} </svg>
</div> <span>
{% else %} {{ frappe.utils.format_date(batch_info.start_date, "long") }}
<div class="indicator-pill red pull-right"> </span>
{{ _("No seats left") }}
</div>
{% endif %}
{% endif %}
{% if batch_info.paid_batch %}
<div class="bold-heading">
{{ frappe.utils.fmt_money(batch_info.amount, 0, batch_info.currency) }}
</div>
{% endif %}
<div class="vertically-center mt-2">
<svg class="icon icon-md mr-1">
<use href="#icon-education"></use>
</svg>
{{ courses | length }} {{ _("Courses") }}
</div>
<div class="mt-2">
<svg class="icon icon-sm">
<use href="#icon-calendar"></use>
</svg>
<span>
{{ frappe.utils.format_date(batch_info.start_date, "long") }}
</span>
{% if batch_info.start_date != batch_info.end_date %} {% if batch_info.start_date != batch_info.end_date %}
<span> <span>
- {{ frappe.utils.format_date(batch_info.end_date, "long") }} - {{ frappe.utils.format_date(batch_info.end_date, "long") }}
</span> </span>
{% endif %} {% endif %}
</div> </div>
{% if batch_info.start_time and batch_info.end_time %} {% if batch_info.start_time and batch_info.end_time %}
<div class="mt-2"> <div class="mt-2">
<svg class="icon icon-sm"> <svg class="icon icon-sm">
<use href="#icon-clock"></use> <use href="#icon-clock"></use>
</svg> </svg>
<span> <span>
{{ frappe.utils.format_time(batch_info.start_time, "hh:mm a") }} - {{ frappe.utils.format_time(batch_info.start_time, "hh:mm a") }}
</span> -
<span> </span>
{{ frappe.utils.format_time(batch_info.end_time, "hh:mm a") }} <span>
</span> {{ frappe.utils.format_time(batch_info.end_time, "hh:mm a") }}
</div> </span>
{% endif %} </div>
{% endif %}
<div class="mt-2"> <div class="mt-2">
{% if is_moderator or is_evaluator %} {% if is_moderator or is_evaluator %}
<a class="btn btn-primary wide-button" href="/batches/{{ batch_info.name }}"> <a
{{ _("Manage Batch") }} class="btn btn-primary wide-button"
</a> href="/batches/{{ batch_info.name }}"
{% elif batch_info.paid_batch %} >
<a class="btn btn-primary wide-button {% if batch_info.seat_count and not seats_left %} hide {% endif %}" {{ _("Manage Batch") }}
href="/billing/batch/{{ batch_info.name }}"> </a>
{{ _("Register Now") }} {% elif batch_info.paid_batch and batch_info.start_date >
</a> frappe.utils.getdate() %}
{% elif batch_info.allow_self_enrollment and batch_info.seat_count and seats_left %} <a
<button class="btn btn-primary wide-button enroll-batch"> class="btn btn-primary wide-button {% if batch_info.seat_count and not seats_left %} hide {% endif %}"
{{ _("Enroll Now") }} href="/billing/batch/{{ batch_info.name }}"
</button> >
{% else %} {{ _("Register Now") }}
<div class="alert alert-info"> </a>
{{ _("To join this batch, please contact the Administrator.") }} {% elif batch_info.allow_self_enrollment and batch_info.seat_count
</div> and seats_left and batch_info.start_date > frappe.utils.getdate() %}
{% endif %} <button class="btn btn-primary wide-button enroll-batch">
</div> {{ _("Enroll Now") }}
{% if is_moderator %} </button>
<div class="mt-2"> {% else %}
<div class="btn btn-secondary wide-button" id="create-batch"> <div class="alert alert-info">
{{ _("Edit") }} {{ _("To join this batch, please contact the Administrator.") }}
</div> </div>
</div> {% endif %}
{% endif %} </div>
</div> {% if is_moderator %}
<div class="mt-2">
<div class="btn btn-secondary wide-button" id="create-batch">
{{ _("Edit") }}
</div>
</div>
{% endif %}
</div>
</div> </div>
{% endmacro %} {% endmacro %} {% macro BatchDetails(batch_info) %}
<div class="batch-details">{{ batch_info.batch_details }}</div>
{% endmacro %} {% macro CourseList(courses) %} {% if courses | length or
{% macro BatchDetails(batch_info) %} is_moderator %}
<div class="batch-details">
{{ batch_info.batch_details }}
</div>
{% endmacro %}
{% macro CourseList(courses) %}
{% if courses | length or is_moderator %}
<div class="batch-course-list"> <div class="batch-course-list">
<div class="align-center flex">
<div class="page-title">{{ _("Courses") }}</div>
{% if is_moderator %}
<button class="btn btn-default btn-sm btn-add-course ml-4">
{{ _("Add Course") }}
</button>
{% endif %}
</div>
<div class="flex align-center"> {% if courses | length %}
<div class="page-title">
{{ _("Courses") }}
</div>
{% if is_moderator %}
<button class="btn btn-default btn-sm btn-add-course ml-4">
{{ _("Add Course") }}
</button>
{% endif %}
</div>
{% if courses | length %}
<div class="cards-parent mt-2"> <div class="cards-parent mt-2">
{% for course in courses %} {% for course in courses %}
<div class="h-100"> <div class="h-100">
{% if is_moderator %} {% if is_moderator %}
<div class="card-buttons"> <div class="card-buttons">
<button class="btn icon-btn btn-default btn-edit-course" <button
data-name="{{ course.batch_course }}" data-course="{{ course.name }}" class="btn icon-btn btn-default btn-edit-course"
{% if course.evaluator %} data-evaluator="{{ course.evaluator }}" {% endif %}> data-name="{{ course.batch_course }}"
<svg class="icon icon-sm"> data-course="{{ course.name }}"
<use href="#icon-edit"></use> {%
</svg> if
</button> course.evaluator
<button class="btn icon-btn btn-default btn-remove-course ml-2" data-course="{{ course.name }}"> %}
<svg class="icon icon-sm"> data-evaluator="{{ course.evaluator }}"
<use href="#icon-delete"></use> {%
</svg> endif
</button> %}
</div> >
{% endif %} <svg class="icon icon-sm">
{{ widgets.CourseCard(course=course, read_only=False) }} <use href="#icon-edit"></use>
</svg>
</button>
<button
class="btn icon-btn btn-default btn-remove-course ml-2"
data-course="{{ course.name }}"
>
<svg class="icon icon-sm">
<use href="#icon-delete"></use>
</svg>
</button>
</div>
{% endif %} {{ widgets.CourseCard(course=course, read_only=False) }}
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
{% else %} {% else %}
<div class=""> <div class="">{{ _("No courses") }}</div>
{{ _("No courses") }}
</div>
{% endif %} {% endif %}
</div> </div>
{% endif %} {% endif %} {% endmacro %} {% macro BatchDetailsRaw() %} {% if
{% endmacro %} batch_info.batch_details_raw %}
<div class="mt-10 pt-10">{{ batch_info.batch_details_raw }}</div>
{% endif %} {% endmacro %} {%- block script %} {{ super() }} {% if is_moderator
{% macro BatchDetailsRaw() %} %}
{% if batch_info.batch_details_raw %} <script>
<div class="mt-10 pt-10"> let batch_info = {{ batch_info | json }};
{{ batch_info.batch_details_raw }} </script>
</div> {% endif %} {% endblock %}
{% endif %}
{% endmacro %}
{%- block script %}
{{ super() }}
{% if is_moderator %}
<script>
let batch_info = {{ batch_info | json }};
</script>
{% endif %}
{% endblock %}