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/')
def delete_note(id): functions.delete_note_using_id(id) notes = functions.get_data_using_user_id(session['id']) tags = [] if notes: for note in notes: tags_list = functions.get_tag_using_note_id(note[0]) temp_list = [] if tags_list: for tag in tags_list: temp = functions.get_data_using_tag_id(tag) if temp is not None: temp_list.append(temp[0]) tags.append(', '.join(temp_list)) return render_template('profile.html', delete=True, tags=tags, username=session['username'], notes=notes)
def delete_note(id): ''' App for viewing a specific note ''' functions.delete_note_using_id(id) notes = functions.get_data_using_user_id(session['id']) tags = [] if notes: for i in range(len(notes)): tags_list = functions.get_tag_using_note_id(notes[i][0]) temp_list = [] if tags_list: for j in range(len(tags_list)): temp = functions.get_data_using_tag_id(tags_list[j]) if temp is not None: temp_list.append(temp[0]) tags.append(', '.join(temp_list)) return render_template('profile.html', delete=True, tags=tags, username=session['username'], notes=notes)
def profile(): if request.method == 'GET': notes = functions.get_data_using_user_id(session['id']) tags = [] if notes: for note in notes: tags_list = functions.get_tag_using_note_id(note[0]) temp_list = [] if tags_list: for tag in tags_list: temp = functions.get_data_using_tag_id(tag) if temp is not None: temp_list.append(temp[0]) tags.append(', '.join(temp_list)) return render_template('profile.html', username=session['username'], notes=notes, tags=tags)
def profile(): ''' App za korisnički profil, može se pristupiti samo nakon uspješne prijave ''' if request.method == 'GET': notes = functions.get_data_using_user_id(session['id']) tags = [] if notes: for note in notes: tags_list = functions.get_tag_using_note_id(note[0]) temp_list = [] if tags_list: for tag in tags_list: temp = functions.get_data_using_tag_id(tag) if temp is not None: temp_list.append(temp[0]) tags.append(', '.join(temp_list)) return render_template('profile.html', username=session['username'], notes=notes, tags=tags)
def profile(): ''' App for user profile can only be accessed only after successful login ''' if request.method == 'GET': notes = functions.get_data_using_user_id(session['id']) tags = [] if notes: for i in range(len(notes)): tags_list = functions.get_tag_using_note_id(notes[i][0]) temp_list = [] if tags_list: for j in range(len(tags_list)): temp = functions.get_data_using_tag_id(tags_list[j]) if temp is not None: temp_list.append(temp[0]) tags.append(', '.join(temp_list)) return render_template( 'profile.html', username=session['username'], notes=notes, tags=tags )
def view_notes(): ''' App for user profile can only be accessed only after successful login ''' if request.method == 'GET': notes = functions.get_data_using_user_id (session['id']) tags = [] if notes: for note in notes: tags_list = functions.get_tag_using_note_id(note[0]) temp_list = [] if tags_list: for tag in tags_list: temp = functions.get_data_using_tag_id(tag) if temp is not None: temp_list.append(temp[0]) tags.append(', '.join(temp_list)) return render_template( 'view_notes.html', username=session['username'], notes=notes, tags=tags )