def edit_actor(actor_id): if 'username' not in session: return redirect('/login') elif session['username'] != ADMIN_NAME: return redirect('/actors') form = ActorForm() actors_model = ActorsModel(db.get_connection()) if form.validate_on_submit(): name = form.name.data surname = form.surname.data role = form.role.data bio = form.bio.data actors_model.edit(actor_id, name, surname, role, bio) return redirect('/actors') exists = actors_model.exists(actor_id) if not exists[0]: return redirect('/actors') actor = actors_model.get(actor_id) form.name.process_data(actor[1]) form.surname.process_data(actor[2]) form.role.process_data(actor[3]) form.bio.process_data(actor[4]) return render_template('actor_form.html', title='Редактирование профиля актёра', form=form)
def dashboard_add_actor(request): context = RequestContext(request) if request.method == 'POST': form = ActorForm(request.POST, request.FILES) if form.is_valid(): form.save() return HttpResponseRedirect('/movies/dashboard') return render_to_response("movie_library/dashboard/add_actor.html", {"form": form, 'dashboard_active':'active'}, context) elif request.method == 'GET': form = ActorForm() return render_to_response("movie_library/dashboard/add_actor.html", {"form": form, 'dashboard_active':'active'}, context)
def add_actor(): if 'username' not in session: return redirect('/login') elif session['username'] != ADMIN_NAME: return redirect('/actors') form = ActorForm() if form.validate_on_submit(): name = form.name.data surname = form.surname.data role = form.role.data bio = form.bio.data actors_model = ActorsModel(db.get_connection()) actors_model.insert(name, surname, role, bio) return redirect('/actors') return render_template('actor_form.html', title='Добавление актёра', form=form)
def create_actor_form(): try: form = ActorForm() return render_template('new_actor.html', form=form, data=session['user_info']) except: abort(500)
def edit_actor(actor_id): actor = json.loads( requests.get(url + '/actors/' + str(actor_id), headers={'Authorization': 'Bearer ' + session['access_token']}).text)['actor'] form = ActorForm() form.name.data = actor['name'] form.age.data = actor['age'] form.gender.data = actor['gender'] form.image_link.data = actor['image_link'] return render_template('form_actors.html', form=form)
def edit_actor(payload, actor_id): form = ActorForm() actor = Actor.query.get(actor_id) if not actor: abort(404) if actor: form.name.data = actor.name form.age.data = actor.age form.gender.data = actor.gender form.contact.data = actor.contact form.place_of_birth.data = actor.place_of_birth form.has_bio.data = actor.has_bio form.image_link.data = actor.image_link form.bio.data = actor.bio return render_template('forms/edit_actor.html', form=form, actor=actor), 200
def dashboard_add_actor(request): context = RequestContext(request) if request.method == 'POST': form = ActorForm(request.POST, request.FILES) if form.is_valid(): form.save() return HttpResponseRedirect('/movies/dashboard') return render_to_response("movie_library/dashboard/add_actor.html", { "form": form, 'dashboard_active': 'active' }, context) elif request.method == 'GET': form = ActorForm() return render_to_response("movie_library/dashboard/add_actor.html", { "form": form, 'dashboard_active': 'active' }, context)
def new_actors_form(): form = ActorForm() return render_template('form_actors.html', form=form)
def create_actor_form(payload): form = ActorForm() return render_template('forms/new_actor.html', form=form), 200