feat: publish batches

This commit is contained in:
Jannat Patel
2023-09-12 15:09:13 +05:30
19 changed files with 218 additions and 33 deletions

View File

@@ -19,25 +19,29 @@ def get_context(context):
"amount",
"currency",
"seat_count",
"published",
],
order_by="start_date",
)
past_batches, upcoming_batches = [], []
past_batches, upcoming_batches, private_batches = [], [], []
for batch in batches:
batch.student_count = frappe.db.count("Batch Student", {"parent": batch.name})
batch.course_count = frappe.db.count("Batch Course", {"parent": batch.name})
batch.seats_left = (
batch.seat_count - batch.student_count if batch.seat_count else None
)
print(batch.seat_count, batch.student_count, batch.seats_left)
if getdate(batch.start_date) < getdate():
print(batch.name, batch.published)
if not batch.published:
private_batches.append(batch)
elif getdate(batch.start_date) < getdate():
past_batches.append(batch)
else:
upcoming_batches.append(batch)
context.past_batches = sorted(past_batches, key=lambda d: d.start_date)
context.upcoming_batches = sorted(upcoming_batches, key=lambda d: d.start_date)
context.private_batches = sorted(private_batches, key=lambda d: d.start_date)
if frappe.session.user != "Guest":
my_batches_info = []