def home(): user_id = session.get('user_id') users = Users.query.filter(Users.id == user_id).first() course1 = Course1.query.filter(Course1.user_id == user_id).all() return render_template('courses/home.html', course1=course1, users=users, res=monthly_archive())
def note_delete(note_id): course2 = Course2.query.filter(Course2.id == note_id).first() db.session.delete(course2) db.session.commit() user_id = session.get('user_id') users = Users.query.filter(Users.id == user_id).first() course1 = Course1.query.filter(Course1.user_id == user_id).all() return render_template('courses/home.html', course1=course1, users=users, res=monthly_archive())
def second_show(course1_id): user_id = session.get('user_id') users = Users.query.filter(Users.id == user_id).first() course2 = Course2.query.filter(Course2.course1_id == course1_id, Course2.user_id == user_id).all() course1 = Course1.query.filter(Course1.user_id == user_id).all() uploads = Upload.query.filter(Upload.user_id == user_id, Upload.course1_id == course1_id).all() return render_template('courses/home.html', course2=course2, course1=course1, uploads=uploads, users=users, res=monthly_archive())
def file_delete(file_id): uploads = Upload.query.filter(Upload.id == file_id).first() # 数据库删除 db.session.delete(uploads) db.session.commit() # 项目保存的文件删除 basepath = os.path.dirname(__file__) file = os.path.join(basepath[:-6], 'static/upload_file', uploads.file_name) if os.path.exists(file): os.remove(file) user_id = session.get('user_id') users = Users.query.filter(Users.id == user_id).first() course1 = Course1.query.filter(Course1.user_id == user_id).all() return render_template('courses/home.html', course1=course1, users=users, res=monthly_archive())
def personal_center(): user_id = session.get('user_id') users = Users.query.filter(Users.id == user_id).first() question = Question.query.filter(Question.user_id == users.id).all() course2 = Course2.query.filter(Course2.user_id == users.id).all() upload = Upload.query.filter(Upload.user_id == users.id).all() ques_count = Question.query.filter(Question.user_id == users.id).count() course2_count = Course2.query.filter(Course2.user_id == user_id).count() upload_count = Upload.query.filter(Upload.user_id == user_id).count() return render_template('users/personal_center.html', users=users, question=question, course2=course2, upload=upload, ques_count=ques_count, course2_count=course2_count, upload_count=upload_count, res=monthly_archive(), upload_archive=upload_archive())