Beispiel #1
0
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})
Beispiel #2
0
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)
Beispiel #3
0
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)
Beispiel #4
0
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})
Beispiel #5
0
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)})
Beispiel #6
0
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)
Beispiel #7
0
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})
Beispiel #8
0
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)
Beispiel #9
0
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)
Beispiel #10
0
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)
Beispiel #11
0
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))