def exculActivitiesPool(cmb, exculset_id, edited_activity_id=0): # collect activity_ids for exculset_id sql = " SELECT ea.id \ FROM excul ex \ JOIN excul_activity_titles ea ON ea.id = ex.activity_id \ WHERE ex.exculset_id = %d " % (exculset_id, ) activityIDs = fetch.getList(sql) if edited_activity_id: l = [] for x in activityIDs: #rint x if not x == edited_activity_id: l.append(x) activityIDs = l activityIDs = [str(x) for x in activityIDs] #rint 'activityIDs',activityIDs listStr = "'%s'" % ','.join(activityIDs) sql = " SELECT id, name \ FROM excul_activity_titles \ WHERE NOT FIND_IN_SET(id, %s) \ ORDER BY name" % listStr #rint sql, fetch.getAll_col(sql) fillCmb(cmb, fetch.getAll_col(sql), 'without activity') restore(cmb, int(edited_activity_id))
def PopulateSourceList(self): source_list=[] sql = "SELECT id, course_name, course_level FROM courses ORDER BY course_level" result = fetch.getAll_col(sql) for row in result: course_id = row[0] course_name = row[1] course_level = "%02d" % row[2] source_list.append((course_id, course_name, course_level)) return source_list
def inv_students(cmb, filter_panel): school_id, course_id, batch_id = filter_panel.getSelectedIDs() #rint 'inv_students', cmb, school_id, course_title_id, batch_id if batch_id: sql ="SELECT s.id, s.first_name, s.middle_name, s.last_name \ FROM students s \ JOIN batch_students bs ON s.id = bs.student_id \ JOIN batches b ON b.id = bs.batch_id \ WHERE s.is_active = 1 \ AND b.id = %d" % batch_id elif course_id: sql ="SELECT s.id, s.first_name, s.middle_name, s.last_name \ FROM students s \ JOIN batch_students bs ON s.id = bs.student_id \ JOIN batches b ON b.id = bs.batch_id \ WHERE s.is_active = 1 \ AND b.course_id = %d" % course_id sql += " AND reg_year < %d" % gVar.schYr origional_id = fetch.cmbID(cmb) dataSet = fetch.getAll_col(sql) cmb.Freeze() # locks the combo so that other processes are not called cmb.Clear() first_item = "" if first_item: cmb.Append(first_item, -1) cmb.Append('', 0) for row in dataSet: if row[1]: fn = "%s " % row[1] else: fn='' if row[2]: mn = "%s " % row[2] else: mn = '' if row[3]: ln = "%s " % row[3] else: ln='' ful_name = "%s%s%s" % (fn,mn,ln) cmb.Append(ful_name, row[0]) restored = restore(cmb, origional_id) cmb.Thaw() if restored: return origional_id else: cmb.SetSelection(1)
def genNoBlank(cmb, sql, first_item='') : #rint 'loadCmb: genNoBlank:', sql, fetch.getAll_dict(sql) #sql should be designed to return first two items 'id' , 'title' dataSet = fetch.getAll_col(sql) origional_id = fetch.cmbID(cmb) cmb.Freeze() # locks the combo so that other processes are not called cmb.Clear() if first_item: cmb.Append(first_item, '0') for row in dataSet: cmb.Append(str(row[1]), row[0]) restore(cmb, origional_id) cmb.Thaw()
def exculTeacherPool(cmb, exculset_id, edited_teacher_id=0): exculList = fetch.excul_groups_forExculSet(exculset_id) teacherIDs = [str(x[0]) for x in exculList] if edited_teacher_id: l = [] for x in teacherIDs: if not x == str(edited_teacher_id): l.append(x) teacherIDs = l listStr = "'%s'" % ','.join(teacherIDs) sql = " SELECT id, CONCAT_WS(' ', first_name, middle_name, last_name) AS full_name \ FROM employees \ WHERE employee_category_id = 2 \ AND %d BETWEEN join_schYr AND leave_schYr \ AND NOT FIND_IN_SET(id, %s) \ ORDER BY full_name" % (gVar.schYr, listStr) fillCmb(cmb, fetch.getAll_col(sql),'without teacher') restore(cmb, int(edited_teacher_id))