def addAplication(request): if request.method == 'POST': form = ApplicationForm(request.POST, request.FILES) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('getbills:thankyou')) else: form = ApplicationForm() return render(request, 'getbills/index.html', {'form': form})
def edit(request, app_id): user = request.user app = Application.objects.get(pk=app_id) if app.user == user: form = ApplicationForm(request.POST or None, instance=app) if request.method == 'POST': if form.is_valid(): obj = form.save(commit=False) obj.save() return HttpResponseRedirect('/tracker/user/{0}/'.format(user.username)) else: print form.errors else: form = ApplicationForm(instance=app) else: return HttpResponse('User mismatch, permission denied.') content = { 'form': form, 'app': app } return render(request, 'tracker/edit.html', content)
def edit(request, app_id): user = request.user app = Application.objects.get(pk=app_id) if app.user == user: form = ApplicationForm(request.POST or None, instance=app) if request.method == 'POST': if form.is_valid(): obj = form.save(commit=False) obj.save() return HttpResponseRedirect('/tracker/user/{0}/'.format( user.username)) else: print form.errors else: form = ApplicationForm(instance=app) else: return HttpResponse('User mismatch, permission denied.') content = {'form': form, 'app': app} return render(request, 'tracker/edit.html', content)
def apply(request): if request.method == 'POST': form = ApplicationForm(request.POST) if form.is_valid(): application = form.save(commit=False) application.user = request.user application.save() return HttpResponseRedirect(reverse('applications')) else: form = ApplicationForm() return render(request, 'sok/apply.html', {'form': form})
def register(request): if request.method == 'POST': form = ApplicationForm(request.POST) if form.is_valid(): new_application = form.save() return render(request, 'thankyou.html') else: form = ApplicationForm() return render(request, 'register.html', {'form': form, 'now' : datetime.now(), 'close' : datetime(2013, 9, 16)})
def application_form(request, application_id): application = get_object_or_404(Application, project__owner=request.user, pk=application_id) context = {} if request.method == "POST": form = ApplicationForm(application.project, request.POST, instance=application, prefix='app_%d_' % application.id) if form.is_valid(): application = form.save() context['saved'] = True form = ApplicationForm(application.project, instance=application, prefix='app_%d_' % application.id) else: form = ApplicationForm(application.project, instance=application, prefix='app_%d_' % application.id) context.update({'application_form': form, 'application': application}) return render_response(request, 'application_form.html', context)
def __save_record(request): # create a new one form = ApplicationForm(request.POST) if form.is_valid(): user = request.user application = form.save(commit=False) application.user = user if not application.date: application.date = datetime.date.today() application.save() app_list = JobApplication.objects.filter(user=user) return render(request, 'applications/applications.html', {'app_list': app_list}) else: return render(request, 'applications/new_record.html', {'form': form})
def addapp(request): if request.method == 'POST': app = Application(user=request.user) form = ApplicationForm(request.POST, instance=app) if form.is_valid(): form.save(commit=True) return HttpResponseRedirect('/tracker/user/{0}/'.format(request.user.username)) else: print form.errors else: form = ApplicationForm() content = { 'form': form } return render(request, 'tracker/addapp.html', content)
def addapp(request): if request.method == 'POST': app = Application(user=request.user) form = ApplicationForm(request.POST, instance=app) if form.is_valid(): form.save(commit=True) return HttpResponseRedirect('/tracker/user/{0}/'.format( request.user.username)) else: print form.errors else: form = ApplicationForm() content = {'form': form} return render(request, 'tracker/addapp.html', content)
def ajax_add_application(request): #TODO: ajax prefix not needed form = ApplicationForm(request.POST, request.project) if form.is_valid(): form.save() return {} return HttpResponse(unicode(form.errors))