def test_highest_version_of_file(self): """ Assert that get_highest_version_of_file_path gets the highest version for all paths """ assert Page.get_highest_version_of_file_path(self.page_1.path) == self.page_1.path assert Page.get_highest_version_of_file_path(self.page_2.path) == self.page_3.path assert Page.get_highest_version_of_file_path(self.page_3.path) == self.page_3.path assert Page.get_highest_version_of_file_path(self.page_4.path) == self.page_4.path
def tag(name): tagged = current_wiki.index_by_tag(name) new_pages = [] for t in tagged: p = Page.get_highest_version_of_file_path(t.path) if t.path == p and t not in new_pages: new_pages.append(t) return render_template('tag.html', pages=new_pages, tag=name)
def tags(): ts = current_wiki.get_tags() new_tags = {} for t in ts: if t not in new_tags: new_tags[t] = [] for p in ts[t]: page = Page.get_highest_version_of_file_path(p.path) if page not in new_tags[t]: new_tags[t].append(page) return render_template('tags.html', tags=new_tags)
def edit(url): page = current_wiki.get(url) form = EditorForm(obj=page) if form.validate_on_submit(): if not page: page = current_wiki.get_bare(url) form.populate_obj(page) page.save() new_path = Page.get_highest_version_of_file_path(page.path) pages = current_wiki.index() new_page = None for p in pages: if p.path == new_path: new_page = p if new_page is None: new_page = page flash('"%s" was saved.' % new_page.title, 'success') return redirect(url_for('wiki.display', url=new_page.url)) return render_template('editor.html', form=form, page=page)