def edit_offer(request, offer_id): offer = Offer.objects.get(pk=offer_id) enterprise = Enterprise.objects.get(pk=request.user.id) # check if user has permission to edit this offer if offer.enterprise != enterprise: request.flash[ 'error_message'] = 'No tiene permisos para editar esta oferta' return redirect('bolsa_trabajo.views_enterprise.offer') # check first if offer is closed if offer.is_closed(): request.flash['error_message'] = "No puede editar una oferta cerrada" return redirect('bolsa_trabajo.views_enterprise.offer') if request.method == 'POST': form = OfferForm(request.POST) if form.is_valid(): offer.load_from_form(form) offer.save() request.flash['message'] = 'Oferta editada exitosamente' url = reverse('bolsa_trabajo.views_enterprise.offer_details', args=[offer.id]) return HttpResponseRedirect(url) else: form = OfferForm.create_from_offer(offer) close_form = OfferStatusForm() return append_user_to_response(request, 'enterprise/edit_offer.html', { 'offer': offer, 'offer_form': form, 'close_form': close_form, })
def add_offer(request): enterprise = Enterprise.objects.get(pk=request.user.id) error = None # If the enterprise has closed offers without feedback if enterprise.get_closed_offers_without_feedback(): request.flash[ 'error_message'] = 'No puede crear nuevas ofertas hasta entregar el feedback de las ya cerradas' return HttpResponseRedirect( reverse('bolsa_trabajo.views_enterprise.offer')) if request.method == 'POST': form = OfferForm(request.POST) if form.is_valid(): offer = Offer.create_from_form(enterprise, form) offer.save() UserProfile.notify_staff_of_new_offer() request.flash[ 'message'] = 'Oferta propuesta exitosamente, por favor espere a que un encargado la valide' url = reverse('bolsa_trabajo.views_account.index') return HttpResponseRedirect(url) else: form = OfferForm() return append_user_to_response(request, 'enterprise/add_offer.html', { 'offer_form': form, 'error': error })
def edit_offer(request, offer_id): offer = Offer.objects.get(pk=offer_id) enterprise = Enterprise.objects.get(pk=request.user.id) # check if user has permission to edit this offer if offer.enterprise != enterprise: request.flash['error_message'] = 'No tiene permisos para editar esta oferta' return redirect('bolsa_trabajo.views_enterprise.offer') # check first if offer is closed if offer.is_closed(): request.flash['error_message'] = "No puede editar una oferta cerrada" return redirect('bolsa_trabajo.views_enterprise.offer') if request.method == 'POST': form = OfferForm(request.POST) if form.is_valid(): offer.load_from_form(form) offer.save() request.flash['message'] = 'Oferta editada exitosamente' url = reverse('bolsa_trabajo.views_enterprise.offer_details', args=[offer.id]) return HttpResponseRedirect(url) else: form = OfferForm.create_from_offer(offer) close_form = OfferStatusForm() return append_user_to_response(request, 'enterprise/edit_offer.html', { 'offer': offer, 'offer_form': form, 'close_form': close_form, })
def add_offer(request): enterprise = Enterprise.objects.get(pk=request.user.id) error = None # If the enterprise has closed offers without feedback if enterprise.get_closed_offers_without_feedback(): request.flash['error_message'] = 'No puede crear nuevas ofertas hasta entregar el feedback de las ya cerradas' return HttpResponseRedirect(reverse('bolsa_trabajo.views_enterprise.offer')) if request.method == 'POST': form = OfferForm(request.POST) if form.is_valid(): offer = Offer.create_from_form(enterprise, form) offer.save() UserProfile.notify_staff_of_new_offer() request.flash['message'] = 'Oferta propuesta exitosamente, por favor espere a que un encargado la valide' url = reverse('bolsa_trabajo.views_account.index') return HttpResponseRedirect(url) else: form = OfferForm() return append_user_to_response(request, 'enterprise/add_offer.html', { 'offer_form': form, 'error': error })
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})