Esempio n. 1
0
def edit_note(note_id):
    '''
        App for editing a particular note
    '''
    form = AddNoteForm()
    form.tags.choices = functions.get_all_tags(session['id'])
    form.tags.default = functions.get_tag_using_note_id(note_id)
    form.tags.process(request.form)

    if form.tags.choices is None:
        form.tags = None

    if request.method == 'GET':
        data = functions.get_data_using_id(note_id)
        form.note_id.data = note_id
        form.note_title.data = data[0][3]
        form.note.data = data[0][5]
        return render_template('edit_note.html', form=form, username=session['username'], id=note_id)
    elif form.validate_on_submit():
        note_id = form.note_id.data
        note_title = request.form['note_title']
        note_markdown = form.note.data

        try:
            tags = form.tags.data
            tags = ','.join(tags)
        except:
            tags = None

        note = Markup(markdown.markdown(note_markdown))
        functions.edit_note(note_title, note, note_markdown, tags, note_id=note_id)
        return redirect('/profile/')
Esempio n. 2
0
def view_tag():
    '''
        App za pregled svih dostupnih oznaka
    '''
    tags = functions.get_all_tags(session['id'])
    return render_template('edit_tag.html',
                           tags=tags,
                           username=session['username'])
Esempio n. 3
0
def view_tag():
    '''
        App for viewing all available tags
    '''
    tags = functions.get_all_tags(session['id'])
    return render_template('edit_tag.html',
                           tags=tags,
                           username=session['username'])
Esempio n. 4
0
def delete_tag(tag_id):
    '''
        App za brisanje određene oznake
    '''
    functions.delete_tag_using_id(tag_id)
    tags = functions.get_all_tags(session['id'])
    return render_template('edit_tag.html',
                           tags=tags,
                           delete=True,
                           username=session['username'])
Esempio n. 5
0
def delete_tag(tag_id):
    '''
        App for deleting a specific tag
    '''
    functions.delete_tag_using_id(tag_id)
    tags = functions.get_all_tags(session['id'])
    return render_template('edit_tag.html',
                           tags=tags,
                           delete=True,
                           username=session['username'])
Esempio n. 6
0
def add_note():
    form = AddNoteForm()
    form.tags.choices = functions.get_all_tags(session['id'])
    if form.tags.choices is None:
        form.tags = None
    if form.validate_on_submit():
        note_title = request.form['note_title']
        note_markdown = form.note.data
        note = Markup(markdown.markdown(note_markdown))
        try:
            tags = form.tags.data
            tags = ','.join(tags)
        except:
            tags = None
        functions.add_note(note_title, note, note_markdown, tags,
                           session['id'])
        return redirect('/profile/')
    return render_template('add_note.html',
                           form=form,
                           username=session['username'])
def add_tag():
    '''
        App for adding a tag
    '''
    form = AddTagForm()
    if form.validate_on_submit():
        tag = request.form['tag']
        tags = functions.get_all_tags(session['id'])
        res = list(zip(*tags))
        res = set(res[1])
        if tag in res:

            flash("Tag Already Exists", 'alert alert-danger')
            return render_template('add_tag.html',
                                   form=form,
                                   username=session['username'])

        else:
            functions.add_tag(tag, session['id'])
            return redirect('/profile/')
    return render_template('add_tag.html',
                           form=form,
                           username=session['username'])
Esempio n. 8
0
def view_tag():

    tags = functions.get_all_tags(session['id'])
    return render_template('edit_tag.html', tags=tags, username=session['username'])