diff --git a/education/education/api.py b/education/education/api.py index 77c5962e..b2f8dbbe 100644 --- a/education/education/api.py +++ b/education/education/api.py @@ -10,6 +10,7 @@ from frappe.model.mapper import get_mapped_doc from frappe.utils import cstr, flt, getdate from frappe.utils.dateutils import get_dates_from_timegrain +from datetime import datetime def get_course(program): @@ -759,3 +760,19 @@ def get_student_attendance(student, student_group): filters={"student": student, "student_group": student_group, "docstatus": 1}, fields=["date", "status", "name"], ) + + +@frappe.whitelist() +def get_announcements(): + announcements = frappe.get_all( + "Newsletter", + filters={"published": 1}, + fields=["subject", "creation", "message"] + ) + + for announcement in announcements: + if "creation" in announcement: + announcement["creation"] = frappe.utils.pretty_date(announcement["creation"]) + + return announcements + diff --git a/education/education/doctype/school_announcement/__init__.py b/education/education/doctype/school_announcement/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/education/education/doctype/school_announcement/school_announcement.js b/education/education/doctype/school_announcement/school_announcement.js new file mode 100644 index 00000000..7e7df6a4 --- /dev/null +++ b/education/education/doctype/school_announcement/school_announcement.js @@ -0,0 +1,8 @@ +// Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +// frappe.ui.form.on("School Announcement", { +// refresh(frm) { + +// }, +// }); diff --git a/education/education/doctype/school_announcement/school_announcement.json b/education/education/doctype/school_announcement/school_announcement.json new file mode 100644 index 00000000..efd824ee --- /dev/null +++ b/education/education/doctype/school_announcement/school_announcement.json @@ -0,0 +1,90 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "format:ANC-{MM}-{#####}", + "creation": "2025-02-26 16:22:04.198050", + "doctype": "DocType", + "engine": "InnoDB", + "field_order": [ + "title", + "column_break_ywyl", + "posting_date", + "descriptions_section", + "description", + "section_break_uyky", + "announcement_date", + "column_break_uhyk", + "is_published" + ], + "fields": [ + { + "fieldname": "title", + "fieldtype": "Data", + "label": "Title" + }, + { + "fieldname": "column_break_ywyl", + "fieldtype": "Column Break" + }, + { + "default": "Today", + "fieldname": "posting_date", + "fieldtype": "Date", + "label": "Posting Date" + }, + { + "default": "0", + "fieldname": "is_published", + "fieldtype": "Check", + "label": "Is Published?" + }, + { + "fieldname": "descriptions_section", + "fieldtype": "Section Break", + "label": "Descriptions" + }, + { + "fieldname": "description", + "fieldtype": "Text Editor", + "label": "Description" + }, + { + "fieldname": "section_break_uyky", + "fieldtype": "Section Break" + }, + { + "fieldname": "announcement_date", + "fieldtype": "Date", + "label": "Announcement Date" + }, + { + "fieldname": "column_break_uhyk", + "fieldtype": "Column Break" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2025-02-26 16:33:07.237999", + "modified_by": "Administrator", + "module": "Education", + "name": "School Announcement", + "naming_rule": "Expression", + "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": [] +} \ No newline at end of file diff --git a/education/education/doctype/school_announcement/school_announcement.py b/education/education/doctype/school_announcement/school_announcement.py new file mode 100644 index 00000000..5b7b607d --- /dev/null +++ b/education/education/doctype/school_announcement/school_announcement.py @@ -0,0 +1,9 @@ +# Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + + +class SchoolAnnouncement(Document): + pass diff --git a/education/education/doctype/school_announcement/test_school_announcement.py b/education/education/doctype/school_announcement/test_school_announcement.py new file mode 100644 index 00000000..cf391059 --- /dev/null +++ b/education/education/doctype/school_announcement/test_school_announcement.py @@ -0,0 +1,9 @@ +# Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt + +# import frappe +from frappe.tests.utils import FrappeTestCase + + +class TestSchoolAnnouncement(FrappeTestCase): + pass diff --git a/education/public/frontend/index.html b/education/public/frontend/index.html index ecc8bbb2..afdc1026 100644 --- a/education/public/frontend/index.html +++ b/education/public/frontend/index.html @@ -5,10 +5,10 @@