def students(): #form = StudentSearchForm() if request.method == 'POST': def stu_init_func(row): s = Student(row['id'], row['Student Name'], row['Date Enrolled'], row['Email']) return s request.save_to_database(field_name='file', session=db.session, table=Student, initializer=stu_init_func) record = Student.query.all() comp_tbl = Comp.query.all() for r in record: # test=r.id for c in comp_tbl: d = Competancy_rec(mark=0, comp_id=c.descrip, clinician_id='1', student_id=r.id) db.session.add(d) db.session.commit() records = Student.query.all() return render_template('students.html', title='Students.html', Student=records)
def student_import(): if request.method == 'POST': def student_init_func(row): #shop_id=Shop.query.filter_by(shopname=row['shop_id']).first() student = Student() student.firstname=row['firstname'] student.lastname=row['lastname'] student.school=row['school'] student.course=row['course'] student.sex=row['sex'] student.province=row['province'] student.city=row['city'] student.area=row['area'] student.address=row['address'] student.parent=row['parent'] student.phone1=row['phone1'] student.phone2=row['phone2'] student.shop_id=current_user.shop_id return student request.save_to_database(field_name='file', session=db.session, table=Student, initializer=student_init_func) return redirect('/student') return render_template('student_import.html')
def upload_categories(): def table_init_func(row): return Category(row['name']) request.save_to_database(field_name='file', session=db.session, table=Category, initializer=table_init_func) return excel.make_response_from_a_table(db.session, Category, "xls")
def upload_categories(): def table_init_func(row): return Category(row['name']) request.save_to_database(field_name='file', session=db.session, table=Category, initializer=table_init_func) return excel.make_response_from_a_table(db.session, Category, "xls")
def about(): if request.method == 'POST': def comp_init_func(row): c = Comp(row['Description'], row['Code'], row['Rotation Name']) return c request.save_to_database( field_name ='file', session=db.session, table=Comp, initializer=comp_init_func) return render_template('about.html', title='About')
def import_case(): if (request.method == 'POST'): def ref_init_func(row): r = Reference() r.resource_type = row['RESOURCE_TYPE'] r.booking_ref = row['BOOKING_REF'] r.expire_on = datetime.datetime.strptime(str(row['EXPIRE_ON']) + " 16:00:00", "%Y-%m-%d %H:%M:%S") return r request.save_to_database(field_name='file', session=db.session, \ table=Reference, \ initializer=(ref_init_func)) flash('HRP Course Registration cases created.') return render_template('admin_acknowledge.html') return render_template('import.html', title='Import HRP Training Registration Cases')
def import_slot(): if (request.method == 'POST'): def resource_init_func(row): r = Resource() r.rtype = row['TYPE'] r.location = row['LOCATION'] r.description = row['DESCRIPTION'] r.capacity = row['CAPACITY'] r.available = row['CAPACITY'] return r request.save_to_database(field_name='file', session=db.session, \ table=Resource, \ initializer=(resource_init_func)) flash('HRP Training timeslots created.') return render_template('admin_acknowledge.html') return render_template('import.html', title='Import HRP Training Timeslot')
def do_import_transcendental(): # Clean Database and recreate database Transcendental.query.delete() if request.method == "POST": def init_func(row): transcendental = Transcendental(row['id'], row['name'], row['Key'], row['Description'], row['Video']) transcendental.id = row['id'] return transcendental request.save_to_database(field_name='file', session=db.session, table=Transcendental, initializers=[init_func]) return '''
def students(): #form = StudentSearchForm() if request.method == 'POST': def stu_init_func(row): s = Student(row['id'], row['Student Name'], row['Date Enrolled'], row['Email']) return s request.save_to_database(field_name='file', session=db.session, table=Student, initializer=stu_init_func) records = Student.query.all() return render_template('students.html', title='Students.html', Student=records)
def do_import(): # Clean Database and recreate database Composition.query.delete() if request.method == "POST": def init_func(row): composition = Composition( row['composition_name'], row['composer'], row['description'], row['video_link'] ) composition.id = row['id'] return composition request.save_to_database( field_name='file', session=db.session, table=Composition, initializers=[init_func]) return '''
def import_case(): if request.method == 'POST': def ref_init_func(row): r = Reference() r.resource_type = row['RESOURCE_TYPE'] r.booking_ref = row['BOOKING_REF'] print(f"......{type(row['EXPIRE_ON'])}") r.expire_on = datetime.datetime.strptime(str(row['EXPIRE_ON']), \ "%Y-%m-%d %H:%M:%S") return r request.save_to_database(field_name='file', session=db.session, \ table=Reference, \ initializer=ref_init_func) flash('HTMB cases created') return render_template('acknowledge.html') return render_template('import.html', title='Import HTMB Referrals')
def teacher_import(): if request.method == 'POST': def teacher_init_func(row): teacher = Teacher() teacher.firstname=row['firstname'] teacher.lastname=row['lastname'] teacher.fee=row['fee'] teacher.course=row['course'] teacher.sex=row['sex'] teacher.resume=row['resume'] teacher.phone=row['phone'] teacher.wx=row['wx'] teacher.shop_id=current_user.shop_id return teacher request.save_to_database(field_name='file', session=db.session, table=Teacher, initializer=teacer_init_func) return redirect('/teacher') return render_template('teacher_import.html')
def students(): if current_user.level == 1 or current_user.level == 2: form2 = SearchbyNameForm() students = '' if form2.validate_on_submit(): #searching by name students = Student.query.filter(Student.name.contains(form2.name.data)).all() if request.method == 'POST': def stu_init_func(row): s = Student(row['id'],row['Student Name'], row['Date Enrolled'], row['Email']) return s request.save_to_database( field_name ='file', session=db.session, table=Student, initializer=stu_init_func) record = Student.query.all() comp_tbl = Comp.query.all() p = bcrypt.generate_password_hash('password').decode('utf-8') for r in record: s = User2(username=r.studentid, email=r.email, password=p, level=3, rotation1='Student', rotation2=r.studentid) # automatically adding students user accounts db.session.add(s) db.session.commit() # test=r.id for c in comp_tbl: d = Competancy_rec(mark=0, comp_id=c.descrip, comp_name=c.rot_name, clinician_id=current_user.id, student_id=r.studentid) #automatically building comp rec table for each student db.session.add(d) db.session.commit() records = Student.query.all() return render_template('students.html', title='Students.html', Student=records, records=records, form2=form2, students=students) else: flash('ONLY CLINICIANS CAN ACCESS THIS PAGE','danger') return redirect(url_for('home'))