Skip to content

Commit d23c98a

Browse files
authored
Merge pull request #2407 from raizasafeel/fix/batch-creation
fix: batch errors are now rendered
2 parents 7781916 + 9e4f1d8 commit d23c98a

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

frontend/src/pages/Batches/components/NewBatchModal.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ import { Button, Dialog, FormControl, TextEditor, toast } from 'frappe-ui'
120120
import { useOnboarding, useTelemetry } from 'frappe-ui/frappe'
121121
import { computed, inject, onMounted, onBeforeUnmount, ref } from 'vue'
122122
import { useRouter } from 'vue-router'
123-
import { sanitizeHTML, createLMSCategory } from '@/utils'
123+
import { sanitizeHTML, createLMSCategory, cleanError } from '@/utils'
124124
import MultiSelect from '@/components/Controls/MultiSelect.vue'
125125
import Link from '@/components/Controls/Link.vue'
126126
import NewMemberModal from '@/components/Modals/NewMemberModal.vue'
@@ -214,7 +214,8 @@ const saveBatch = (close: () => void = () => {}) => {
214214
}
215215
},
216216
onError(err: any) {
217-
toast.error(cleanError(err.messages?.[0]))
217+
const message = err?.messages?.[0]
218+
toast.error(message ? cleanError(message) : __('Error creating batch'))
218219
console.error(err)
219220
},
220221
}

lms/lms/doctype/lms_batch/lms_batch.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
class LMSBatch(Document):
2929
def validate(self):
30+
self._validate_mandatory()
3031
self.validate_seats_left()
3132
self.validate_batch_end_date()
3233
self.validate_batch_time()
@@ -43,7 +44,7 @@ def on_update(self):
4344
frappe.enqueue(send_notification_for_published_batch, batch=self)
4445

4546
def autoname(self):
46-
if not self.name:
47+
if not self.name and self.title:
4748
self.name = generate_slug(self.title, "LMS Batch")
4849

4950
def validate_batch_end_date(self):

0 commit comments

Comments
 (0)