示例#1
0
 def post(self, request, vacancy_id):
     if not request.user.is_authenticated:
         return redirect('login')
     form = ApplicationForm(request.POST)
     user = self.get_current_user(request)
     vacancy = self.get_vacancy(vacancy_id)
     if form.is_valid() and user is not None:
         form = form.save(commit=False)
         form.vacancy = vacancy
         form.user = user
         form.save()
         return redirect(f'/vacancies/{vacancy_id}/send/')
     return render(request,
                   self.template_name,
                   context={
                       'form': form,
                       'vacancy': vacancy,
                       'user': user
                   })
示例#2
0
 def post(self, request, vacancy):
     this_vacancy = get_object_or_404(Vacancy, id=vacancy)
     form = ApplicationForm(request.POST)
     if form.is_valid():
         application = form.save(commit=False)
         application.user = request.user
         application.vacancy = get_object_or_404(Vacancy, id=vacancy)
         application.save()
         return redirect('send_request_vacancy', vacancy)
     return render(request, 'vacancies/vacancy.html', {
         'form': form,
         'this_vacancy': this_vacancy
     })
示例#3
0
 def post(self, request, vacancy_id):
     form = ApplicationForm(request.POST)
     user = get_current_user(request)
     if user is None:
         return redirect('login')
     vacancy = Vacancy.objects.filter(
         pk=vacancy_id).select_related('specialty')
     if form.is_valid():
         application = form.save(commit=False)
         application.user = user
         application.vacancy = vacancy
         application.save()
         return redirect('send', vacancy_id)
     return render(request, 'vacancies/vacancy.html', {'form': form})
示例#4
0
    def post(self, request, *args, **kwargs):
        self.object = self.get_object()  # noqa
        form = ApplicationForm(request.POST or None)

        if form.is_valid():
            application = form.save(commit=False)

            application.vacancy = self.object

            if request.user.is_authenticated:
                application.user = self.request.user

            application.save()
            return self.form_valid(form)

        return self.form_invalid(form)
示例#5
0
    def post(self, request, vacancy_id):
        user = request.user
        if not user.is_authenticated:
            return HttpResponseRedirect(reverse('login'))

        vacancy = self.get_vacancy(vacancy_id)
        application_form = ApplicationForm(request.POST)
        if application_form.is_valid():
            application = application_form.save(commit=False)
            application.user = user
            application.vacancy = vacancy
            application.save()
            return HttpResponseRedirect(redirect_to='send')

        return render(request,
                      'vacancies/vacancy.html',
                      context={
                          'vacancy': vacancy,
                          'form': application_form
                      })