fix: announcements should to go one student at a time

This commit is contained in:
Jannat Patel
2025-02-12 12:46:57 +05:30
parent 1c3e84e9bb
commit ee73790127
3 changed files with 22 additions and 13 deletions

View File

@@ -428,16 +428,15 @@ watch(students, () => {
}) })
const certificationCount = createResource({ const certificationCount = createResource({
url: "frappe.client.get_count", url: 'frappe.client.get_count',
params: { params: {
doctype: "LMS Certificate", doctype: 'LMS Certificate',
filters: { filters: {
"batch_name": props.batch.name, batch_name: props.batch.name,
}, },
}, },
auto: true auto: true,
}) })
</script> </script>
<style> <style>
.apexcharts-legend { .apexcharts-legend {

View File

@@ -33,9 +33,9 @@
{{ __('Announcement') }} {{ __('Announcement') }}
</div> </div>
<TextEditor <TextEditor
:bubbleMenu="true" :fixedMenu="true"
@change="(val) => (announcement.announcement = val)" @change="(val) => (announcement.announcement = val)"
editorClass="prose-sm py-2 px-2 min-h-[200px] border-outline-gray-2 hover:border-outline-gray-3 rounded-md bg-surface-gray-3" editorClass="prose-sm py-2 px-2 min-h-[200px] border-outline-gray-2 hover:border-outline-gray-3 rounded-b-md bg-surface-gray-3"
/> />
</div> </div>
</div> </div>
@@ -67,16 +67,13 @@ const announcement = reactive({
}) })
const announcementResource = createResource({ const announcementResource = createResource({
url: 'frappe.core.doctype.communication.email.make', url: 'lms.lms.api.make_announcement',
makeParams(values) { makeParams(values) {
return { return {
recipients: props.students.join(', '), students: props.students,
cc: announcement.replyTo, cc: announcement.replyTo,
subject: announcement.subject, subject: announcement.subject,
content: announcement.announcement, content: announcement.announcement,
doctype: 'LMS Batch',
name: props.batch,
send_email: 1,
} }
}, },
}) })
@@ -102,7 +99,7 @@ const makeAnnouncement = (close) => {
) )
}, },
onError(err) { onError(err) {
showToast(__('Error'), __(err.messages?.[0] || err), 'check') showToast(__('Error'), __(err.messages?.[0] || err), 'alert-circle')
}, },
} }
) )

View File

@@ -1225,3 +1225,16 @@ def get_notifications(filters):
@frappe.whitelist(allow_guest=True) @frappe.whitelist(allow_guest=True)
def is_guest_allowed(): def is_guest_allowed():
return frappe.get_cached_value("LMS Settings", None, "allow_guest_access") return frappe.get_cached_value("LMS Settings", None, "allow_guest_access")
@frappe.whitelist()
def make_announcement(students, cc, subject, content):
for student in students:
frappe.sendmail(
recipients=student,
cc=cc,
subject=subject,
message=content,
header=[subject, "green"],
retry=3,
)