赞
踩
✨作者主页:IT毕设梦工厂✨
个人简介:曾从事计算机专业培训教学,擅长Java、Python、微信小程序、Golang、安卓Android等项目实战。接项目定制开发、代码讲解、答辩教学、文档编写、降重等。
☑文末获取源码☑
精彩专栏推荐⬇⬇⬇
Java项目
Python项目
安卓项目
微信小程序项目
随着科技的发展和全球数字化进程的加速,电影产业在人们的生活中占据了越来越重要的地位。电影订票系统作为连接观众与电影的关键桥梁,其效率和便利性直接影响到观众的观影体验。尽管当前存在一些电影订票系统,但它们往往无法满足观众对于多元化、个性化服务的需求,如获取全面的电影信息、便捷的购票流程以及实时的客户服务等。因此,针对当前电影订票系统的不足,开展对高效、便捷、信息透明的电影订票系统的研究是必要的。
当前的电影订票系统主要存在以下问题:
信息不透明:很多电影订票系统在提供电影信息方面并不全面,如放映时间、地点、票价等重要信息往往无法清晰地展示给观众,导致观众难以做出决策。
操作繁琐:部分电影订票系统的操作流程设计复杂,缺乏人性化考虑,使得观众在购票过程中需要花费过多的时间和精力,降低了购票的便利性。
服务不完善:许多电影订票系统缺乏在线客服或者客服反应不及时,无法在观众遇到问题时提供及时、有效的帮助,这大大降低了用户的使用体验。
本课题旨在构建一个高效、便捷、信息透明的电影订票系统,以解决现有系统中存在的问题,实现以下目标:
提供全面、准确的电影信息:系统能够实时更新电影信息,包括放映时间、地点、票价等关键信息,以便观众做出决策。同时,还可以提供电影评论和推荐,帮助观众更好地了解和选择电影。
设计简洁、人性化的操作流程:我们将研究更为简洁和智能化的购票流程,减少用户的操作步骤和等待时间,提升购票的便利性和效率。此外,系统还应具备友好的用户界面和交互设计,使用户能够轻松地完成购票操作。
提供完善的客户服务:系统将提供在线客服功能,观众可以通过实时聊天、电话等方式联系客服,及时获得解答和帮助。同时,系统还将设置自助服务模块,通过FAQ和指导文档等方式帮助观众自行解决问题。
本课题的研究具有重要的理论和实践意义:
理论意义:本课题将完善电影订票系统的设计理论,为后续相关研究提供参考。同时,课题的研究成果还可以为其他类似系统的设计提供指导。
实践意义:本课题将推动电影订票系统的改进升级,更好地服务于广大观众,提升人们的观影体验。此外,课题的研究成果还可以为企业和社会带来经济效益和社会效益。具体来说,对于企业而言,一个高效、便捷的电影订票系统可以提高票房收入、提升品牌形象和增强市场竞争力;对于社会而言,一个完善、透明的电影订票系统可以促进文化传播、丰富人们的精神生活并推动社会的和谐发展。
# 上下应用处理器 @admin.context_processor def tpl_extra(): data = dict( online_time=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") ) return data # 登录装饰器--需要登陆才能获取的页面 def admin_login_req(f): @wraps(f) def decorated_function(*args, **kwargs): if "admin" not in session: return redirect(url_for('admin.login', next=request.url)) return f(*args, **kwargs) return decorated_function def admin_auth(f): @wraps(f) def decorated_function(*args, **kwargs): admin = Admin.query.filter_by( id=session['admin_id'] ).first() auths = admin.role.auths auths = list(map(lambda v: int(v), auths.split(","))) auth_list = Auth.query.all() urls = [v.url for v in auth_list for val in auths if val == v.id] rule = request.url_rule rule_s = str(rule)[1:] if "general_admin" in urls: pass else: if rule_s not in urls: flash("您没有此权限,已返回", 'error') return redirect(url_for('admin.index')) return f(*args, **kwargs) return decorated_function # 修改文件名称 def change_filename(filename): fileinfo = os.path.splitext(filename) filename = datetime.datetime.now().strftime("%Y%m%d%H%M%S") + str(uuid.uuid4().hex) + fileinfo[-1] return filename @admin.route("/login", methods=['GET', 'POST']) def login(): form = LoginForm() if form.validate_on_submit(): data = form.data admin = Admin.query.filter_by(name=data['account']).first() if not admin.check_pwd(data["pwd"]): flash("密码错误", 'error') return redirect(url_for('admin.login')) session['admin'] = data['account'] session['admin_id'] = admin.id adminlog = Adminlog( admin_id=admin.id, ip=request.remote_addr ) db.session.add(adminlog) db.session.commit() return redirect(request.args.get("next") or url_for('admin.index')) return render_template("admin/login.html", form=form) @admin.route("/logout") @admin_login_req def logout(): session.pop("admin", None) session.pop("admin_id", None) return redirect(url_for("admin.login")) @admin.route('/') @admin.route('/index') @admin_login_req @admin_auth def index(): return render_template("admin/index.html", session=session) # 修改密码 @admin.route('pwd', methods=['GET', 'POST']) @admin_login_req def pwd(): form = PwdForm() if form.validate_on_submit(): data = form.data admin = Admin.query.filter_by(name=session['admin']).first() from werkzeug.security import generate_password_hash admin.pwd = generate_password_hash(data["new_pwd"]) db.session.add(admin) db.session.commit() flash("修改密码成功!请重新登陆!", 'success') return redirect(url_for("admin.logout")) return render_template("admin/pwd.html", form=form) # 添加标签 @admin.route('/tag/add/', methods=['GET', 'POST']) @admin_login_req @admin_auth def tag_add(): form = TagForm() if form.validate_on_submit(): data = form.data tag = Tag.query.filter_by(name=data["name"]).count() if tag == 1: flash("名称已经存在", 'error') else: tag = Tag( name=data["name"] ) db.session.add(tag) db.session.commit() flash("添加标签成功", 'success') oplog = Oplog( admin_id=session['admin_id'], ip=request.remote_addr, reason="添加标签:%s" % data['name'] ) db.session.add(oplog) db.session.commit() redirect(url_for("admin.tag_add")) return render_template('admin/tag_add.html', form=form) # 标签列表 @admin.route('/tag/list/<int:page>') @admin_login_req @admin_auth def tag_list(page=None): if page is None: page = 1 page_data = Tag.query.order_by( Tag.addtime.desc() ).paginate(page=page, per_page=10) return render_template('admin/tag_list.html', page_data=page_data) # 删除标签 @admin.route("/tag/del/<int:id>", methods=["GET"]) @admin_login_req @admin_auth def tag_del(id=None): _tag = Tag.query.filter_by(id=id).first_or_404() db.session.delete(_tag) db.session.commit() flash("删除标签成功", 'success') return redirect(url_for("admin.tag_list", page=1)) # 编辑标签 @admin.route('/tag/edit/<int:id>', methods=['GET', 'POST']) @admin_login_req @admin_auth def tag_edit(id): form = TagForm() tag = Tag.query.get_or_404(id) if form.validate_on_submit(): data = form.data tag_count = Tag.query.filter_by(name=data["name"]).count() if tag.name != data['name'] and tag_count == 1: flash("名称已经存在", 'error') # return redirect(url_for("admin.tag_add")) else: tag.name = data['name'] db.session.add(tag) db.session.commit() flash("修改标签成功", 'success') return redirect(url_for("admin.tag_list", page=1)) return render_template('admin/tag_edit.html', form=form, tag=tag) @admin.route('/movie/add/', methods=['GET', 'POST']) @admin_login_req @admin_auth def movie_add(): form = MovieForm() if form.validate_on_submit(): data = form.data file_url = secure_filename(form.url.data.filename) file_logo = secure_filename(form.logo.data.filename) if not os.path.exists(app.config["UP_DIR"]): os.makedirs(app.config["UP_DIR"]) os.chmod(app.config["UP_DIR"], "rw") url = change_filename(file_url) logo = change_filename(file_logo) form.url.data.save(app.config["UP_DIR"] + url) form.logo.data.save(app.config["UP_DIR"] + logo) movie = Movie( title=data['title'], url=url, info=data['info'], logo=logo, star=int(data['star']), playnum=0, commentnum=0, tag_id=int(data['tag_id']), area=data['area'], release_time=data['release_time'], length=data['length'] ) db.session.add(movie) db.session.commit() flash("添加电影成功", "success") return redirect(url_for('admin.movie_add')) return render_template('admin/movie_add.html', form=form) # 电影列表 @admin.route('/movie/list/<int:page>', methods=['GET']) @admin_login_req @admin_auth def movie_list(page=None): if page is None: page = 1 page_data = Movie.query.join(Tag).filter( Tag.id == Movie.tag_id ).order_by( Movie.addtime.desc() ).paginate(page=page, per_page=10) return render_template('admin/movie_list.html', page_data=page_data) # 删除电影 @admin.route('/movie/del/<int:id>', methods=['GET']) @admin_login_req @admin_auth def movie_del(id=None): movie = Movie.query.get_or_404(int(id)) db.session.delete(movie) db.session.commit() flash("删除电影成功", 'success') return redirect(url_for("admin.movie_list", page=1)) # 编辑电影 @admin.route('/movie/edit/<int:id>', methods=['GET', 'POST']) @admin_login_req @admin_auth def movie_edit(id=None): form = MovieForm() form.url.validators = [] form.logo.validators = [] movie = Movie.query.get_or_404(int(id)) if request.method == "GET": form.info.data = movie.info form.tag_id.data = movie.tag_id form.star.data = movie.star if form.validate_on_submit(): data = form.data movie_count = Movie.query.filter_by(title=data['title']).count() if movie_count == 1 and movie.title != data['title']: flash("影片名已经存在", 'error') return redirect(url_for('admin.movie_edit', id=id)) if not os.path.exists(app.config["UP_DIR"]): os.makedirs(app.config["UP_DIR"]) os.chmod(app.config["UP_DIR"], "rw") if form.url.data.filename != "": file_url = secure_filename(form.url.data.filename) movie.url = change_filename(file_url) form.url.data.save(app.config["UP_DIR"] + movie.url) if form.logo.data.filename != "": file_logo = secure_filename(form.logo.data.filename) movie.logo = change_filename(file_logo) form.logo.data.save(app.config["UP_DIR"] + movie.logo) movie.star = data['star'] movie.tag_id = data['tag_id'] movie.info = data['info'] movie.title = data['title'] movie.area = data['area'] movie.length = data['length'] movie.release_time = data['release_time'] db.session.add(movie) db.session.cmmit() flash("修改电影成功", "success") return redirect(url_for('admin.movie_edit', id=movie.id)) return render_template('admin/movie_edit.html', form=form, movie=movie) @admin.route('preview/add', methods=['GET', 'POST']) @admin_login_req @admin_auth def preview_add(): form = PreviewForm() form.logo.validators = [] if form.validate_on_submit(): data = form.data file_logo = secure_filename(form.logo.data.filename) preview_count = Preview.query.filter_by(title=data['title']).count() if preview_count == 1: flash("影片名已经存在", 'error') return redirect(url_for('admin.preview_add')) if not os.path.exists(app.config["UP_DIR"]): os.makedirs(app.config["UP_DIR"]) os.chmod(app.config["UP_DIR"], "rw") logo = change_filename(file_logo) form.logo.data.save(app.config["UP_DIR"] + logo) preview = Preview( title=data['title'], logo=logo ) db.session.add(preview) db.session.commit() flash("添加预告成功", "success") return redirect(url_for('admin.preview_add')) return render_template("admin/preview_add.html", form=form) @admin.route('preview/list/<int:page>', methods=['GET']) @admin_login_req @admin_auth def preview_list(page=None): if page is None: page = 1 page_data = Preview.query.order_by( Preview.addtime.desc() ).paginate(page=page, per_page=10) return render_template("admin/preview_list.html", page_data=page_data) @admin.route('preview/edit/<int:id>', methods=['GET', 'POST']) @admin_login_req @admin_auth def preview_edit(id): form = PreviewForm() preview = Preview.query.get_or_404(int(id)) if request.method == "GET": form.title.data = preview.title if form.validate_on_submit(): data = form.data if form.logo.data.filename != "": file_logo = secure_filename(form.logo.data.filename) preview.logo = change_filename(file_logo) form.logo.data.save(app.config["UP_DIR"] + preview.logo) preview.title = data['title'] db.session.add(preview) db.session.commit() flash("修改预告成功", "success") return redirect(url_for('admin.preview_edit', id=id)) return render_template("admin/preview_edit.html", form=form, preview=preview) @admin.route('preview/del/<int:id>', methods=['GET']) @admin_login_req @admin_auth def preview_del(id=None): preview = Preview.query.get_or_404(int(id)) db.session.delete(preview) db.session.commit() flash("删除预告成功", 'success') return redirect(url_for("admin.preview_list", page=1)) @admin.route('/user/list/<int:page>', methods=['GET']) @admin_login_req @admin_auth def user_list(page=None): if page is None: page = 1 page_data = User.query.order_by( User.addtime.desc() ).paginate(page=page, per_page=7) return render_template("admin/user_list.html", page_data=page_data) @admin.route('user/del/<int:id>', methods=['GET']) @admin_login_req @admin_auth def user_del(id=None): user = User.query.get_or_404(int(id)) db.session.delete(user) db.session.commit() flash("删除用户成功", 'success') return redirect(url_for("admin.user_list", page=1)) @admin.route('/user/view/<int:id>', methods=['GET']) @admin_login_req @admin_auth def user_view(id=None): user = User.query.get_or_404(int(id)) return render_template("admin/user_view.html", user=user) @admin.route("/comment/list/<int:page>", methods=['GET']) @admin_login_req @admin_auth def comment_list(page=None): if page is None: page = 1 page_data = Comment.query.join( Movie ).join( User ).filter( Movie.id == Comment.movie_id, User.id == Comment.user_id ).order_by( Comment.addtime.desc() ).paginate(page=page, per_page=8) return render_template("admin/comment_list.html", page_data=page_data) @admin.route('comment/del/<int:id>', methods=['GET']) @admin_login_req @admin_auth def comment_del(id=None): comment = Comment.query.get_or_404(int(id)) db.session.delete(comment) db.session.commit() flash("删除评论成功", 'success') return redirect(url_for("admin.comment_list", page=1)) @admin.route("/moviecol/list/<int:page>") @admin_login_req @admin_auth def moviecol_list(page=None): if page is None: page = 1 page_data = Moviecol.query.join( Movie ).join( User ).filter( Movie.id == Moviecol.movie_id, User.id == Moviecol.user_id ).order_by( Moviecol.addtime.desc() ).paginate(page=page, per_page=8) return render_template("admin/moviecol_list.html", page_data=page_data) @admin.route('moviecol/del/<int:id>', methods=['GET']) @admin_login_req @admin_auth def moviecol_del(id=None): moviecol = Moviecol.query.get_or_404(int(id)) db.session.delete(moviecol) db.session.commit() flash("删除收藏成功", 'success') return redirect(url_for("admin.moviecol_list", page=1)) # 操作日志 @admin.route("/oplog/list/<int:page>", methods=['GET', 'POST']) @admin_login_req @admin_auth def oplog_list(page=None): if page is None: page = 1 page_data = Oplog.query.join( Admin ).filter( Admin.id == Oplog.admin_id, ).order_by( Oplog.addtime.desc() ).paginate(page=page, per_page=8) return render_template("admin/oplog_list.html", page_data=page_data) @admin.route("/adminloginlog/list/<int:page>", methods=['GET', 'POST']) @admin_login_req @admin_auth def adminloginlog_list(page): if page is None: page = 1 page_data = Adminlog.query.join( Admin ).filter( Admin.id == Adminlog.admin_id ).order_by( Adminlog.addtime.desc() ).paginate(page=page, per_page=8) return render_template("admin/adminloginlog_list.html", page_data=page_data) @admin.route("/userloginlog/list/<int:page>", methods=['GET', 'POST']) @admin_login_req @admin_auth def userloginlog_list(page=None): if page is None: page = 1 page_data = Userlog.query.join( User ).filter( User.id == Userlog.user_id ).order_by( Userlog.addtime.desc() ).paginate(page=page, per_page=8) return render_template("admin/userloginlog_list.html", page_data=page_data) @admin.route('auth/add', methods=['GET', 'POST']) @admin_login_req @admin_auth def auth_add(): form = AuthForm() if form.validate_on_submit(): data = form.data auth = Auth( name=data['name'], url=data['url'] ) db.session.add(auth) db.session.commit() flash("添加权限成功", "success") return render_template("admin/auth_add.html", form=form) # 权限列表 @admin.route('/auth/list/<int:page>') @admin_login_req @admin_auth def auth_list(page=None): if page is None: page = 1 page_data = Auth.query.order_by( Auth.addtime.desc() ).paginate(page=page, per_page=10) return render_template('admin/auth_list.html', page_data=page_data) # 删除权限 @admin.route("/auth/del/<int:id>", methods=["GET"]) @admin_login_req @admin_auth def auth_del(id=None): auth = Auth.query.filter_by(id=id).first_or_404() db.session.delete(auth) db.session.commit() flash("删除标签成功", 'success') return redirect(url_for("admin.auth_list", page=1)) # 编辑权限 @admin.route('/auth/edit/<int:id>', methods=['GET', 'POST']) @admin_login_req @admin_auth def auth_edit(id): form = AuthForm() auth = Auth.query.get_or_404(id) if form.validate_on_submit(): data = form.data auth_url = data['url'] auth_name = data['name'] db.session.add(auth) db.session.commit() flash("修改权限成功", 'success') redirect(url_for("admin.auth_list", page=1)) return render_template('admin/auth_edit.html', form=form, auth=auth) @admin.route('role/add', methods=['GET', 'POST']) @admin_login_req @admin_auth def role_add(): form = RoleForm() if form.validate_on_submit(): data = form.data role = Role( name=data['name'], auths=",".join(map(lambda v: str(v), data['auths'])) ) db.session.add(role) db.session.commit() flash("添加角色成功", 'success') return render_template("admin/role_add.html", form=form) @admin.route("/role/list/<int:page>", methods=['GET', 'POST']) @admin_login_req @admin_auth def role_list(page=None): if page is None: page = 1 page_data = Role.query.order_by( Role.addtime.desc() ).paginate(page=page, per_page=10) return render_template("admin/role_list.html", page_data=page_data) @admin.route("/role/del/<int:id>", methods=["GET"]) @admin_login_req @admin_auth def role_del(id=None): role = Role.query.filter_by(id=id).first_or_404() db.session.delete(role) db.session.commit() flash("删除标签成功", 'success') return redirect(url_for("admin.role_list", page=1)) @admin.route("/role/edit/<int:id>", methods=['GET', 'POST']) @admin_login_req @admin_auth def role_edit(id=None): form = RoleForm() role = Role.query.get_or_404(id) if request.method == "GET": form.auths.data = list(map(lambda v: int(v), role.auths.split(","))) if form.validate_on_submit(): data = form.data role.name = data['name'] role.auths = ",".join(map(lambda v: str(v), data['auths'])) db.session.add(role) db.session.commit() return redirect(url_for("admin.role_list", page=1)) return render_template('admin/role_edit.html', form=form, role=role) @admin.route('admin/add', methods=['GET', 'POST']) @admin_login_req @admin_auth def admin_add(): from werkzeug.security import generate_password_hash form = AdminForm() if form.validate_on_submit(): data = form.data admin_count = Admin.query.filter_by(name=data['name']).count() if admin_count == 1: flash("管理员已经存在", 'error') return redirect(url_for('admin.admin_add')) else: if data['pwd'] != data['re_pwd']: flash("两次输入的密码不相同", 'error') elif data['pwd'] == data['re_pwd']: admin = Admin( name=data['name'], pwd=generate_password_hash(data["pwd"]), role_id=data['role'], is_super=data['is_super'] ) db.session.add(admin) db.session.commit() flash("注册成功,请登录", 'success') return redirect(url_for("admin.admin_list", page=1)) return render_template("admin/admin_add.html", form=form) @admin.route("/admin/list/<int:page>", methods=['GET', 'POST']) @admin_login_req @admin_auth def admin_list(page=None): if page is None: page = 1 page_data = Admin.query.join( Role ).filter( Role.id == Admin.role_id ).order_by( Admin.addtime.desc() ).paginate(page=page, per_page=10) return render_template("admin/admin_list.html", page_data=page_data)
# 上下应用处理器 @admin.context_processor def tpl_extra(): data = dict( online_time=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") ) return data # 登录装饰器--需要登陆才能获取的页面 def admin_login_req(f): @wraps(f) def decorated_function(*args, **kwargs): if "admin" not in session: return redirect(url_for('admin.login', next=request.url)) return f(*args, **kwargs) return decorated_function def admin_auth(f): @wraps(f) def decorated_function(*args, **kwargs): admin = Admin.query.filter_by( id=session['admin_id'] ).first() auths = admin.role.auths auths = list(map(lambda v: int(v), auths.split(","))) auth_list = Auth.query.all() urls = [v.url for v in auth_list for val in auths if val == v.id] rule = request.url_rule rule_s = str(rule)[1:] if "general_admin" in urls: pass else: if rule_s not in urls: flash("您没有此权限,已返回", 'error') return redirect(url_for('admin.index')) return f(*args, **kwargs) return decorated_function # 修改文件名称 def change_filename(filename): fileinfo = os.path.splitext(filename) filename = datetime.datetime.now().strftime("%Y%m%d%H%M%S") + str(uuid.uuid4().hex) + fileinfo[-1] return filename @admin.route("/login", methods=['GET', 'POST']) def login(): form = LoginForm() if form.validate_on_submit(): data = form.data admin = Admin.query.filter_by(name=data['account']).first() if not admin.check_pwd(data["pwd"]): flash("密码错误", 'error') return redirect(url_for('admin.login')) session['admin'] = data['account'] session['admin_id'] = admin.id adminlog = Adminlog( admin_id=admin.id, ip=request.remote_addr ) db.session.add(adminlog) db.session.commit() return redirect(request.args.get("next") or url_for('admin.index')) return render_template("admin/login.html", form=form) @admin.route("/logout") @admin_login_req def logout(): session.pop("admin", None) session.pop("admin_id", None) return redirect(url_for("admin.login")) @admin.route('/') @admin.route('/index') @admin_login_req @admin_auth def index(): return render_template("admin/index.html", session=session) # 修改密码 @admin.route('pwd', methods=['GET', 'POST']) @admin_login_req def pwd(): form = PwdForm() if form.validate_on_submit(): data = form.data admin = Admin.query.filter_by(name=session['admin']).first() from werkzeug.security import generate_password_hash admin.pwd = generate_password_hash(data["new_pwd"]) db.session.add(admin) db.session.commit() flash("修改密码成功!请重新登陆!", 'success') return redirect(url_for("admin.logout")) return render_template("admin/pwd.html", form=form) # 添加标签 @admin.route('/tag/add/', methods=['GET', 'POST']) @admin_login_req @admin_auth def tag_add(): form = TagForm() if form.validate_on_submit(): data = form.data tag = Tag.query.filter_by(name=data["name"]).count() if tag == 1: flash("名称已经存在", 'error') else: tag = Tag( name=data["name"] ) db.session.add(tag) db.session.commit() flash("添加标签成功", 'success') oplog = Oplog( admin_id=session['admin_id'], ip=request.remote_addr, reason="添加标签:%s" % data['name'] ) db.session.add(oplog) db.session.commit() redirect(url_for("admin.tag_add")) return render_template('admin/tag_add.html', form=form) # 标签列表 @admin.route('/tag/list/<int:page>') @admin_login_req @admin_auth def tag_list(page=None): if page is None: page = 1 page_data = Tag.query.order_by( Tag.addtime.desc() ).paginate(page=page, per_page=10) return render_template('admin/tag_list.html', page_data=page_data) # 删除标签 @admin.route("/tag/del/<int:id>", methods=["GET"]) @admin_login_req @admin_auth def tag_del(id=None): _tag = Tag.query.filter_by(id=id).first_or_404() db.session.delete(_tag) db.session.commit() flash("删除标签成功", 'success') return redirect(url_for("admin.tag_list", page=1)) # 编辑标签 @admin.route('/tag/edit/<int:id>', methods=['GET', 'POST']) @admin_login_req @admin_auth def tag_edit(id): form = TagForm() tag = Tag.query.get_or_404(id) if form.validate_on_submit(): data = form.data tag_count = Tag.query.filter_by(name=data["name"]).count() if tag.name != data['name'] and tag_count == 1: flash("名称已经存在", 'error') # return redirect(url_for("admin.tag_add")) else: tag.name = data['name'] db.session.add(tag) db.session.commit() flash("修改标签成功", 'success') return redirect(url_for("admin.tag_list", page=1)) return render_template('admin/tag_edit.html', form=form, tag=tag) @admin.route('/movie/add/', methods=['GET', 'POST']) @admin_login_req @admin_auth def movie_add(): form = MovieForm() if form.validate_on_submit(): data = form.data file_url = secure_filename(form.url.data.filename) file_logo = secure_filename(form.logo.data.filename) if not os.path.exists(app.config["UP_DIR"]): os.makedirs(app.config["UP_DIR"]) os.chmod(app.config["UP_DIR"], "rw") url = change_filename(file_url) logo = change_filename(file_logo) form.url.data.save(app.config["UP_DIR"] + url) form.logo.data.save(app.config["UP_DIR"] + logo) movie = Movie( title=data['title'], url=url, info=data['info'], logo=logo, star=int(data['star']), playnum=0, commentnum=0, tag_id=int(data['tag_id']), area=data['area'], release_time=data['release_time'], length=data['length'] ) db.session.add(movie) db.session.commit() flash("添加电影成功", "success") return redirect(url_for('admin.movie_add')) return render_template('admin/movie_add.html', form=form) # 电影列表 @admin.route('/movie/list/<int:page>', methods=['GET']) @admin_login_req @admin_auth def movie_list(page=None): if page is None: page = 1 page_data = Movie.query.join(Tag).filter( Tag.id == Movie.tag_id ).order_by( Movie.addtime.desc() ).paginate(page=page, per_page=10) return render_template('admin/movie_list.html', page_data=page_data) # 删除电影 @admin.route('/movie/del/<int:id>', methods=['GET']) @admin_login_req @admin_auth def movie_del(id=None): movie = Movie.query.get_or_404(int(id)) db.session.delete(movie) db.session.commit() flash("删除电影成功", 'success') return redirect(url_for("admin.movie_list", page=1)) # 编辑电影 @admin.route('/movie/edit/<int:id>', methods=['GET', 'POST']) @admin_login_req @admin_auth def movie_edit(id=None): form = MovieForm() form.url.validators = [] form.logo.validators = [] movie = Movie.query.get_or_404(int(id)) if request.method == "GET": form.info.data = movie.info form.tag_id.data = movie.tag_id form.star.data = movie.star if form.validate_on_submit(): data = form.data movie_count = Movie.query.filter_by(title=data['title']).count() if movie_count == 1 and movie.title != data['title']: flash("影片名已经存在", 'error') return redirect(url_for('admin.movie_edit', id=id)) if not os.path.exists(app.config["UP_DIR"]): os.makedirs(app.config["UP_DIR"]) os.chmod(app.config["UP_DIR"], "rw") if form.url.data.filename != "": file_url = secure_filename(form.url.data.filename) movie.url = change_filename(file_url) form.url.data.save(app.config["UP_DIR"] + movie.url) if form.logo.data.filename != "": file_logo = secure_filename(form.logo.data.filename) movie.logo = change_filename(file_logo) form.logo.data.save(app.config["UP_DIR"] + movie.logo) movie.star = data['star'] movie.tag_id = data['tag_id'] movie.info = data['info'] movie.title = data['title'] movie.area = data['area'] movie.length = data['length'] movie.release_time = data['release_time'] db.session.add(movie) db.session.cmmit() flash("修改电影成功", "success") return redirect(url_for('admin.movie_edit', id=movie.id)) return render_template('admin/movie_edit.html', form=form, movie=movie) @admin.route('preview/add', methods=['GET', 'POST']) @admin_login_req @admin_auth def preview_add(): form = PreviewForm() form.logo.validators = [] if form.validate_on_submit(): data = form.data file_logo = secure_filename(form.logo.data.filename) preview_count = Preview.query.filter_by(title=data['title']).count() if preview_count == 1: flash("影片名已经存在", 'error') return redirect(url_for('admin.preview_add')) if not os.path.exists(app.config["UP_DIR"]): os.makedirs(app.config["UP_DIR"]) os.chmod(app.config["UP_DIR"], "rw") logo = change_filename(file_logo) form.logo.data.save(app.config["UP_DIR"] + logo) preview = Preview( title=data['title'], logo=logo ) db.session.add(preview) db.session.commit() flash("添加预告成功", "success") return redirect(url_for('admin.preview_add')) return render_template("admin/preview_add.html", form=form) @admin.route('preview/list/<int:page>', methods=['GET']) @admin_login_req @admin_auth def preview_list(page=None): if page is None: page = 1 page_data = Preview.query.order_by( Preview.addtime.desc() ).paginate(page=page, per_page=10) return render_template("admin/preview_list.html", page_data=page_data) @admin.route('preview/edit/<int:id>', methods=['GET', 'POST']) @admin_login_req @admin_auth def preview_edit(id): form = PreviewForm() preview = Preview.query.get_or_404(int(id)) if request.method == "GET": form.title.data = preview.title if form.validate_on_submit(): data = form.data if form.logo.data.filename != "": file_logo = secure_filename(form.logo.data.filename) preview.logo = change_filename(file_logo) form.logo.data.save(app.config["UP_DIR"] + preview.logo) preview.title = data['title'] db.session.add(preview) db.session.commit() flash("修改预告成功", "success") return redirect(url_for('admin.preview_edit', id=id)) return render_template("admin/preview_edit.html", form=form, preview=preview) @admin.route('preview/del/<int:id>', methods=['GET']) @admin_login_req @admin_auth def preview_del(id=None): preview = Preview.query.get_or_404(int(id)) db.session.delete(preview) db.session.commit() flash("删除预告成功", 'success') return redirect(url_for("admin.preview_list", page=1)) @admin.route('/user/list/<int:page>', methods=['GET']) @admin_login_req @admin_auth def user_list(page=None): if page is None: page = 1 page_data = User.query.order_by( User.addtime.desc() ).paginate(page=page, per_page=7) return render_template("admin/user_list.html", page_data=page_data) @admin.route('user/del/<int:id>', methods=['GET']) @admin_login_req @admin_auth def user_del(id=None): user = User.query.get_or_404(int(id)) db.session.delete(user) db.session.commit() flash("删除用户成功", 'success') return redirect(url_for("admin.user_list", page=1)) @admin.route('/user/view/<int:id>', methods=['GET']) @admin_login_req @admin_auth def user_view(id=None): user = User.query.get_or_404(int(id)) return render_template("admin/user_view.html", user=user) @admin.route("/comment/list/<int:page>", methods=['GET']) @admin_login_req @admin_auth def comment_list(page=None): if page is None: page = 1 page_data = Comment.query.join( Movie ).join( User ).filter( Movie.id == Comment.movie_id, User.id == Comment.user_id ).order_by( Comment.addtime.desc() ).paginate(page=page, per_page=8) return render_template("admin/comment_list.html", page_data=page_data) @admin.route('comment/del/<int:id>', methods=['GET']) @admin_login_req @admin_auth def comment_del(id=None): comment = Comment.query.get_or_404(int(id)) db.session.delete(comment) db.session.commit() flash("删除评论成功", 'success') return redirect(url_for("admin.comment_list", page=1)) @admin.route("/moviecol/list/<int:page>") @admin_login_req @admin_auth def moviecol_list(page=None): if page is None: page = 1 page_data = Moviecol.query.join( Movie ).join( User ).filter( Movie.id == Moviecol.movie_id, User.id == Moviecol.user_id ).order_by( Moviecol.addtime.desc() ).paginate(page=page, per_page=8) return render_template("admin/moviecol_list.html", page_data=page_data) @admin.route('moviecol/del/<int:id>', methods=['GET']) @admin_login_req @admin_auth def moviecol_del(id=None): moviecol = Moviecol.query.get_or_404(int(id)) db.session.delete(moviecol) db.session.commit() flash("删除收藏成功", 'success') return redirect(url_for("admin.moviecol_list", page=1)) # 操作日志 @admin.route("/oplog/list/<int:page>", methods=['GET', 'POST']) @admin_login_req @admin_auth def oplog_list(page=None): if page is None: page = 1 page_data = Oplog.query.join( Admin ).filter( Admin.id == Oplog.admin_id, ).order_by( Oplog.addtime.desc() ).paginate(page=page, per_page=8) return render_template("admin/oplog_list.html", page_data=page_data) @admin.route("/adminloginlog/list/<int:page>", methods=['GET', 'POST']) @admin_login_req @admin_auth def adminloginlog_list(page): if page is None: page = 1 page_data = Adminlog.query.join( Admin ).filter( Admin.id == Adminlog.admin_id ).order_by( Adminlog.addtime.desc() ).paginate(page=page, per_page=8) return render_template("admin/adminloginlog_list.html", page_data=page_data) @admin.route("/userloginlog/list/<int:page>", methods=['GET', 'POST']) @admin_login_req @admin_auth def userloginlog_list(page=None): if page is None: page = 1 page_data = Userlog.query.join( User ).filter( User.id == Userlog.user_id ).order_by( Userlog.addtime.desc() ).paginate(page=page, per_page=8) return render_template("admin/userloginlog_list.html", page_data=page_data) @admin.route('auth/add', methods=['GET', 'POST']) @admin_login_req @admin_auth def auth_add(): form = AuthForm() if form.validate_on_submit(): data = form.data auth = Auth( name=data['name'], url=data['url'] ) db.session.add(auth) db.session.commit() flash("添加权限成功", "success") return render_template("admin/auth_add.html", form=form) # 权限列表 @admin.route('/auth/list/<int:page>') @admin_login_req @admin_auth def auth_list(page=None): if page is None: page = 1 page_data = Auth.query.order_by( Auth.addtime.desc() ).paginate(page=page, per_page=10) return render_template('admin/auth_list.html', page_data=page_data) # 删除权限 @admin.route("/auth/del/<int:id>", methods=["GET"]) @admin_login_req @admin_auth def auth_del(id=None): auth = Auth.query.filter_by(id=id).first_or_404() db.session.delete(auth) db.session.commit() flash("删除标签成功", 'success') return redirect(url_for("admin.auth_list", page=1)) # 编辑权限 @admin.route('/auth/edit/<int:id>', methods=['GET', 'POST']) @admin_login_req @admin_auth def auth_edit(id): form = AuthForm() auth = Auth.query.get_or_404(id) if form.validate_on_submit(): data = form.data auth_url = data['url'] auth_name = data['name'] db.session.add(auth) db.session.commit() flash("修改权限成功", 'success') redirect(url_for("admin.auth_list", page=1)) return render_template('admin/auth_edit.html', form=form, auth=auth) @admin.route('role/add', methods=['GET', 'POST']) @admin_login_req @admin_auth def role_add(): form = RoleForm() if form.validate_on_submit(): data = form.data role = Role( name=data['name'], auths=",".join(map(lambda v: str(v), data['auths'])) ) db.session.add(role) db.session.commit() flash("添加角色成功", 'success') return render_template("admin/role_add.html", form=form) @admin.route("/role/list/<int:page>", methods=['GET', 'POST']) @admin_login_req @admin_auth def role_list(page=None): if page is None: page = 1 page_data = Role.query.order_by( Role.addtime.desc() ).paginate(page=page, per_page=10) return render_template("admin/role_list.html", page_data=page_data) @admin.route("/role/del/<int:id>", methods=["GET"]) @admin_login_req @admin_auth def role_del(id=None): role = Role.query.filter_by(id=id).first_or_404() db.session.delete(role) db.session.commit() flash("删除标签成功", 'success') return redirect(url_for("admin.role_list", page=1)) @admin.route("/role/edit/<int:id>", methods=['GET', 'POST']) @admin_login_req @admin_auth def role_edit(id=None): form = RoleForm() role = Role.query.get_or_404(id) if request.method == "GET": form.auths.data = list(map(lambda v: int(v), role.auths.split(","))) if form.validate_on_submit(): data = form.data role.name = data['name'] role.auths = ",".join(map(lambda v: str(v), data['auths'])) db.session.add(role) db.session.commit() return redirect(url_for("admin.role_list", page=1)) return render_template('admin/role_edit.html', form=form, role=role) @admin.route('admin/add', methods=['GET', 'POST']) @admin_login_req @admin_auth def admin_add(): from werkzeug.security import generate_password_hash form = AdminForm() if form.validate_on_submit(): data = form.data admin_count = Admin.query.filter_by(name=data['name']).count() if admin_count == 1: flash("管理员已经存在", 'error') return redirect(url_for('admin.admin_add')) else: if data['pwd'] != data['re_pwd']: flash("两次输入的密码不相同", 'error') elif data['pwd'] == data['re_pwd']: admin = Admin( name=data['name'], pwd=generate_password_hash(data["pwd"]), role_id=data['role'], is_super=data['is_super'] ) db.session.add(admin) db.session.commit() flash("注册成功,请登录", 'success') return redirect(url_for("admin.admin_list", page=1)) return render_template("admin/admin_add.html", form=form) @admin.route("/admin/list/<int:page>", methods=['GET', 'POST']) @admin_login_req @admin_auth def admin_list(page=None): if page is None: page = 1 page_data = Admin.query.join( Role ).filter( Role.id == Admin.role_id ).order_by( Admin.addtime.desc() ).paginate(page=page, per_page=10) return render_template("admin/admin_list.html", page_data=page_data)
电影订票系统-项目视频:
计算机毕业设计选题推荐-电影订票系统-Python项目实战
计算机毕业设计选题推荐-电影订票系统-Python项目实战
大家可以帮忙点赞、收藏、关注、评论啦~
源码获取:私信我
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。