Exemplo n.º 1
0
def view(id=None, level_id=None):
    level = None

    if level_id:
        level = get_or_404(Level, id=level_id)

    elif current_user.grade:
        level = Level.objects.get(description=current_user.grade)

    if not current_user.grade:
        form = update_details_form()

        if form.validate_on_submit():
            current_user.update(grade=form.grade.data)
            flash('Successfully updated profile')
            return redirect(url_for('.view', id=id))

    not_linked = Competency.objects.filter(
        id__nin=[c.id for c in current_user.competencies])

    return render_template(
        'competency/view.html',
        level=level,
        competency=get_or_404(Competency, id=id),
        comps_not_linked=not_linked)
Exemplo n.º 2
0
def link_staff(id):
    note = get_or_404(LogEntry, entry_type='log', id=id)

    member = get_or_404(User, id=request.form['user_id'])

    note.link(member)
    return redirect(url_for('.view', id=id))
Exemplo n.º 3
0
def link_staff(id):
    note = get_or_404(LogEntry, entry_type='log', id=id)

    member = get_or_404(User, id=request.form['user_id'])

    note.link(member)
    return redirect(url_for('.view', id=id))
Exemplo n.º 4
0
def competency_json(id, level_id):
    level = get_or_404(Level, id=level_id)
    competency = get_or_404(Competency, id=id)
    return jsonify({
        'competency': competency,
        'level': level,
        'behaviours': competency.behaviours(level),
        'next_level': level.next,
        'prev_level': level.prev})
Exemplo n.º 5
0
def link(id, link_id):
    objective = get_objective_or_404(id)
    get_or_404(Link, id=link_id)

    if request.method == 'DELETE':
        objective.remove_link(link_id)
        return jsonify({})

    return jsonify({})
Exemplo n.º 6
0
def unlink(id, other_id):
    competency = get_or_404(Competency, id=id)
    other = get_or_404(LogEntry, id=other_id)

    if competency.unlink(other):
        flash("Removed link")

    else:
        flash("Failed to remove link", "error")

    return redirect(url_for(".view", id=id))
Exemplo n.º 7
0
def unlink(id, other_id):
    competency = get_or_404(Competency, id=id)
    other = get_or_404(LogEntry, id=other_id)

    if competency.unlink(other):
        flash('Removed link')

    else:
        flash('Failed to remove link', 'error')

    return redirect(url_for('.view', id=id))
Exemplo n.º 8
0
def get_link_target(data):
    _type = None
    target = None

    if 'competencies' in data:
        _type = 'Competency'
        target = get_or_404(Competency, id=data['competencies'])

    elif 'notes' in data:
        _type = 'Note'
        target = get_or_404(current_user.notes, id=data['notes'])

    return _type, target
Exemplo n.º 9
0
def get_link_target(data):
    _type = None
    target = None

    if 'objectives' in data:
        _type = 'Objective'
        target = get_or_404(current_user.objectives, id=data['objectives'])

    elif 'notes' in data:
        _type = 'Note'
        target = get_or_404(current_user.notes, id=data['notes'])

    return _type, target
Exemplo n.º 10
0
def view_all_for_user(user_id):
    user = get_or_404(User, id=user_id)

    if user not in current_user.staff:
        abort(403)

    return render_template('objectives/view_all.html', user=user)
Exemplo n.º 11
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)
Exemplo n.º 12
0
def remove_evidence(id, evidence_id):
    objective = get_objective_or_404(id=id)
    evidence = get_or_404(LogEntry, entry_type='evidence', id=evidence_id)
    objective.unlink(evidence)
    evidence.delete()
    flash('Evidence removed')
    return redirect(url_for('.view', id=id))
Exemplo n.º 13
0
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)
Exemplo n.º 14
0
def view_all_for_user(user_id):
    user = get_or_404(User, id=user_id)

    if user not in current_user.staff:
        abort(403)

    return render_template('objectives/view_all.html', user=user)
Exemplo n.º 15
0
def remove_evidence(id, evidence_id):
    objective = get_objective_or_404(id=id)
    evidence = get_or_404(LogEntry, entry_type='evidence', id=evidence_id)
    objective.unlink(evidence)
    evidence.delete()
    flash('Evidence removed')
    return redirect(url_for('.view', id=id))
Exemplo n.º 16
0
def unlink(id, link_id):
    note = get_or_404(LogEntry, entry_type='log', id=id)

    note.unlink(link_id)

    flash('Removed link')

    return redirect(url_for('.view', id=id))
Exemplo n.º 17
0
def unlink(id, link_id):
    note = get_or_404(LogEntry, entry_type='log', id=id)

    note.remove_link(link_id)

    flash('Removed link')

    return redirect(url_for('.view', id=id))
Exemplo n.º 18
0
def view(id=None, level_id=None):
    level = None

    if level_id:
        level = get_or_404(Level, id=level_id)

    elif current_user.grade:
        level = Level.objects.get(description=current_user.grade)

    if not current_user.grade:
        form = update_details_form()

        if form.validate_on_submit():
            current_user.update(grade=form.grade.data)
            flash("Successfully updated profile")
            return redirect(url_for(".view", id=id))

    return render_template("competency/view.html", level=level, competency=get_or_404(Competency, id=id))
