def edit_date_status(photographer_id): if photographer_id == current_user.id: user = User.query.filter_by(id=photographer_id).first() form = DateStatusForm() if request.method == 'POST': if request.form.get('action') == 'create': if form.validate_on_submit(): start_date = form.from_day.data end_date = form.end_day.data date_status = DateStatus() date_status.start_date = start_date date_status.end_date = end_date date_status.user_id = photographer_id date_status.status = EnumValues.find_one_by_code(DATE_STATUS_NOT_AVAILABLE) save_obj_commit(date_status) flash('工作日历修改成功') else: flash('输入错误,请重新选择起始日期') elif request.form.get('action') == 'delete': id_to_del = int(request.form.get('id_to_delete')) delete_by_id(DateStatus, id_to_del) flash('工作日历中不可用时间段删除成功') date_statuses = user.date_statuses return rt('edit_date_status.html', form=form, date_statuses=date_statuses) else: flash('您没有权限编辑该用户的工作日历') return redirect(url_for('index'))