feat: paid classes and seat count
This commit is contained in:
0
lms/lms/doctype/class_student_detail/__init__.py
Normal file
0
lms/lms/doctype/class_student_detail/__init__.py
Normal file
@@ -0,0 +1,8 @@
|
||||
// Copyright (c) 2023, Frappe and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
// frappe.ui.form.on("Class Student Detail", {
|
||||
// refresh(frm) {
|
||||
|
||||
// },
|
||||
// });
|
||||
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"actions": [],
|
||||
"allow_rename": 1,
|
||||
"creation": "2023-05-03 20:52:46.950991",
|
||||
"default_view": "List",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"user",
|
||||
"full_name"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "user",
|
||||
"fieldtype": "Link",
|
||||
"label": "User",
|
||||
"options": "User"
|
||||
},
|
||||
{
|
||||
"fieldname": "full_name",
|
||||
"fieldtype": "Data",
|
||||
"label": "Full Name"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2023-05-03 20:52:46.950991",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "Class Student Detail",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
"track_changes": 1
|
||||
}
|
||||
@@ -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 ClassStudentDetail(Document):
|
||||
pass
|
||||
@@ -0,0 +1,9 @@
|
||||
# Copyright (c) 2023, Frappe and Contributors
|
||||
# See license.txt
|
||||
|
||||
# import frappe
|
||||
from frappe.tests.utils import FrappeTestCase
|
||||
|
||||
|
||||
class TestClassStudentDetail(FrappeTestCase):
|
||||
pass
|
||||
@@ -11,7 +11,9 @@
|
||||
"title",
|
||||
"start_date",
|
||||
"end_date",
|
||||
"paid_class",
|
||||
"column_break_4",
|
||||
"seat_count",
|
||||
"description",
|
||||
"section_break_6",
|
||||
"students",
|
||||
@@ -71,11 +73,22 @@
|
||||
"fieldtype": "Code",
|
||||
"label": "Custom Component",
|
||||
"options": "HTML"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "paid_class",
|
||||
"fieldtype": "Check",
|
||||
"label": "Paid Class"
|
||||
},
|
||||
{
|
||||
"fieldname": "seat_count",
|
||||
"fieldtype": "Int",
|
||||
"label": "Seat Count"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2023-03-02 22:47:13.139289",
|
||||
"modified": "2023-05-03 17:52:28.226169",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Class",
|
||||
|
||||
@@ -68,11 +68,7 @@
|
||||
|
||||
<div class="lms-card">
|
||||
|
||||
<div class="lms-card-title">
|
||||
{{ class.title }}
|
||||
</div>
|
||||
|
||||
<div class="text-muted small mb-4">
|
||||
<div class="text-muted small mb-2">
|
||||
{% if course_count %}
|
||||
<span class="mr-3">
|
||||
{{ course_count }} {{ _("Courses") }}
|
||||
@@ -84,6 +80,16 @@
|
||||
{{ student_count }} {{ _("Students") }}
|
||||
</span>
|
||||
{% endif %}
|
||||
|
||||
{% if class.seats_left %}
|
||||
<span class="indicator-pill yellow pull-right">
|
||||
{{ class.seats_left }} {{ _("seats left") }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="lms-card-title mb-4">
|
||||
{{ class.title }}
|
||||
</div>
|
||||
|
||||
<div class="">
|
||||
@@ -97,6 +103,13 @@
|
||||
{{ frappe.utils.format_date(class.end_date, "long") }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{% if class.paid_class and class.start_date > frappe.utils.getdate() %}
|
||||
<a class="btn btn-secondary btn-sm mt-4">
|
||||
{{ _("Register") }}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
<a class="stretched-link" href="/classes/{{ class.name }}"></a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
@@ -8,13 +8,22 @@ def get_context(context):
|
||||
context.is_moderator = has_course_moderator_role()
|
||||
classes = frappe.get_all(
|
||||
"LMS Class",
|
||||
fields=["name", "title", "start_date", "end_date"],
|
||||
fields=["name", "title", "start_date", "end_date", "paid_class", "seat_count"],
|
||||
)
|
||||
|
||||
past_classes, upcoming_classes = [], []
|
||||
for class_ in classes:
|
||||
if getdate(class_.end_date) < getdate():
|
||||
if class_.seat_count:
|
||||
filled_seats = frappe.db.count(
|
||||
"Class Student",
|
||||
filters={"parent": class_.name},
|
||||
)
|
||||
class_.seats_left = class_.seat_count - filled_seats
|
||||
|
||||
if getdate(class_.start_date) < getdate():
|
||||
past_classes.append(class_)
|
||||
else:
|
||||
upcoming_classes.append(class_)
|
||||
|
||||
context.past_classes = past_classes
|
||||
context.upcoming_classes = upcoming_classes
|
||||
|
||||
Reference in New Issue
Block a user