Exemplo n.º 19
0
def view_json(id):
    note = get_or_404(LogEntry, entry_type='log', id=id)

    if request.method in ['PATCH', 'PUT']:
        note.entry.update(**entry_from_json('log', request.json))
        note.add_tags(request.json.get('tags', []))
        note.reload()

    return jsonify(note.to_json())
Exemplo n.º 20
0
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))
Exemplo n.º 21
0
def comment(user_id, id):
    user = get_or_404(User, id=user_id)

    if user not in current_user.staff:
        abort(403)

    objective = get_objective_or_404(id=id)

    objective.add_comment(request.form['content'])

    return redirect(url_for('.view_for_user', user_id=user_id, id=id))
Exemplo n.º 22
0
def comment(user_id, id):
    user = get_or_404(User, id=user_id)

    if user not in current_user.staff:
        abort(403)

    objective = get_objective_or_404(id=id)

    objective.add_comment(request.form['content'])

    return redirect(url_for('.view_for_user', user_id=user_id, id=id))
Exemplo n.º 23
0
def view_for_user(user_id, id):
    user = get_or_404(User, id=user_id)

    if user not in current_user.staff:
        abort(403)

    objective = get_objective_or_404(id=id)

    return render_template(
        'objectives/view.html',
        objective=objective,
        user=user)
Exemplo n.º 24
0
def link(id):
    competency = get_or_404(Competency, id=id)
    _type, target = get_link_target(request.form)

    if target:
        competency.link(target)
        flash('{} successfully linked to competency'.format(_type))

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

    return redirect(url_for('.view', id=id))
Exemplo n.º 25
0
def view_for_user(user_id, id):
    user = get_or_404(User, id=user_id)

    if user not in current_user.staff:
        abort(403)

    objective = get_objective_or_404(id=id)

    return render_template(
        'objectives/view.html',
        objective=objective,
        user=user)
Exemplo n.º 26
0
def reply_to_feedback(id):
    form = FeedbackForm()
    feedback_request = get_or_404(LogEntry, id=id)

    if form.validate_on_submit():
        feedback_request.entry.update(replied=True, details=form.feedback.data)
        flash("Saved feedback")

        return redirect(url_for('feedback.give_feedback'))

    return render_template('feedback/give-feedback.html',
                           form=form,
                           feedback_request=feedback_request)
Exemplo n.º 27
0
def promote_note(id, note_id):
    note = get_or_404(LogEntry, entry_type='log', id=note_id)

    evidence = create_log_entry(
        'evidence',
        title=note.entry.title,
        content=note.entry.content)

    objective = get_objective_or_404(id=id)
    objective.link(evidence)

    flash('Evidence created from note')

    return redirect(url_for('.view', id=id))
Exemplo n.º 28
0
def promote_note(id, note_id):
    note = get_or_404(LogEntry, entry_type='log', id=note_id)

    evidence = create_log_entry(
        'evidence',
        title=note.entry.title,
        content=note.entry.content)

    objective = get_objective_or_404(id=id)
    objective.link(evidence)

    flash('Evidence created from note')

    return redirect(url_for('.view', id=id))
def reply_to_feedback(id):
    form = FeedbackForm()
    feedback_request = get_or_404(LogEntry, id=id)

    if form.validate_on_submit():
        feedback_request.entry.update(
            replied=True,
            details=form.feedback.data)
        flash("Saved feedback")

        return redirect(url_for('feedback.give_feedback'))

    return render_template(
        'feedback/give-feedback.html',
        form=form,
        feedback_request=feedback_request)
Exemplo n.º 30
0
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))
Exemplo n.º 31
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))
def view_requested_feedback(id):
    feedback_request = get_or_404(LogEntry, id=id, entry_type='feedback')

    return render_template(
        'feedback/view-feedback.html',
        feedback_request=feedback_request)
Exemplo n.º 33
0
def member(id):
    member = get_or_404(User, id=id)
    return render_template('staff/member.html', member=member)
Exemplo n.º 34
0
def add_staff(**member_data):
    member = get_or_404(User, **member_data)
    current_user.add_staff(member)
Exemplo n.º 35
0
def get_objective_or_404(**kwargs):
    return get_or_404(LogEntry, entry_type='objective', **kwargs)
Exemplo n.º 36
0
 def get_or_404(self, cls, **kwargs):
     return get_or_404(cls, owner=self, **kwargs)
Exemplo n.º 37
0
 def get_or_404(self, cls, **kwargs):
     return get_or_404(cls, owner=self, **kwargs)
Exemplo n.º 38
0
def view(id):
    note = get_or_404(LogEntry, entry_type='log', id=id)

    return render_template('notes/view.html', note=note)
Exemplo n.º 39
0
def view_requested_feedback(id):
    feedback_request = get_or_404(LogEntry, id=id, entry_type='feedback')

    return render_template('feedback/view-feedback.html',
                           feedback_request=feedback_request)
Exemplo n.º 40
0
def get_objective_or_404(**kwargs):
    return get_or_404(LogEntry, entry_type='objective', **kwargs)
Exemplo n.º 41
0
def add_staff(**member_data):
    member = get_or_404(User, **member_data)
    current_user.add_staff(member)
    current_user.reload()
Exemplo n.º 42
0
def member(id):
    member = get_or_404(User, id=id)
    return render_template('staff/member.html', member=member)
Exemplo n.º 43
0
def view(id):
    note = get_or_404(LogEntry, entry_type='log', id=id)
    return render_template('notes/view.html', note=note)