Exemplo n.º 1
0
def concept(context_id=None, concept_id=None):
    if concept_id is not None:
        concept = Concept.get_concept_by_id(concept_id)
    else:
        return render_template('concept.html', error="Invalid concept.")
    if context_id is not None:
        context = Context.get_context(context_id)
    else:
        return render_template('concept.html', error="Invalid context.")
    assertions = concept.get_assertions()
    cocnept_assertions = context.assertions.all()
    return render_template('concept.html')
Exemplo n.º 2
0
def new_concept(context_id=None):
    if request.method == 'POST':
        text = request.form['concept_name']
        if text.strip() == "":
            return render_template('add_concept.html', \
                                   context_id=context_id, \
                                   error="Concept cannot be blank.")
        # TODO(a33kuo): Should be replaced by get_or_create() method.
        concept = Concept.get_concept(text, session['user_language'])
        if concept is None:
            concept = Concept(text, session['user_language'])
            concept.add()
        context = Context.get_context(context_id)
        concept.add_context(context)
        if context_id is not None:
            return redirect('/context/' + context_id)
        else:
            return redirect('/context/')
    else:
        return render_template('add_concept.html', context_id=context_id)