Exemplo n.º 1
0
    def get(self, request, vacancy_update: int):
        specialties = Specialty.objects.all()
        all_applications = Application.objects.all()
        current_vacancy = vacancy_update
        vacancy_form = VacancyForm()
        if vacancy_form.is_valid():
            vacancy_form.save()
        application_form = ApplicationForm()
        if application_form.is_valid():
            application_form.save()
        applications = Application.objects.all()
        paginator = Paginator(applications, 5)
        page = self.request.GET.get('page')
        try:
            applications = paginator.page(page)
        except PageNotAnInteger:
            # If page is not an integer, deliver first page.
            applications = paginator.page(1)
        except EmptyPage:
            # If page is out of range (e.g. 9999), deliver last page of results.
            applications = paginator.page(paginator.num_pages)

        context = {
            'vacancy_form': vacancy_form,
            'all_applications': all_applications,
            'specialties': specialties,
            'current_vacancy': current_vacancy,
            'application_form': application_form,
            'vacancies': Vacancy.objects.all(),
            'applications': applications,
        }

        return render(request,
                      'recruitment/vacancy_update.html',
                      context=context)
Exemplo n.º 2
0
    def get(self, request, vacancy_id: int):
        vacancy = Vacancy.objects.filter(id=vacancy_id).first()
        if not vacancy:
            raise Http404

        application_form = ApplicationForm()
        if application_form.is_valid():
            application_form.save()
        context = {
            'vacancy': vacancy,
            'application_form': application_form,
        }
        return render(request, 'recruitment/vacancy.html', context=context)
Exemplo n.º 3
0
def process_application(request):
	if request.method == 'POST':
		print request.META['REMOTE_ADDR']
		af = ApplicationForm(request.POST)
		if af.is_valid():
			a = af.save(commit=False)
			a.header = a.character_name + " " + str(a.level) + " " + a.race + " " + a.xclass
			a.save()
			af.save_m2m()
			return HttpResponseRedirect(reverse('recruitment:applications'))
	return render(request, 'recruitment/apply.html', { 'application_form': af })
Exemplo n.º 4
0
    def post(self, request, vacancy_id: int, *args, **kwargs):
        application_form = ApplicationForm(request.POST)
        if application_form.is_valid():
            application = application_form.save(commit=False)
            application.user = request.user
            application.vacancy = Vacancy.objects.filter(id=vacancy_id).first()
            application_form.save()

        context = {
            'application_form': application_form,
        }
        return render(request, 'recruitment/sent.html', context=context)

        if not application_form.is_valid():
            application_form.save()

        context = {
            'application_form': application_form,
            'application_form.errors': application_form.errors,
        }

        return render(request, 'recruitment/vacancy.html', context=context)
Exemplo n.º 5
0
def apply_for_position(request):
    def join_preferred_positions(pfs):
        pfs = [p for p in pfs if p]
        pfslen = len(pfs)
        if pfslen == 1:
            return pfs[0]
        elif pfslen == 2:
            return _(u"and").join(unicode(pfs))
        else:
            return u"%s, %s %s %s" % (pfs[0], _(u"and"), pfs[1], pfs[2])

    # TODO: Make the process more user friendly.
    aform = ApplicationForm(request.POST or None)
    if request.method == "POST":
        if aform.is_valid():
            application = aform.save(commit=False)
            application.person = Person.objects.get(user=request.user)
            application.save()

            messages.success(
                request,
                _(
                    u"Thank you for applying to %s. You will within 24 hours receieve a confirmation mail with further instructions."
                )
                % join_preferred_positions(
                    (application.preferred_position1, application.preferred_position2, application.preferred_position3)
                ),
            )

            return HttpResponseRedirect(reverse("mypage") + u"#applications")

    return render(
        request,
        "recruitment/register.html",
        {"page_title": _(u"Apply for position"), "button_text": _(u"Save!"), "form": aform},
    )