fix: from time and to time not updated in drag and drop action #29114
fix: from time and to time not updated in drag and drop action
This commit is contained in:
parent
efcfb825d7
commit
8b5827ed6d
@ -201,8 +201,8 @@ def get_course_schedule_events(start, end, filters=None):
|
||||
conditions = get_event_conditions("Course Schedule", filters)
|
||||
|
||||
data = frappe.db.sql("""select name, course, color,
|
||||
timestamp(schedule_date, from_time) as from_datetime,
|
||||
timestamp(schedule_date, to_time) as to_datetime,
|
||||
timestamp(schedule_date, from_time) as from_time,
|
||||
timestamp(schedule_date, to_time) as to_time,
|
||||
room, student_group, 0 as 'allDay'
|
||||
from `tabCourse Schedule`
|
||||
where ( schedule_date between %(start)s and %(end)s )
|
||||
|
@ -3,6 +3,8 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
@ -30,6 +32,14 @@ class CourseSchedule(Document):
|
||||
if self.from_time > self.to_time:
|
||||
frappe.throw(_("From Time cannot be greater than To Time."))
|
||||
|
||||
"""Handles specicfic case to update schedule date in calendar """
|
||||
if isinstance(self.from_time, str):
|
||||
try:
|
||||
datetime_obj = datetime.strptime(self.from_time, '%Y-%m-%d %H:%M:%S')
|
||||
self.schedule_date = datetime_obj
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
def validate_overlap(self):
|
||||
"""Validates overlap for Student Group, Instructor, Room"""
|
||||
|
||||
@ -47,4 +57,4 @@ class CourseSchedule(Document):
|
||||
validate_overlap_for(self, "Assessment Plan", "student_group")
|
||||
|
||||
validate_overlap_for(self, "Assessment Plan", "room")
|
||||
validate_overlap_for(self, "Assessment Plan", "supervisor", self.instructor)
|
||||
validate_overlap_for(self, "Assessment Plan", "supervisor", self.instructor)
|
@ -1,11 +1,10 @@
|
||||
frappe.views.calendar["Course Schedule"] = {
|
||||
field_map: {
|
||||
// from_datetime and to_datetime don't exist as docfields but are used in onload
|
||||
"start": "from_datetime",
|
||||
"end": "to_datetime",
|
||||
"start": "from_time",
|
||||
"end": "to_time",
|
||||
"id": "name",
|
||||
"title": "course",
|
||||
"allDay": "allDay"
|
||||
"allDay": "allDay",
|
||||
},
|
||||
gantt: false,
|
||||
order_by: "schedule_date",
|
||||
|
@ -6,6 +6,7 @@ import unittest
|
||||
|
||||
import frappe
|
||||
from frappe.utils import to_timedelta, today
|
||||
from frappe.utils.data import add_to_date
|
||||
|
||||
from erpnext.education.utils import OverlapError
|
||||
|
||||
@ -39,6 +40,11 @@ class TestCourseSchedule(unittest.TestCase):
|
||||
make_course_schedule_test_record(from_time= cs1.from_time, to_time= cs1.to_time,
|
||||
student_group="Course-TC102-2014-2015 (_Test Academic Term)", instructor="_Test Instructor 2", room=frappe.get_all("Room")[1].name)
|
||||
|
||||
def test_update_schedule_date(self):
|
||||
doc = make_course_schedule_test_record(schedule_date= add_to_date(today(), days=1))
|
||||
doc.schedule_date = add_to_date(doc.schedule_date, days=1)
|
||||
doc.save()
|
||||
|
||||
def make_course_schedule_test_record(**args):
|
||||
args = frappe._dict(args)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user