diff --git a/lms/lms/doctype/batch_student/batch_student.py b/lms/lms/doctype/batch_student/batch_student.py index 7cd9a61a..d3168f71 100644 --- a/lms/lms/doctype/batch_student/batch_student.py +++ b/lms/lms/doctype/batch_student/batch_student.py @@ -1,9 +1,19 @@ # Copyright (c) 2022, Frappe and contributors # For license information, please see license.txt -# import frappe +import frappe from frappe.model.document import Document class BatchStudent(Document): pass + + +@frappe.whitelist() +def enroll_batch(batch_name): + enrollment = frappe.new_doc("Batch Student") + enrollment.student = frappe.session.user + enrollment.parent = batch_name + enrollment.parentfield = "students" + enrollment.parenttype = "LMS Batch" + enrollment.save(ignore_permissions=True) diff --git a/lms/lms/doctype/lms_batch/lms_batch.json b/lms/lms/doctype/lms_batch/lms_batch.json index b05ee563..48d2e0c8 100644 --- a/lms/lms/doctype/lms_batch/lms_batch.json +++ b/lms/lms/doctype/lms_batch/lms_batch.json @@ -15,6 +15,7 @@ "start_time", "end_time", "published", + "allow_self_enrollment", "section_break_rgfj", "medium", "category", @@ -293,11 +294,17 @@ "fieldname": "amount_usd", "fieldtype": "Currency", "label": "Amount (USD)" + }, + { + "default": "0", + "fieldname": "allow_self_enrollment", + "fieldtype": "Check", + "label": "Allow Self Enrollment" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-12-21 12:27:16.849362", + "modified": "2024-01-19 23:36:17.351413", "modified_by": "Administrator", "module": "LMS", "name": "LMS Batch", @@ -327,6 +334,15 @@ "role": "Moderator", "share": 1, "write": 1 + }, + { + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "LMS Student", + "share": 1 } ], "show_title_field_in_link": 1, diff --git a/lms/www/batches/batch_details.html b/lms/www/batches/batch_details.html index 9fd5c93e..7c5b5123 100644 --- a/lms/www/batches/batch_details.html +++ b/lms/www/batches/batch_details.html @@ -146,6 +146,10 @@ href="/billing/batch/{{ batch_info.name }}"> {{ _("Register Now") }} + {% elif batch_info.allow_self_enrollment %} + {% else %}