def offer_post(request): if request.method == "POST": form = OfferForm(request.POST) if form.is_valid(): redirect_to = resolve_url('/partime/manage/') user = get_user(request) form.save(user) return HttpResponseRedirect(redirect_to) else: form = OfferForm() return render(request, 'partime/offer/offer_post.html', {'form': form, 'url': 'partime:offer_post'})
def offer_update(request, id): user = get_user(request) user_info = get_user_info(user) instance = get_object_or_404(Offer, id=id, employer=user_info) if request.method == "POST": form = OfferForm(request.POST, instance=instance) if form.is_valid(): redirect_to = resolve_url('/partime/manage/') form.save() return HttpResponseRedirect(redirect_to) else: form = OfferForm(instance=instance) return render(request, 'partime/offer/offer_post.html', {'form': form, 'url': 'partime:offer_update', 'id': id})