def general(): if request.method == 'POST': name = request.form['name'] phone = request.form['phone'] email = request.form['email'] website = request.form['website'] linkedin = request.form['linkedin'] summary = request.form['summary'] user = User() gen = General(name, phone, email, website, linkedin, summary) user.update_general(gen.data) user.to_db() return redirect(url_for('view.general')) user = User() if (request.args.get('warning') != None): return render_template('view/general.html', gen=user.data['general'], data=user.data, warning=request.args.get('warning')) return render_template('view/general.html', gen=user.data['general'], data=user.data)
def get_tex_file(): try: os.mkdir('instance/texfiles') except OSError: pass user = User() text = get_header(user.data['config']) text += get_general(user.data['general']) text += get_education(user.data['educations']) text += get_experience(user.data['experiences']) text += get_project(user.data['projects']) text += get_publication(user.data['publications']) text += get_skill(user.data['skills']) text += get_footer() text = text.replace('&', '\&') try: os.mkdir('instance/texfiles/{}'.format(get_hash( session.get('user_id')))) except OSError: pass with open( 'instance/texfiles/{}/main.tex'.format( get_hash(session.get('user_id'))), 'w') as file: file.write(text) file.close()
def signup(): if session.get('user_id') is not None: return redirect(url_for('index')) if request.method == 'POST': username = request.form.get('username') password = request.form.get('password') confirm = request.form.get('confirm_password') error = None db = get_db() user = User(signup=True) if password != confirm: error = 'Entered passwords don\'t match' elif db.execute( 'SELECT id FROM user WHERE username = ?', (username,) ).fetchone() is not None: error = 'User {} is already registered'.format(username) if error is None: db.execute( 'INSERT INTO user (username, password_hash, resume_data) VALUES (?, ?, ?)', (username, generate_password_hash(password), dumps(user.data)) ) db.commit() return redirect(url_for('auth.signin')) return render_template('auth/signup.html', error=error) return render_template('auth/signup.html')
def generate(): user = User() if user.data['general'] == None: return redirect( url_for( 'view.general', warning= "Please fill this information before generating the resume.")) get_tex_file() param = { 'url': urljoin( ENV_VAR['BASE_URL'], url_for('view.raw_data', filename=get_hash(session.get('user_id')))) } compile_base = "https://latexonline.cc/compile?" url = compile_base + urlencode(param) # return redirect(url_for('view.raw_data', filename=get_hash(session.get('user_id')))) return redirect(url)
def education(index): user = User() user.remove_education(index) user.to_db() return redirect(url_for('view.education'))
def experience(index): user = User() user.remove_experience(index) user.to_db() return redirect(url_for('view.experience'))
def publication(index): user = User() user.remove_publication(index) user.to_db() return redirect(url_for('view.publication'))
def skill(index): user = User() user.removeSkill(index) user.to_db() return redirect(url_for('view.skills'))
def project(index): user = User() user.remove_project(index) user.to_db() return redirect(url_for('view.project'))
def skills(): if request.method == 'POST': skill = request.form['skill'] user = User() user.add_skill(skill) user.to_db() return redirect(url_for('view.skills')) user = User() return render_template('view/skills.html', skills=user.data['skills'], data=user.data)
def publication(): if request.method == 'POST': title = request.form.get('title') journal = request.form.get('journal') link = request.form.get('link') date = request.form.get('date') user = User() pub = Publication(title, date, journal, link) user.add_publication(pub.data) user.to_db() return redirect(url_for('view.publication')) user = User() return render_template('add/publication.html', data=user.data)
def education(): if request.method == 'POST': institute = request.form.get('institute') title = request.form.get('title') start = request.form.get('start') end = request.form.get('end') description = request.form.get('description') user = User() edu = Education(institute, title, start, end, description) user.add_education(edu.data) user.to_db() return redirect(url_for('view.education')) user = User() return render_template('add/education.html', data=user.data)
def experience(): if request.method == 'POST': workplace = request.form.get('workplace') title = request.form.get('title') start = request.form.get('start') end = request.form.get('end') description = request.form.get('description') user = User() exp = Experience(workplace, title, start, end, description) user.add_experience(exp.data) user.to_db() return redirect(url_for('view.experience')) user = User() return render_template('add/experience.html', data=user.data)
def config(): if request.method == 'POST': font = int(request.form['font']) horizontal = request.form['horizontal'] vertical = request.form['vertical'] user = User() conf = Config(font, horizontal, vertical) user.update_conf(conf.data) user.to_db() return redirect(url_for('view.config')) user = User() return render_template('view/config.html', conf=user.data['config'], data=user.data)
def add(): if request.method == 'POST': field = request.form['field'] if field == 'edu': return redirect(url_for('add.education')) elif field == 'exp': return redirect(url_for('add.experience')) elif field == 'pro': return redirect(url_for('add.project')) elif field == 'pub': return redirect(url_for('add.publication')) return redirect(url_for('view.add')) user = User() return render_template('view/add.html', data=user.data)
def project(): if request.method == 'POST': title = request.form.get('title') subtitle = request.form.get('subtitle') start = request.form.get('start') end = request.form.get('end') link = request.form.get('link') description = request.form.get('description') if len(link) == 0: link = None user = User() pro = Project(title, start, end, subtitle, link, description) user.add_project(pro.data) user.to_db() return redirect(url_for('view.project')) user = User() return render_template('add/project.html', data=user.data)
def experience(): user = User() return render_template('view/experience.html', exps=user.data['experiences'], data=user.data)
def education(): user = User() return render_template('view/education.html', edus=user.data['educations'], data=user.data)
def project(): user = User() return render_template('view/project.html', pros=user.data['projects'], data=user.data)
def publication(): user = User() return render_template('view/publication.html', pubs=user.data['publications'], data=user.data)