fix: unavailability validaions
This commit is contained in:
@@ -122,10 +122,12 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { createResource, FormControl, Button } from 'frappe-ui'
|
import { createResource, FormControl, Button } from 'frappe-ui'
|
||||||
import { computed, reactive, ref } from 'vue'
|
import { computed, reactive, ref, onMounted, inject } from 'vue'
|
||||||
import { showToast, convertToTitleCase } from '@/utils'
|
import { showToast, convertToTitleCase } from '@/utils'
|
||||||
import { Plus, X, Check } from 'lucide-vue-next'
|
import { Plus, X, Check } from 'lucide-vue-next'
|
||||||
|
|
||||||
|
const user = inject('$user')
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
profile: {
|
profile: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@@ -133,6 +135,12 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (user.data?.name !== props.profile.data?.name) {
|
||||||
|
window.location.href = `/user/${props.profile.data?.username}`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const showSlotsTemplate = ref(0)
|
const showSlotsTemplate = ref(0)
|
||||||
const from = ref(null)
|
const from = ref(null)
|
||||||
const to = ref(null)
|
const to = ref(null)
|
||||||
|
|||||||
@@ -12,6 +12,17 @@ from frappe.utils import get_time
|
|||||||
class CourseEvaluator(Document):
|
class CourseEvaluator(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_time_slots()
|
self.validate_time_slots()
|
||||||
|
self.validate_unavailability()
|
||||||
|
|
||||||
|
def validate_unavailability(self):
|
||||||
|
if self.unavailable_from and not self.unavailable_to:
|
||||||
|
frappe.throw(_("Unavailable To Date is mandatory if Unavailable From Date is set"))
|
||||||
|
|
||||||
|
if self.unavailable_to and not self.unavailable_from:
|
||||||
|
frappe.throw(_("Unavailable From Date is mandatory if Unavailable To Date is set"))
|
||||||
|
|
||||||
|
if self.unavailable_from >= self.unavailable_to:
|
||||||
|
frappe.throw(_("Unavailable From Date cannot be greater than Unavailable To Date"))
|
||||||
|
|
||||||
def validate_time_slots(self):
|
def validate_time_slots(self):
|
||||||
for schedule in self.schedule:
|
for schedule in self.schedule:
|
||||||
|
|||||||
Reference in New Issue
Block a user