def get_all_record(cls, student_id): from .enumtype import * from .models import StudentClass from utils import getformattime all_record = StudentClassRecord.objects.filter( student_id=student_id).order_by('-id') data = [] for rec in all_record: current_rec = { 'class_name': rec.classes.name, 'class_status': CLASS_STATUS.getDesc(rec.classes.class_status), 'teacher': rec.classes.teacher.name, 'command': COMMAND_STATUS.getDesc(rec.command), 'create_time': getformattime(rec.create_time) } data.append(current_rec) return data
def class_get(self, class_id): """ GET LIST BY id """ if class_id is None: return None try: classes = Class.objects.get(id=class_id) except IntegrityError: print 'error' class_data = to_dict(classes) class_data['start_time'] = getformattime( class_data['start_time']) if class_data['start_time'] else '' class_data['course_system_name'] = classes.course_system.name class_data['course_rate'] = classes.classess.filter( course_status=2).count() class_data['progress'] = '%s/%s' % ( class_data['course_rate'], classes.course_system.courses.count()) class_data['teacher_name'] = classes.teacher.name class_data['students'] = [to_dict(s) for s in classes.students.all()] return class_data
def student_get(self, student_id): """ GET LIST BY id """ if student_id is None: return None try: studentes = Student.objects.get(id=student_id) except IntegrityError: print 'error' student_data = to_dict(studentes) count_result = self.get_count_num(student_id) student_data['create_time'] = getformattime( student_data['create_time']) if student_data['create_time'] else '' student_data['course_nums'] = count_result[0][0] student_data['game_bkp_level'] = count_result[1][0] student_data['game_bkp_coin_num'] = count_result[1][1] student_data['game_ballon_level'] = '%s/%s' % (count_result[2][0], count_result[2][1]) student_data['game_ballon_coin_num'] = count_result[2][2] return student_data
def getval_create_time(self, obj, default=''): from utils import getformattime return getformattime(obj.create_time) \ if obj.create_time else ''
def getval_start_time(self, obj, default=''): return getformattime(obj.start_time, '%Y-%m-%d') \ if obj.start_time else ''
def getval_create_time(self, obj, default=''): return getformattime(obj.create_time) \ if obj.create_time else ''