def createResume():
    '''
    Add a new resume to the resume dashboard. Resumes are
    given a unique URL that users can share them. They are accessible
    to anyone with the URL.
    '''
    if 'username' not in login_session:
        return redirect(url_for('welcome'))
    form = ResumeForm()
    if request.method == 'POST' and form.validate_on_submit():
        user = getUserInfo(user_id=login_session['user_id'])
        #Create unique code for resume to use in the resume's URL.
        code = ''.join(random.choice(string.ascii_uppercase + string.digits)
                        for x in xrange(6))

        #In the unlikely event resume code already exists, create a new one.
        while session.query(Resume).filter_by(code = code).first():
            code = ''.join(random.choice(string.ascii_uppercase + string.digits)
                            for x in xrange(6))

        #Store the courses required for the resume.
        course_ids_for_resume = request.form.getlist('course')
        for course_id in course_ids_for_resume:
            courseAndResume = ResumeCourse(code = code, course_id = course_id)
            session.add(courseAndResume)
        newResume = Resume(code = code, user_id = user.id, title = form.title.data)
        session.add(newResume)
        session.commit()
        flash('New Resume Successfully Created')
        return redirect(url_for('fullResumeList', code=code, user_id = login_session['user_id']))
    else:
        courses = session.query(Course).filter_by(user_id = login_session['user_id'])
        return render_template('newresume.html', courses = courses, time = time.time(), form = form)
Exemple #2
0
def resume_view(request):
    if request.method == 'POST':
        f = ResumeForm(request.POST, instance=Resume.objects.get(user=request.user))
        if f.is_valid():
            f.save()
            return render_resume(request)
        else :
            print f.errors
            return render_resume(request)
    return render_resume(request, request.GET.get('tab'))
def create(request):
    # save entry to the resume model given data from submitted form

    if request.POST:
        instance = Resume.objects.get(request.user)
        form = ResumeForm(request.POST, instance)

        if form.is_valid():
            form.save()
            return HttpResponseRedirect('resume/about/create')
    else:
        form = ResumeForm(initial={'user': request.user})

    args = {}
    args.update(csrf(request))
    args['form'] = form

    return render_to_response('builder/create_resume.html',args)
def new_resume(request):
    # renders an empty form used to create new resume instance

    if request.method == 'POST':
        # create new resume from form
        form = ResumeForm(request.POST)

        if form.is_valid():
            resume = form.save(commit=False)
            resume.user = request.user
            resume.save()
        return HttpResponseRedirect('/resume/')

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

        return render_to_response('builder/create_resume.html',args)
Exemple #5
0
def render_resume(request, tab='general'):
    resume = Resume.objects.get(user=request.user)
    return render(request, 'resume.html', {
        'general_form': ResumeForm(instance=resume),
        'skill_form': SkillForm(),
        'experience_form': ExpForm(),
        'education_form': EduForm(),
        'language_form': LangForm(),
        'skills': Skill.objects.filter(resume=resume),
        'experience': Experience.objects.filter(resume=resume),
        'education': Education.objects.filter(resume=resume),
        'languages': Language.objects.filter(resume=resume),
        'tab':tab
    })
    
def create(request):
    # save entry to the resume model given data from submitted form

    if request.POST:
        instance = Resume.objects.get(request.user)
        form = ResumeForm(request.POST, instance)

        if form.is_valid():
            form.save()
            return HttpResponseRedirect('resume/about/create')
    else:
        form = ResumeForm(initial={'user': request.user})

    args = {}
    args.update(csrf(request))
    args['form'] = form

    return render_to_response('builder/create_resume.html', args)
def new_resume(request):
    # renders an empty form used to create new resume instance

    if request.method == 'POST':
        # create new resume from form
        form = ResumeForm(request.POST)

        if form.is_valid():
            resume = form.save(commit=False)
            resume.user = request.user
            resume.save()
        return HttpResponseRedirect('/resume/')

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

        return render_to_response('builder/create_resume.html', args)
Exemple #8
0
def edit(user):
    person = fluid_filter('fluiddb/users/username="******"' % user)
    if not person:
        abort(404)
    form = ResumeForm()
    person = Person(person[0], user)
    jobs = fluid_filter('has %s/employer' % user)
    jobs = [Work(uid, user) for uid in jobs]
    for job in jobs:
        form.jobs.append_entry()
        # join functions list to paragraph
        job.functions = r"\n".join(job.functions).strip()

    schools = fluid_filter('has %s/attended' % user)
    schools = [Education(uid, user) for uid in schools]
    for school in schools:
        form.schools.append_entry()

    if form.validate_on_submit():
        denied = False
        logging.debug('Valid form for %s' % user)
        password = form.person.password.data

        if not person.update_from_form(form.person):
            denied = True

        for job_form in form.jobs:
            # it seems that we get 1 or more phantom jobs here...
            if not job_form.url.data:
                continue
            # this seems kinda weird, but I'm not sure of a better way to
            # find the correct work object yet
            found_job = False
            logging.info("working on job: %s" % job_form.url.data)
            for job in jobs:
                if job.about == job_form.url.data:
                    if not job.update_from_form(job_form, password):
                        denied = True
                    found_job = True

            if not found_job:
                job = Work.create(job_form.url.data, user)
                if not job.update_from_form(job_form, password):
                    denied = True

        for school_form in form.schools:
            # it seems that we get 1 or more phantom schools here...
            if not school_form.url.data:
                continue
            # this seems kinda weird, but I'm not sure of a better way to
            # find the correct work object yet
            found_school = False
            logging.info("working on school: %s" % school_form.url.data)
            for school in schools:
                if school.about == school_form.url.data:
                    if not school.update_from_form(school_form, password):
                        denied = True
                    found_school = True

            if not found_school:
                school = Education.create(school_form.url.data, user)
                if not school.update_from_form(school_form, password):
                    denied = True

        if form.skills.data:
            OReillySkill.update_from_form(form.skills, user, password)

        if denied:
            flash("Permission Denied!", category='error')
        else:
            flash("Success!", category='info')

        # gotta reload the attributes to show changes
        person.reload_tags()
        for job in jobs:
            job.reload_tags()
        for school in schools:
            school.reload_tags()

    skills = fluid_filter('has %s/skill' % user)
    skills = [OReillySkill(uid) for uid in skills]
    skill_list = json.dumps([{'id'   : skill.uid,
                              'name' : skill.title}
                             for skill in skills])

    return render_template('edit.html', person=person, jobs=jobs,
                           schools=schools, form=form, user=user,
                           skill_list=skill_list)