def edit(id=None):

    note = None
    link_form = None
    if id:
        note = get_or_404(LogEntry, entry_type='log', id=id)
        link_form = make_link_form(competencies=True, objectives=True)

    form = NoteForm()

    if form.validate_on_submit():

        if note:
            form.update(note)
            flash('Updated note')

        else:
            note = form.create()
            flash('Added note')

        return redirect(url_for('.view', id=note.id))

    if note:
        form.content.data = note.entry.content
        form.tags.data = ','.join(tag.name for tag in note.tags)

    return render_template(
        'notes/edit.html',
        form=form,
        link_form=link_form,
        note=note)
Beispiel #2
0
def edit(id=None):

    note = None
    if id:
        note = get_or_404(LogEntry, entry_type='log', id=id)

    form = make_link_form(form=NoteForm, competencies=True, objectives=True)

    if form.validate_on_submit():

        if note:
            form.update(note)
            flash('Updated note')

        else:
            note = form.create()
            flash('Added note')

        remove_broken_links(note, form.competencies.data)
        remove_broken_links(note, form.objectives.data)
        _link(note, dict(request.form.lists()))

        return redirect(url_for('.view', id=note.id))

    if note:
        form.content.data = note.entry.content
        form.tags.data = ','.join(tag.name for tag in note.tags)

    return render_template(
        'notes/edit.html',
        form=form,
        note=note)
def link(id):
    competency = get_or_404(Competency, id=id)
    form = make_link_form(objectives=True, notes=True)

    if form.validate_on_submit():
        objective = LogEntry.objects.get(id=request.form["objectives"], entry_type="objective")
        objective.link(competency)
        flash("Competency linked to selected objective")

    return redirect(url_for(".view", id=id))
def link(id):
    note = get_or_404(LogEntry, entry_type='log', id=id)
    form = make_link_form(competencies=True, objectives=True)

    if form.is_submitted():
        if 'competencies' in request.form:
            competency = Competency.objects.get(
                id=request.form['competencies'])
            note.link(competency)
            flash('Competency successfully linked to note')

        elif 'objectives' in request.form:
            objective = LogEntry.objects.get(
                id=request.form['objectives'],
                entry_type='objective')
            note.link(objective)
            flash('Objective successfully linked to note')

    return redirect(url_for('.view', id=id))
def link(id):
    objective = get_objective_or_404(id=id)
    form = make_link_form(competencies=True, notes=True)

    if form.is_submitted():
        if 'competencies' in request.form:
            competency = Competency.objects.get(
                id=request.form['competencies'])
            objective.link(competency)
            flash('Competency successfully linked to objective')

        elif 'notes' in request.form:
            note = LogEntry.objects.get(
                id=request.form['notes'],
                entry_type='log')
            objective.link(note)
            flash('Note successfully linked to objective')

    else:
        flash('Linking to competency failed', 'error')

    return redirect(url_for('.view', id=id))
Beispiel #6
0
def link(id):
    queue_links = False

    if id == 'add':
        queue_links = True

    else:
        note = get_or_404(LogEntry, entry_type='log', id=id)

    form = make_link_form(competencies=True, objectives=True)

    if form.is_submitted():

        if queue_links:
            links = session.get('links', {})
            for key, values in list(request.form.lists()):
                links[key] = values
            session['links'] = links

        elif _link(note, dict(request.form.lists())):
            flash('Link successful')

    return redirect(url_for('.view', id=id))