style: formattin
This commit is contained in:
@@ -88,11 +88,15 @@ class LMSBatch(Document):
|
||||
frappe.throw(_("Evaluation end date cannot be less than the batch end date."))
|
||||
|
||||
def validate_membership(self):
|
||||
members = frappe.get_all('LMS Batch Enrollment', filters={'batch': self.name}, pluck=['member'])
|
||||
members = frappe.get_all(
|
||||
"LMS Batch Enrollment", filters={"batch": self.name}, pluck=["member"]
|
||||
)
|
||||
for course in self.courses:
|
||||
for member in members:
|
||||
if not frappe.db.exists('LMS Enrollment', {'course': course.course, 'member': member}):
|
||||
enrollment = frappe.new_doc('LMS Enrollment')
|
||||
if not frappe.db.exists(
|
||||
"LMS Enrollment", {"course": course.course, "member": member}
|
||||
):
|
||||
enrollment = frappe.new_doc("LMS Enrollment")
|
||||
enrollment.course = course.course
|
||||
enrollment.member = member
|
||||
enrollment.save()
|
||||
|
||||
@@ -8,7 +8,6 @@ from frappe.email.doctype.email_template.email_template import get_email_templat
|
||||
|
||||
|
||||
class LMSBatchEnrollment(Document):
|
||||
|
||||
def after_insert(self):
|
||||
self.send_confirmation_email()
|
||||
self.add_member_to_live_class()
|
||||
@@ -18,7 +17,9 @@ class LMSBatchEnrollment(Document):
|
||||
self.validate_course_enrollment()
|
||||
|
||||
def validate_duplicate_members(self):
|
||||
if frappe.db.exists("LMS Batch Enrollment", {"batch": self.batch, "member": self.member}):
|
||||
if frappe.db.exists(
|
||||
"LMS Batch Enrollment", {"batch": self.batch, "member": self.member}
|
||||
):
|
||||
frappe.throw(_("Member already enrolled in this batch"))
|
||||
|
||||
def validate_course_enrollment(self):
|
||||
@@ -41,9 +42,8 @@ class LMSBatchEnrollment(Document):
|
||||
outgoing_email_account = frappe.get_cached_value(
|
||||
"Email Account", {"default_outgoing": 1, "enable_outgoing": 1}, "name"
|
||||
)
|
||||
if (
|
||||
not self.confirmation_email_sent
|
||||
and (outgoing_email_account or frappe.conf.get("mail_login"))
|
||||
if not self.confirmation_email_sent and (
|
||||
outgoing_email_account or frappe.conf.get("mail_login")
|
||||
):
|
||||
self.send_mail()
|
||||
self.confirmation_email_sent = 1
|
||||
@@ -54,7 +54,12 @@ class LMSBatchEnrollment(Document):
|
||||
custom_template = frappe.db.get_single_value(
|
||||
"LMS Settings", "batch_confirmation_template"
|
||||
)
|
||||
batch = frappe.db.get_value("LMS Batch", self.batch, ["name", "title", "start_date", "start_time", "medium"], as_dict=1)
|
||||
batch = frappe.db.get_value(
|
||||
"LMS Batch",
|
||||
self.batch,
|
||||
["name", "title", "start_date", "start_time", "medium"],
|
||||
as_dict=1,
|
||||
)
|
||||
args = {
|
||||
"title": batch.title,
|
||||
"student_name": self.member_name,
|
||||
@@ -96,4 +101,4 @@ class LMSBatchEnrollment(Document):
|
||||
"parenttype": "Event",
|
||||
"parentfield": "event_participants",
|
||||
}
|
||||
).save()
|
||||
).save()
|
||||
|
||||
@@ -1226,9 +1226,9 @@ def get_batch_details(batch):
|
||||
batch_details.courses = frappe.get_all(
|
||||
"Batch Course", filters={"parent": batch}, fields=["course", "title", "evaluator"]
|
||||
)
|
||||
batch_details.students = frappe.get_all("LMS Batch Enrollment", {
|
||||
"batch": batch
|
||||
}, pluck='member')
|
||||
batch_details.students = frappe.get_all(
|
||||
"LMS Batch Enrollment", {"batch": batch}, pluck="member"
|
||||
)
|
||||
|
||||
if batch_details.paid_batch and batch_details.start_date >= getdate():
|
||||
batch_details.amount, batch_details.currency = check_multicurrency(
|
||||
@@ -1718,16 +1718,20 @@ def enroll_in_batch(batch, payment_name=None):
|
||||
if not frappe.db.exists(
|
||||
"LMS Batch Enrollment", {"batch": batch, "member": frappe.session.user}
|
||||
):
|
||||
batch_doc = frappe.db.get_value('LMS Batch', batch, ['name', 'seat_count'], as_dict=True)
|
||||
batch_doc = frappe.db.get_value(
|
||||
"LMS Batch", batch, ["name", "seat_count"], as_dict=True
|
||||
)
|
||||
students = frappe.db.count("LMS Batch Enrollment", {"batch": batch})
|
||||
if batch_doc.seat_count and students >= batch_doc.seat_count:
|
||||
frappe.throw(_("The batch is full. Please contact the Administrator."))
|
||||
|
||||
new_student = frappe.new_doc("LMS Batch Enrollment")
|
||||
new_student.update({
|
||||
"member": frappe.session.user,
|
||||
"batch": batch,
|
||||
})
|
||||
new_student.update(
|
||||
{
|
||||
"member": frappe.session.user,
|
||||
"batch": batch,
|
||||
}
|
||||
)
|
||||
|
||||
if payment_name:
|
||||
payment = frappe.db.get_value(
|
||||
|
||||
@@ -1,17 +1,29 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
students = frappe.get_all("Batch Student", fields=["student", "student_name", "username", "payment", "source", "parent", "confirmation_email_sent"])
|
||||
students = frappe.get_all(
|
||||
"Batch Student",
|
||||
fields=[
|
||||
"student",
|
||||
"student_name",
|
||||
"username",
|
||||
"payment",
|
||||
"source",
|
||||
"parent",
|
||||
"confirmation_email_sent",
|
||||
],
|
||||
)
|
||||
|
||||
for student in students:
|
||||
doc = frappe.new_doc("LMS Batch Enrollment")
|
||||
doc.member = student.student
|
||||
doc.member_name = student.student_name
|
||||
doc.member_username = student.username
|
||||
doc.payment = student.payment
|
||||
doc.source = student.source
|
||||
doc.batch = student.parent
|
||||
doc.confirmation_email_sent = student.confirmation_email_sent
|
||||
doc.save()
|
||||
for student in students:
|
||||
doc = frappe.new_doc("LMS Batch Enrollment")
|
||||
doc.member = student.student
|
||||
doc.member_name = student.student_name
|
||||
doc.member_username = student.username
|
||||
doc.payment = student.payment
|
||||
doc.source = student.source
|
||||
doc.batch = student.parent
|
||||
doc.confirmation_email_sent = student.confirmation_email_sent
|
||||
doc.save()
|
||||
|
||||
frappe.delete_doc("DocType", "Batch Student")
|
||||
frappe.delete_doc("DocType", "Batch Student")
|
||||
|
||||
Reference in New Issue
Block a user