Exemple #1
0
def category():
    form = CategoryForm(request.form)
    # adding a new category
    if request.method == 'POST' and 'go_back' not in request.form.keys():
        if form.validate() and form.no_special_characters():
            if Category.insert_new_category(form.category.data):
                return redirect(url_for('main.index'))
            else:
                form.add_error(ErrorMessages.CATEGORY_NOT_UNIQUE)
    elif request.method == 'POST' and 'go_back' in request.form.keys(
    ):  # going back to main page
        return redirect(url_for('main.index'))
    return render_template('content/index.html',
                           result_set=Skill.get_all_visible_skills(),
                           form=form,
                           admin_email=Config.ADMIN_EMAIL)
Exemple #2
0
def index():
    form = SkillForm(request.form)
    form.update_category_choices()
    # adding a new skill
    if request.method == 'POST' and 'skill' in request.form.keys(
    ) and 'new_category' not in request.form.keys():
        if form.validate() and form.no_special_characters():
            if Skill.insert_new_skill(
                    form.skill.data,
                    dict(form.category.choices).get(form.category.data)):
                return redirect(url_for('main.index'))
            else:
                form.add_error(ErrorMessages.SKILL_NOT_UNIQUE)
    # going to category form
    elif request.method == 'POST' and 'skill' in request.form.keys(
    ) and 'new_category' in request.form.keys():
        return redirect(url_for('content.category'))
    return render_template('content/index.html',
                           result_set=Skill.get_all_visible_skills(),
                           form=form,
                           admin_email=Config.ADMIN_EMAIL)
Exemple #3
0
def index():
    if current_user.is_authenticated:
        return redirect(url_for('content.index'))
    return render_template('index.html', result_set=Skill.get_all_visible_skills(), admin_email=Config.ADMIN_EMAIL)