Example #1
0
 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))
Example #2
0
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()
    })
Example #3
0
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
    })
Example #4
0
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()})
Example #5
0
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)
Example #6
0
def ntfeed():
    notes = Note.all().order('-added')
    return render_template('ntfeed.atom', notes=notes)
Example #7
0
def note():
    notes = Note.all().order('-added')
    return render_template('note.html', notes=notes)
Example #8
0
def ntedit_list():
    """Render website's index page."""
    notes = Note.all().order('-added')
    return render_template('ntedit_list.html', notes=notes)
Example #9
0
def get_note_by_number(number):
    notes = Note.all()
    notes = notes.filter('number ==', int(number))
    if notes.count() == 0:
        return None
    return notes[0]
Example #10
0
	def get(self):
		allNotes = Note.all().order("-text")
		template_values = {
			'notes': allNotes
		}
		self.response.write(renderTemplate('index.html',template_values))