From 0fcea692c71f4ef7fe472bc6c26cad23ff07d833 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Wed, 27 Sep 2023 19:21:57 +0530 Subject: [PATCH] feat: batch meta and raw details --- lms/lms/doctype/lms_batch/lms_batch.json | 24 +++++++++++++++++++++++- lms/lms/doctype/lms_batch/lms_batch.py | 4 ++++ lms/public/js/common_functions.js | 12 ++++++++++++ lms/www/batches/batch_details.html | 10 ++++++++++ lms/www/batches/batch_details.py | 10 ++++++++++ 5 files changed, 59 insertions(+), 1 deletion(-) diff --git a/lms/lms/doctype/lms_batch/lms_batch.json b/lms/lms/doctype/lms_batch/lms_batch.json index d4e4ea6d..beb3c22a 100644 --- a/lms/lms/doctype/lms_batch/lms_batch.json +++ b/lms/lms/doctype/lms_batch/lms_batch.json @@ -22,7 +22,11 @@ "seat_count", "section_break_6", "description", + "batch_details_raw", + "column_break_hlqw", "batch_details", + "meta_image", + "section_break_jgji", "students", "courses", "section_break_gsac", @@ -218,11 +222,29 @@ { "fieldname": "section_break_ontp", "fieldtype": "Section Break" + }, + { + "fieldname": "batch_details_raw", + "fieldtype": "HTML Editor", + "label": "Batch Details Raw" + }, + { + "fieldname": "column_break_hlqw", + "fieldtype": "Column Break" + }, + { + "fieldname": "section_break_jgji", + "fieldtype": "Section Break" + }, + { + "fieldname": "meta_image", + "fieldtype": "Attach Image", + "label": "Meta Image" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-09-20 14:40:45.940540", + "modified": "2023-09-27 18:42:53.301107", "modified_by": "Administrator", "module": "LMS", "name": "LMS Batch", diff --git a/lms/lms/doctype/lms_batch/lms_batch.py b/lms/lms/doctype/lms_batch/lms_batch.py index f7e824d7..5213f93e 100644 --- a/lms/lms/doctype/lms_batch/lms_batch.py +++ b/lms/lms/doctype/lms_batch/lms_batch.py @@ -194,6 +194,8 @@ def create_batch( end_date, description=None, batch_details=None, + batch_details_raw=None, + meta_image=None, seat_count=0, start_time=None, end_time=None, @@ -218,6 +220,8 @@ def create_batch( "end_date": end_date, "description": description, "batch_details": batch_details, + "batch_details_raw": batch_details_raw, + "image": meta_image, "seat_count": seat_count, "start_time": start_time, "end_time": end_time, diff --git a/lms/public/js/common_functions.js b/lms/public/js/common_functions.js index 59edd021..d0f17265 100644 --- a/lms/public/js/common_functions.js +++ b/lms/public/js/common_functions.js @@ -340,6 +340,18 @@ const open_batch_dialog = () => { default: batch_info && batch_info.batch_details, reqd: 1, }, + { + fieldtype: "HTML Editor", + label: __("Batch Details Raw"), + fieldname: "batch_details_raw", + default: batch_info && batch_info.batch_details_raw, + }, + { + fieldtype: "Attach Image", + label: __("Meta Image"), + fieldname: "meta_image", + default: batch_info && batch_info.image, + }, { fieldtype: "Section Break", label: __("Pricing"), diff --git a/lms/www/batches/batch_details.html b/lms/www/batches/batch_details.html index 8d1d9ee9..d543bc88 100644 --- a/lms/www/batches/batch_details.html +++ b/lms/www/batches/batch_details.html @@ -14,6 +14,7 @@ {{ CourseList(courses) }} + {{ BatchDetailsRaw() }} {% endblock %} @@ -216,6 +217,15 @@ {% endmacro %} + +{% macro BatchDetailsRaw() %} + {% if batch_info.batch_details_raw %} +
+ {{ batch_info.batch_details_raw }} +
+ {% endif %} +{% endmacro %} + {%- block script %} {{ super() }} {% if is_moderator %} diff --git a/lms/www/batches/batch_details.py b/lms/www/batches/batch_details.py index df044a1e..8840a91d 100644 --- a/lms/www/batches/batch_details.py +++ b/lms/www/batches/batch_details.py @@ -29,6 +29,8 @@ def get_context(context): "end_time", "seat_count", "published", + "meta_image", + "batch_details_raw", ], as_dict=1, ) @@ -67,3 +69,11 @@ def get_context(context): context.student_count = frappe.db.count("Batch Student", {"parent": batch_name}) context.seats_left = context.batch_info.seat_count - context.student_count + + context.metatags = { + "title": context.batch_info.title, + "image": context.batch_info.meta_image, + "description": context.batch_info.description, + "keywords": context.batch_info.title, + "og:type": "website", + }