fix: batch copy

This commit is contained in:
Jannat Patel
2023-09-20 12:40:04 +05:30
parent 0d99269109
commit 33f4e82399
3 changed files with 8 additions and 5 deletions

View File

@@ -136,9 +136,9 @@
{% endif %} {% endif %}
<div class="mt-2"> <div class="mt-2">
{% if is_moderator or is_evaluator or is_student %} {% if is_moderator or is_evaluator %}
<a class="btn btn-primary wide-button" href="/batches/{{ batch_info.name }}"> <a class="btn btn-primary wide-button" href="/batches/{{ batch_info.name }}">
{{ _("Checkout Batch") }} {{ _("Manage Batch") }}
</a> </a>
{% elif batch_info.paid_batch %} {% elif batch_info.paid_batch %}
<a class="btn btn-primary wide-button {% if batch_info.seat_count and not seats_left %} hide {% endif %}" <a class="btn btn-primary wide-button {% if batch_info.seat_count and not seats_left %} hide {% endif %}"

View File

@@ -31,10 +31,15 @@ def get_context(context):
context.is_moderator = has_course_moderator_role() context.is_moderator = has_course_moderator_role()
context.is_evaluator = has_course_evaluator_role() context.is_evaluator = has_course_evaluator_role()
context.is_student = is_student(batch_name)
if not context.is_moderator and not context.batch_info.published: if not context.is_moderator and not context.batch_info.published:
raise frappe.PermissionError(_("You do not have permission to access this page.")) raise frappe.PermissionError(_("You do not have permission to access this page."))
if context.is_student:
frappe.local.flags.redirect_location = f"/batches/{batch_name}"
raise frappe.Redirect
context.courses = frappe.get_all( context.courses = frappe.get_all(
"Batch Course", "Batch Course",
{"parent": batch_name}, {"parent": batch_name},
@@ -51,5 +56,3 @@ def get_context(context):
context.student_count = frappe.db.count("Batch Student", {"parent": batch_name}) context.student_count = frappe.db.count("Batch Student", {"parent": batch_name})
context.seats_left = context.batch_info.seat_count - context.student_count context.seats_left = context.batch_info.seat_count - context.student_count
context.is_student = is_student(batch_name)

View File

@@ -24,7 +24,7 @@ def get_context(context):
def validate_access(doctype, docname, module): def validate_access(doctype, docname, module):
if frappe.session.user == "Guest": if frappe.session.user == "Guest":
raise frappe.PermissionError(_("You are not allowed to access this page.")) raise frappe.PermissionError(_("Please login to continue with payment."))
if module not in ["course", "batch"]: if module not in ["course", "batch"]:
raise ValueError(_("Module is incorrect.")) raise ValueError(_("Module is incorrect."))