feat: batch source
This commit is contained in:
@@ -4,11 +4,11 @@ from frappe.desk.page.setup_wizard.setup_wizard import add_all_roles_to
|
||||
|
||||
def after_install():
|
||||
add_pages_to_nav()
|
||||
create_batch_source()
|
||||
|
||||
|
||||
def after_sync():
|
||||
create_lms_roles()
|
||||
set_default_home()
|
||||
set_default_certificate_print_format()
|
||||
add_all_roles_to("Administrator")
|
||||
|
||||
@@ -64,10 +64,6 @@ def delete_lms_roles():
|
||||
frappe.db.delete("Role", role)
|
||||
|
||||
|
||||
def set_default_home():
|
||||
frappe.db.set_single_value("Portal Settings", "default_portal_home", "/courses")
|
||||
|
||||
|
||||
def create_course_creator_role():
|
||||
if not frappe.db.exists("Role", "Course Creator"):
|
||||
role = frappe.get_doc(
|
||||
@@ -182,3 +178,20 @@ def delete_custom_fields():
|
||||
|
||||
for field in fields:
|
||||
frappe.db.delete("Custom Field", {"fieldname": field})
|
||||
|
||||
|
||||
def create_batch_source():
|
||||
sources = [
|
||||
"Newsletter",
|
||||
"LinkedIn",
|
||||
"Twitter",
|
||||
"Website",
|
||||
"Friend/Colleague/Connection",
|
||||
"Google Search",
|
||||
]
|
||||
|
||||
for source in sources:
|
||||
if not frappe.db.exists("LMS Batch Source", source):
|
||||
doc = frappe.new_doc("LMS Batch Source")
|
||||
doc.source = source
|
||||
doc.save()
|
||||
|
||||
@@ -9,11 +9,12 @@
|
||||
"field_order": [
|
||||
"student_details_section",
|
||||
"student",
|
||||
"payment",
|
||||
"confirmation_email_sent",
|
||||
"column_break_oduu",
|
||||
"student_name",
|
||||
"username"
|
||||
"username",
|
||||
"column_break_oduu",
|
||||
"payment",
|
||||
"source",
|
||||
"confirmation_email_sent"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@@ -59,12 +60,18 @@
|
||||
"fieldname": "confirmation_email_sent",
|
||||
"fieldtype": "Check",
|
||||
"label": "Confirmation Email Sent"
|
||||
},
|
||||
{
|
||||
"fieldname": "source",
|
||||
"fieldtype": "Link",
|
||||
"label": "Source",
|
||||
"options": "LMS Source"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2023-10-09 17:09:50.481794",
|
||||
"modified": "2023-10-26 16:52:04.266693",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "Batch Student",
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"field_order": [
|
||||
"payment_for_document_type",
|
||||
"member",
|
||||
"source",
|
||||
"column_break_rqkd",
|
||||
"payment_for_document",
|
||||
"billing_name",
|
||||
@@ -129,11 +130,17 @@
|
||||
"fieldtype": "Dynamic Link",
|
||||
"label": "Payment for Document",
|
||||
"options": "payment_for_document_type"
|
||||
},
|
||||
{
|
||||
"fieldname": "source",
|
||||
"fieldtype": "Link",
|
||||
"label": "Source",
|
||||
"options": "LMS Source"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2023-10-17 23:17:50.334975",
|
||||
"modified": "2023-10-26 16:54:12.408274",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Payment",
|
||||
|
||||
0
lms/lms/doctype/lms_source/__init__.py
Normal file
0
lms/lms/doctype/lms_source/__init__.py
Normal file
8
lms/lms/doctype/lms_source/lms_source.js
Normal file
8
lms/lms/doctype/lms_source/lms_source.js
Normal file
@@ -0,0 +1,8 @@
|
||||
// Copyright (c) 2023, Frappe and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
// frappe.ui.form.on("LMS Source", {
|
||||
// refresh(frm) {
|
||||
|
||||
// },
|
||||
// });
|
||||
69
lms/lms/doctype/lms_source/lms_source.json
Normal file
69
lms/lms/doctype/lms_source/lms_source.json
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"actions": [],
|
||||
"allow_rename": 1,
|
||||
"autoname": "field:source",
|
||||
"creation": "2023-10-26 16:28:53.932278",
|
||||
"default_view": "List",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"source"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "source",
|
||||
"fieldtype": "Data",
|
||||
"label": "Source",
|
||||
"unique": 1
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2023-10-26 17:25:09.144367",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Source",
|
||||
"naming_rule": "By fieldname",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Moderator",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "LMS Student",
|
||||
"select": 1,
|
||||
"share": 1
|
||||
}
|
||||
],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
"title_field": "source"
|
||||
}
|
||||
9
lms/lms/doctype/lms_source/lms_source.py
Normal file
9
lms/lms/doctype/lms_source/lms_source.py
Normal file
@@ -0,0 +1,9 @@
|
||||
# Copyright (c) 2023, Frappe and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
# import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
class LMSSource(Document):
|
||||
pass
|
||||
9
lms/lms/doctype/lms_source/test_lms_source.py
Normal file
9
lms/lms/doctype/lms_source/test_lms_source.py
Normal file
@@ -0,0 +1,9 @@
|
||||
# Copyright (c) 2023, Frappe and Contributors
|
||||
# See license.txt
|
||||
|
||||
# import frappe
|
||||
from frappe.tests.utils import FrappeTestCase
|
||||
|
||||
|
||||
class TestLMSSource(FrappeTestCase):
|
||||
pass
|
||||
@@ -898,7 +898,7 @@ def check_multicurrency(amount, currency, country=None):
|
||||
currency = "USD"
|
||||
|
||||
if apply_rounding and amount % 100 != 0:
|
||||
amount = ceil(amount + 100 - amount % 100)
|
||||
amount = amount + 100 - amount % 100
|
||||
|
||||
return amount, currency
|
||||
|
||||
@@ -1028,12 +1028,13 @@ def record_payment(address, response, client, doctype, docname):
|
||||
"amount_with_gst": payment_details["amount_with_gst"],
|
||||
"gstin": address.gstin,
|
||||
"pan": address.pan,
|
||||
"source": address.source,
|
||||
"payment_for_document_type": doctype,
|
||||
"payment_for_document": docname,
|
||||
}
|
||||
)
|
||||
payment_doc.save(ignore_permissions=True)
|
||||
return payment_doc.name
|
||||
return payment_doc
|
||||
|
||||
|
||||
def get_payment_details(doctype, docname, address):
|
||||
@@ -1056,7 +1057,7 @@ def get_payment_details(doctype, docname, address):
|
||||
def create_membership(course, payment):
|
||||
membership = frappe.new_doc("LMS Enrollment")
|
||||
membership.update(
|
||||
{"member": frappe.session.user, "course": course, "payment": payment}
|
||||
{"member": frappe.session.user, "course": course, "payment": payment.name}
|
||||
)
|
||||
membership.save(ignore_permissions=True)
|
||||
return f"/courses/{course}/learn/1.1"
|
||||
@@ -1067,7 +1068,8 @@ def add_student_to_batch(batchname, payment):
|
||||
student.update(
|
||||
{
|
||||
"student": frappe.session.user,
|
||||
"payment": payment,
|
||||
"payment": payment.name,
|
||||
"source": payment.source,
|
||||
"parent": batchname,
|
||||
"parenttype": "LMS Batch",
|
||||
"parentfield": "students",
|
||||
|
||||
@@ -75,4 +75,5 @@ lms.patches.v1_0.create_student_role
|
||||
lms.patches.v1_0.mark_confirmation_for_batch_students
|
||||
lms.patches.v1_0.create_quiz_questions
|
||||
lms.patches.v1_0.add_default_marks #16-10-2023
|
||||
lms.patches.v1_0.add_certificate_template #26-10-2023
|
||||
lms.patches.v1_0.add_certificate_template #26-10-2023
|
||||
lms.patches.v1_0.create_batch_source
|
||||
5
lms/patches/v1_0/create_batch_source.py
Normal file
5
lms/patches/v1_0/create_batch_source.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from lms.install import create_batch_source
|
||||
|
||||
|
||||
def execute():
|
||||
create_batch_source()
|
||||
@@ -40,15 +40,15 @@ const setup_billing = () => {
|
||||
reqd: 1,
|
||||
default: address && address.city,
|
||||
},
|
||||
{
|
||||
fieldtype: "Column Break",
|
||||
},
|
||||
{
|
||||
fieldtype: "Data",
|
||||
label: __("State/Province"),
|
||||
fieldname: "state",
|
||||
default: address && address.state,
|
||||
},
|
||||
{
|
||||
fieldtype: "Column Break",
|
||||
},
|
||||
{
|
||||
fieldtype: "Link",
|
||||
label: __("Country"),
|
||||
@@ -75,6 +75,13 @@ const setup_billing = () => {
|
||||
reqd: 1,
|
||||
default: address && address.phone,
|
||||
},
|
||||
{
|
||||
fieldtype: "Link",
|
||||
label: __("Where did you hear about this?"),
|
||||
fieldname: "source",
|
||||
options: "LMS Source",
|
||||
only_select: 1,
|
||||
},
|
||||
{
|
||||
fieldtype: "Section Break",
|
||||
label: __("GST Details"),
|
||||
|
||||
Reference in New Issue
Block a user