Example #1
0
def experience_add(request, resume_id, work_id):
    # creates and saves new experience object using submitted form data 

    if request.method == 'POST':
        #exp_instance = (Experience.objects.get(pk=pk) or None)
        form = ExperienceForm(request.POST)

        if form.is_valid():
            experience = form.save(commit=False)
            experience.user = request.user
            experience.resume_id = Resume.objects.get(pk=resume_id)
            experience.work_id = Work.objects.get(pk=work_id)
            experience.save()

            context = {'pk': work_id, 'resume_id': resume_id}
            args = (resume_id, work_id)
        return HttpResponseRedirect(reverse('index'))

    else: # create form to make new resume
        form = ExperienceForm(initial={'user': request.user})
        context = {}
        context.update(csrf(request))
        context['form'] = form

        return render_to_response('builder/model_add.html',context)
def experience_update(request, resume_id, work_id, pk):
    # saves data to existing Experience model instance using modified form data
    if request.method == 'POST':
        exp_instance = (Experience.objects.get(pk=pk) or None)
        form = ExperienceForm(request.POST, instance=exp_instance)

        if form.is_valid():
            model = form.save(commit=False)
            model.user = request.user
            model.pk = pk
            model.resume_id = Resume.objects.get(pk=resume_id)
            model.work_id = Work.objects.get(pk=work_id)
            model.save()
        return HttpResponseRedirect('/')
    else:
        return HttpResponseRedirect('/')
Example #3
0
def experience_update(request, resume_id, work_id, pk):
    # saves data to existing Experience model instance using modified form data
    if request.method == 'POST':
        exp_instance = (Experience.objects.get(pk=pk) or None)
        form = ExperienceForm(request.POST,instance=exp_instance)

        if form.is_valid():
            model = form.save(commit=False)
            model.user = request.user
            model.pk = pk
            model.resume_id = Resume.objects.get(pk=resume_id)
            model.work_id = Work.objects.get(pk=work_id)
            model.save()
        return HttpResponseRedirect('/')
    else:
        return HttpResponseRedirect('/')
def experience_edit(request, resume_id, work_id, pk):
    # renders editable html form populated with data from existing work instance

    if not Work.objects.get(pk=work_id) == Experience.objects.get(
            pk=pk).work_id:
        return HttpResponseRedirect(reverse('resume_index'))

    exp_instance = Experience.objects.get(pk=pk)
    form = ExperienceForm(instance=exp_instance)
    context = {'form': form}

    return render(request, 'builder/model_form.html', context)
Example #5
0
def edit_experience(id):
    experience = Experience.query.get(id)
    edit_experience = ExperienceForm(
        name=experience.name,
        position=experience.position,
        time=experience.time,
        link=experience.link,
        description=experience.description,
    )
    if edit_experience.validate_on_submit():
        experience.name = edit_experience.name.data
        experience.position = edit_experience.position.data
        experience.time = edit_experience.time.data
        experience.link = edit_experience.link.data
        experience.description = edit_experience.description.data
        db.session.commit()
        return redirect(url_for("main_page.home") + "#Experience")

    return render_template("form_page.html",
                           form=edit_experience,
                           title="Experience")
Example #6
0
def add_experience():
    experience_query = Experience.query.filter_by(general_id=current_user.id)
    form = ExperienceForm()
    if request.method == "POST" and form.validate_on_submit():
        exp_query_count = 1
        if experience_query:
            exp_query_count = experience_query.count() + 1
        new_experience = Experience(
            name=form.name.data,
            position=form.position.data,
            time=form.time.data,
            link=form.link.data,
            description=form.description.data,
            general=current_user,
            order_exp=exp_query_count,
        )
        db.session.add(new_experience)
        db.session.commit()
        return redirect(url_for("main_page.home") + "#Experience")

    return render_template("form_page.html", form=form, title="Experience")
def experience_add(request, resume_id, work_id):
    # creates and saves new experience object using submitted form data

    if request.method == 'POST':
        #exp_instance = (Experience.objects.get(pk=pk) or None)
        form = ExperienceForm(request.POST)

        if form.is_valid():
            experience = form.save(commit=False)
            experience.user = request.user
            experience.resume_id = Resume.objects.get(pk=resume_id)
            experience.work_id = Work.objects.get(pk=work_id)
            experience.save()

            context = {'pk': work_id, 'resume_id': resume_id}
            args = (resume_id, work_id)
        return HttpResponseRedirect(reverse('index'))

    else:  # create form to make new resume
        form = ExperienceForm(initial={'user': request.user})
        context = {}
        context.update(csrf(request))
        context['form'] = form

        return render_to_response('builder/model_add.html', context)