def get(self): if 'X-AppEngine-Cron' not in self.request.headers: self.error(403) notes = Note.query().fetch() for note in notes: self._shrink_note(note)
def get_note_counter(): data = memcache.get('note_count') if data is None: data = Note.query().count() memcache.set('note_count', data) return data
def get(self): # otherwise task queue request is not received if 'X-Appengine-Cron' not in self.request.headers: self.error(403) # Forbidden # load all Note entities from datastore notes = Note.query().fetch() for note in notes: self._shrink_note(note)
def note_for_company(self, request): user = endpoints.get_current_user() query = Note.query(ancestor=main.get_parent_key(user)).filter(Note.company_entity_key == request.company_entity_key) returnNote = Note(note="", company_entity_key=request.company_entity_key) for note in query: returnNote = note break return returnNote
def get(self): notes = Note.query().order(-Note.timestamp).fetch(limit=20) user = users.get_current_user() logout_url = users.create_logout_url('/') if user else None template = jinja_env.get_template('main.html') self.response.write( template.render({ 'notes': notes, 'nickname': user.nickname() if user else None, 'logout_url': logout_url }))
def get(self): notes_query = Note.query(Note.user == self.user.key) notes = notes_query.fetch() template_values = { 'user': self.user, 'notes': notes, 'description': 'Notes App - Admin Area' } templates.render_page("notes/home", template_values, self) # get the users notes here return
def note_for_company(self, request): user = endpoints.get_current_user() query = Note.query(ancestor=main.get_parent_key(user)).filter( Note.company_entity_key == request.company_entity_key) returnNote = Note(note="", company_entity_key=request.company_entity_key) for note in query: returnNote = note break return returnNote
def get(self): # need to get the subject that was clicked if len(self.request.url.split('?')) > 1: subject_type = self.request.url.split('?')[1].replace('%', ' ') else: subject_type = '' user = users.get_current_user() subject_template = JINJA_ENVIRONMENT.get_template('templates/subjectNotes.html') notes = Note.query().filter(Note.owner == user.user_id() and Note.subject == subject_type).fetch() songs = Song.query().filter(Song.owner == user.user_id() and Song.subject == subject_type).fetch() subject_dict = { "notes_list": notes, "songs_list": songs, "subject_name": subject_type } self.response.write(subject_template.render(subject_dict))
def list_notes(): notes = Note.query() # Convert body of each note to marked-up markdown for note in notes: note.body = Markup(markdown.markdown(note.body)) form = NoteForm() if form.validate_on_submit(): note = Note(title=form.note_title.data, slug=slugify(form.note_title.data), body=form.note_body.data, author=users.get_current_user()) try: note.put() note_id = note.key.id() flash(u'Note %s saved.' % note_id, 'success') return redirect(url_for('list_notes')) except CapabilityDisabledError: flash(u'Datastore is in read-only mode.', 'info') return redirect(url_for('list_notes')) return render_template('dynamic_notes.html', notes=notes, form=form)
def post(self): user = users.get_current_user() if self.request.get("delete-note") == 'X': key = self.request.get("note-id") note_list = Note.query().filter(Note.owner == user.user_id()).fetch() flag = False for n in note_list: if str(n.key) == key: selected_note = n flag = True if flag: selected_note.key.delete() else: key = self.request.get("song-id") song_list = Song.query().filter(Song.owner == user.user_id()).fetch() flag = False for s in song_list: if str(s.key) == key: selected_song = s flag = True if flag: selected_song.key.delete() time.sleep(0.1) self.get()
def post(self): user = users.get_current_user() if self.request.get("action") == "Add Subject" and self.request.get("subject_string") != '': subject_string = self.request.get("subject_string") subject = Subject(name=subject_string, owner=user.user_id()) subject.put() else: key = self.request.get("subject-id") subject_list = Subject.query().filter(Subject.owner == user.user_id()).fetch() flag = False for subj in subject_list: if str(subj.key) == key: selected_subject = subj flag = True if flag: notes_to_delete = Note.query().filter(Note.subject == selected_subject.name and Note.owner == user.user_id()) songs_to_delete = Song.query().filter(Song.subject == selected_subject.name and Song.owner == user.user_id()) for note in notes_to_delete: note.key.delete() for song in songs_to_delete: song.key.delete() selected_subject.key.delete() time.sleep(0.1) self.redirect('/')
def cached_notes(): notes = Note.query() return render_template('list_notes_cached', notes=notes)
def get(self): note = Note.query().order(-Note.timestamp).get() self.response.headers['Content-Type'] = 'text-plain' self.response.write(str(note.timestamp if note else ''))