def add_skill(engineer): engineer = User.query.filter_by(engineer=engineer).first_or_404() form = SkillForm() if form.validate_on_submit(): skill = Skills(skill_name=form.skill_name.data, skill_strength=form.skill_strength.data, engineer=engineer, skill_engineer=engineer.engineer) print "skill is:" + repr(skill) db.session.add(skill) db.session.commit() skill_list = engineer.skills.all() return render_template('skills.html', title='Engineer Skills', engineer=engineer.engineer, skills=skill_list) return render_template('add_skill.html', title='Add a Skill', engineer=engineer.engineer, form=form)
def crtSkill(request): """ Form for creating a skill """ context = RequestContext(request) if request.method=='POST': skillform = SkillForm(data=request.POST) if skillform.is_valid(): if Skill.objects.filter(name=skillform.cleaned_data['name']).count() <= 0: s = Skill() s.name = skillform.cleaned_data['name'] s.lvl = skillform.cleaned_data['lvl_unlock'] if skillform.cleaned_data['condition'] == 'y': s.isPassive = True else: s.isPassive = False s.save() s.effect = skillform.cleaned_data['effect'] s.save() return render_to_response('system/main.html', {'skillform': skillform}, context) else: print "cant add" raise CommandError("Can't create entry-> entry already exists ") else: print skillform.errors else: skillform = SkillForm() return render_to_response('system/create/skills.html', {'skillform': skillform}, context)
def add_skill(): form = SkillForm(request.form) if request.method == 'POST' and form.validate(): skill_name = form.skill_name.data skills = skill_name.split(',') #print(skills,file=sys.stderr) # Create Cursor cur = mysql.connection.cursor() # Get user id result = cur.execute("SELECT id FROM users WHERE username = %s", [session['username']]) user_id = cur.fetchone() print(user_id['id'], file=sys.stderr) # Execute size = len(skills) for i in range(0, size): cur.execute( "INSERT INTO skills (skill_name, has_skill) VALUES(%r, %s)", [skills[i], user_id['id']]) # Commit to DB mysql.connection.commit() #Close connection cur.close() flash('Skill Added', 'success') return redirect(url_for('dashboard')) return render_template('add_skill.html', form=form)
def skill_view(request): if request.method == 'POST': f = SkillForm(request.POST) if f.is_valid(): resume = Resume.objects.get(user=request.user) model = f.save(commit=False) model.resume = resume model.save() return render_resume(request, tab='skill') return redirect('/resume')
def add_skill(): """Route to add skill to database and redirect to index page""" skills = mongo.db.Skills form = SkillForm() if request.method == 'POST' and form.validate_on_submit(): skills.insert( { 'skill_name': request.form.get('skill_name'), 'percent': int(request.form.get('percent')), 'skill_icon': request.form.get('skill_icon') }) return redirect(url_for('index')) return render_template('pages/add/skill.html', form=form)
def edit_skill(skill_id): """Route to edit skill in database and redirect to index page""" skills = mongo.db.Skills the_skill = mongo.db.Skills.find_one({'_id': ObjectId(skill_id)}) form = SkillForm() form.skill_name.data = the_skill['skill_name'] form.percent.data = the_skill['percent'] form.skill_icon.data = the_skill['skill_icon'] if request.method == 'POST' and form.validate_on_submit(): skills.update({'_id': ObjectId(skill_id)}, { 'skill_name': request.form.get('skill_name'), 'percent': int(request.form.get('percent')), 'skill_icon': request.form.get('skill_icon') }) return redirect(url_for('index')) return render_template('pages/edit/skill.html', skill=the_skill, form=form)
def addskill(): form = SkillForm() if form.validate_on_submit(): if request.method == 'POST': result = request.form cursor = connection1.cursor() values = list(result.values()) cursor.execute("select * from skill_list") l = cursor.fetchall() lit = [i[0] for i in l] if values[1] in lit: flash("Already skill exists", 'danger') return redirect(url_for('addskill')) else: cursor.execute("insert into skill_list(skill) values('" + values[1] + "')") connection1.commit() flash('Skill added successfully', 'success') return render_template('addskill.html', form=form)
def addSkill(): # define an error variable to be passed through if any errors that need to be prompted to the user occur error = None skill_form = SkillForm() # checks for a post request from the form submit button if request.method == 'POST': # if the validation from the wtform class passes continue if skill_form.validate_on_submit(): skills = [] for skill in current_user.get_skills(): skills.append(skill.skillType) if skill_form.skill.data not in skills: new_skill = Skill(skill_form.skill.data, current_user.id) # add and commit to the database db.session.add(new_skill) db.session.commit() return redirect(url_for('dashboard.userDashboard')) else: error = "You have all ready added that skill." else: error = "Invalid Skill Selected." return render_template('accounts/add_skill.html', skill_form=skill_form, error=error)
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 skill_edit_view(request, id = -1): if request.method == 'POST': f = SkillForm(request.POST, instance=Skill.objects.get(pk=id)) if f.is_valid(): f.save() return render_resume(request, tab='skill') elif id != -1: return render(request, 'edit/skill.html', { 'form': SkillForm(instance=Skill.objects.get(pk=id)), 'id': id }); return redirect('/resume')
def skills(): form = SkillForm() if request.method == "POST": soft = json.dumps(form.soft_skills.data) tech = json.dumps(form.tech_skills.data) langs = json.dumps(form.langs_known.data) urls = URLData(user=current_user.user, facebook=form.urls.facebook.data, twitter=form.urls.twitter.data, linkedin=form.urls.linkedin.data, stack_overflow=form.urls.stack_overflow.data, github=form.urls.github.data) sk = Skills(user=current_user.user, soft_skills=soft, tech_skills=tech, langs_known=langs) db.session.add_all([urls, sk]) db.session.commit() return render_template('display.html', user=json.dumps(soft)) return render_template('skills.html', form=form, title='ORM - Skills')
def addskill(): form = SkillForm() return render_template('addskill.html', form=form)