def apply(request): form = ApplicantForm() success = False if request.method == "POST": form = ApplicantForm(request.POST, request.FILES) if form.is_valid(): form.save() success = True pass return render_to_response( "apply.html", {"form": form, "success": success}, context_instance=RequestContext(request) )
def add_candidates(request): eid = employee.get_employee_by_user(request.user.id).id if request.method == 'POST': form = ApplicantForm(request.POST, request.FILES) if form.is_valid(): try: candi = form.save() return render(request, 'candidate_detail.html', {'candi': candi}) except Exception as ex: print ex else: form = ApplicantForm() return render(request, 'add_candidates.html', {'form': form, 'eid': eid})
def add_applicant(request, event_name): applicant = Applicant() if request.method == 'POST': form = ApplicantForm(request.POST, request.FILES, instance=applicant) if (form.is_valid()): app = form.save(commit=False) if not Applicant.objects.filter(norm_name=app.norm_name).exists(): event = Event.objects.get(name=event_name) app.event = event app.save() log_slack('Applicant %s added by %s' % (app.get_full_name(), request.user.mcuser.get_full_name())) return redirect('feedback:applicant_profile', event_name, applicant.norm_name) else: form = ApplicantForm(instance=applicant) context = { 'form': form, 'event_name': event_name } return render(request, 'feedback/add_applicant.html', context)
def edit_applicant(request, event_name, name): try: applicant = Applicant.objects.get(norm_name=normalize_name(name), event__name=event_name) except Applicant.DoesNotExist: raise Http404('Applicant does not exist.') if request.method == 'POST': form = ApplicantForm(request.POST, request.FILES, instance=applicant) if (form.is_valid()): app = form.save(commit=False) app.save() log_slack('Applicant %s/%s edited by %s' % (name, app.get_full_name(), request.user.mcuser.get_full_name())) return redirect('feedback:applicant_profile', event_name, app.norm_name) else: form = ApplicantForm(instance=applicant) context = { 'applicant': applicant, 'form': form, 'event_name': event_name } return render(request, 'feedback/edit_applicant.html', context)
def application(): from forms import ApplicantForm from models import ApplicantModel form = ApplicantForm() if form.validate_on_submit(): applicant = db.session.query(ApplicantModel).filter_by(email=form.email.data).first() if not applicant: applicant = ApplicantModel() db.session.add(applicant) else: unschedule_email(applicant) form.populate_obj(applicant) create_test(applicant) schedule_email(applicant) update_trello(applicant) send_message_slack(applicant) db.session.commit() return render_template('success.html') return render_template('application.html', form=form)
def offerDetailsView(request, slug_offer): offer = get_object_or_404( Offer, slug=slug_offer) if request.method == "POST": form = ApplicantForm(request.POST, request.FILES) if form.is_valid(): applicant_factory = ApplicantFactory() applicant = applicant_factory.get_instance_form(form=form) offer_applicant_factory = OfferApplicantFactory() offer_applicant = offer_applicant_factory.get_instance_form(applicant=applicant, offer=offer, form=form) offer_applicant_message = OfferApplicantMessage() offer_applicant_message.send(offer_applicant) return HttpResponseRedirect("/offer/%s/?success=1" % (offer.slug)) if request.method == "GET": if offer.is_finished() or offer.is_draft(): return error404(request) form = ApplicantForm() applicants_number = OfferApplicant.objects.filter(offer=offer, state=True).count() ctx = {'form': form, 'offer': offer, 'applicants_number':applicants_number} return render_to_response('offer_detail.html', ctx, context_instance=RequestContext(request))
def add_applicant(request, event_name): applicant = Applicant() if request.method == 'POST': form = ApplicantForm(request.POST, request.FILES, instance=applicant) if (form.is_valid()): app = form.save(commit=False) if not Applicant.objects.filter(norm_name=app.norm_name).exists(): event = Event.objects.get(name=event_name) app.event = event app.save() log_slack( 'Applicant %s added by %s' % (app.get_full_name(), request.user.mcuser.get_full_name())) return redirect('feedback:applicant_profile', event_name, applicant.norm_name) else: form = ApplicantForm(instance=applicant) context = {'form': form, 'event_name': event_name} return render(request, 'feedback/add_applicant.html', context)
def edit_applicant(request, event_name, name): try: applicant = Applicant.objects.get(norm_name=normalize_name(name), event__name=event_name) except Applicant.DoesNotExist: raise Http404('Applicant does not exist.') if request.method == 'POST': form = ApplicantForm(request.POST, request.FILES, instance=applicant) if (form.is_valid()): app = form.save(commit=False) app.save() log_slack('Applicant %s/%s edited by %s' % (name, app.get_full_name(), request.user.mcuser.get_full_name())) return redirect('feedback:applicant_profile', event_name, app.norm_name) else: form = ApplicantForm(instance=applicant) context = {'applicant': applicant, 'form': form, 'event_name': event_name} return render(request, 'feedback/edit_applicant.html', context)