def testNote(self): Note(author=self.current_user, title='Test 1', public=False).put() self.assertEqual(1, Note.all().count(10)) Note(author=self.current_user, title='Test 2', public=True).put() self.assertEqual(2, Note.all().count(10)) Note(author=self.current_user, title='Test 3', text=u'Treść', url='jkpluta.appspot.com', public=True).put() self.assertEqual(3, Note.all().count(10)) with self.assertRaises(datastore_errors.BadValueError): Note().put() with self.assertRaises(datastore_errors.BadValueError): Note().put(author=self.current_user, title='Test X') with self.assertRaises(datastore_errors.BadValueError): Note().put(author=self.current_user, public=False) self.assertEqual(3, Note.all().count(10))
def ssearch(request, key_word): query1 = FlashCard.all().search(key_word).order("-mtime") query2 = Note.all().search(key_word).order("-mtime") return render_to_response('quiz.html', { 'cards': query1.run(), 'notes': query2.run() })
def download(request): query1 = FlashCard.all() query2 = Note.all() query3 = Reference.all() xmlcards = [card.to_xml() for card in query1.run()] xmlnotes = [note.to_xml() for note in query2.run()] xmlrefs = [ref.to_xml() for ref in query3.run()] return render_to_response('download.xml', { 'xmlcards': xmlcards, 'xmlnotes': xmlnotes, 'xmlrefs': xmlrefs })
def search(request): class SearchForm(forms.Form): keyword = forms.CharField() if request.POST: form = SearchForm(request.POST) keywords = form.data['keyword'] query1 = FlashCard.all().search(keywords).order("-mtime") query2 = Note.all().search(keywords).order("-mtime") return render_to_response('display.html', { 'cards': query1.run(), 'notes': query2.run() }) else: return render_to_response('search.html', {'page': SearchForm()})
def add_note(): """Add a note.""" form = ArticleForm() if request.method == 'POST': if form.validate_on_submit(): # Get the right number - the article ID number = 1 notes = Note.all().order('-number') if notes.count() > 0: number = notes[0].number + 1 note = Note( number=number, title=form.title.data, content=form.content.data, tags=form.tags.data, ) note.save() return redirect(note.get_absolute_url()) action_url = url_for('add_note') return render_template('add_note.html', form=form, action_url=action_url)
def ntfeed(): notes = Note.all().order('-added') return render_template('ntfeed.atom', notes=notes)
def note(): notes = Note.all().order('-added') return render_template('note.html', notes=notes)
def ntedit_list(): """Render website's index page.""" notes = Note.all().order('-added') return render_template('ntedit_list.html', notes=notes)
def get_note_by_number(number): notes = Note.all() notes = notes.filter('number ==', int(number)) if notes.count() == 0: return None return notes[0]
def get(self): allNotes = Note.all().order("-text") template_values = { 'notes': allNotes } self.response.write(renderTemplate('index.html',template_values))