Пример #1
0
def delete_note(note_id):
    note = Note.get_by_id(note_id)
    try:
        note.key.delete()
        flash(u'Note %s deleted.' % note_id, 'success')
        return redirect(url_for('list_notes'))
    except CapabilityDisabledError:
        flash(u'The datastore is in read only mode.', 'info')
        return redirect(url_for('list_notes'))
Пример #2
0
def edit_note(note_id):
    note = Note.get_by_id(note_id)
    form = NoteForm(obj=note)
    if request.method == 'POST':
        if form.validate_on_submit():
            note.title = form.data.get('note_title')
            note.body = form.data.get('note_body')
            note.slug = slugify(note.title)
            note.put()
            flash(u'Note %s saved.' % note_id, 'success')
            return redirect(url_for('list_notes'))
    return render_template('edit_note.html', note=note, form=form)
Пример #3
0
 def _on_note_deleting(self, note):
     self.searcher.delete_doc(note)
     note.delete_instance()
     self.note_list_panel.remove(note)
     if len(self._note_ids) > 1:
         note_id_index = self._note_ids.index(note.id)
         next_index = note_id_index + 1
         if next_index > len(self._note_ids) - 1:
             next_index = note_id_index - 1
         self.note_list_panel.select(Note.get_by_id(self._note_ids[next_index]))
     self._note_ids.remove(note.id)
     self.header_panel.change_count(-1)
Пример #4
0
 def update(self,
            note_id,
            name=None,
            start_time_delta=None,
            assignee=None,
            description=None):
     note = NoteModel.get_by_id(note_id)
     if name:
         note.name = name
     if start_time_delta:
         note.start_time_delta = start_time_delta
     if assignee:
         note.assignee = assignee
     if description:
         note.description = description
     note.put()
Пример #5
0
    def get(self):
        logging.debug("Sprawdzam czy dane sa w memcache")
        data = memcache.get('jadlospis')
        if data is None:
            logging.debug(
                "Danych nie ma w memcache, sprawdzam czy dane sa w NDB")
            q = Note.get_by_id('jadlospis')
            if q is None:
                logging.debug("Danych nie ma w NDB")
                data = 'Brak danych w bazie'
            else:
                logging.debug("Dane sa w NDB")
                data = q.kindergartenMenu
                logging.debug("Dodaje dane do memcache")
                memcache.add(key='jadlospis', value=data, time=expirationTime)
        else:
            logging.debug("Dane sa w memcache")

        template_context = {'body': data}
        template = jinja_env.get_template('templates/main.html')
        self.response.out.write(template.render(template_context))
Пример #6
0
    def get(self):
        logging.debug("Sprawdzam czy dane sa w memcache")
        data = memcache.get('jadlospis')
        if data is None:
            logging.debug("Danych nie ma w memcache, sprawdzam czy dane sa w NDB")
            q = Note.get_by_id('jadlospis')
            if q is None:
                logging.debug("Danych nie ma w NDB")
                data = 'Brak danych w bazie'
            else:
                logging.debug("Dane sa w NDB")
                data = q.kindergartenMenu
                logging.debug("Dodaje dane do memcache")
                memcache.add(key='jadlospis', value=data, time=expirationTime)
        else:
            logging.debug("Dane sa w memcache")

        template_context = {
            'body': data
        }
        template = jinja_env.get_template('templates/main.html')
        self.response.out.write(template.render(template_context))
Пример #7
0
 def get(self, note_id):
     note_model = NoteModel.get_by_id(int(note_id))
     if not note_model:
         raise Exception("note %s not found" % note_id)
     return Note.deserialize(note_model)
Пример #8
0
 def _on_left_clicked(self, _):
     pub.sendMessage('note.clicked', note=Note.get_by_id(self.note_id))
Пример #9
0
 def _delete_note(self, _):
     pub.sendMessage('note.deleting', note=Note.get_by_id(self.note_id))