Beispiel #1
0
 def _render_template(self,template_name,context=None):
     if context is None:
         context = {}
     user = users.get_current_user()
     ancestor_key = ndb.key("User",user.nickname())
     qry = Note.owner_query(ancestor_key)
     context["notes"] = qry.fetch()
     template = jinja_env.get_template(template_name)
     return template.render(context)
Beispiel #2
0
    def _render_template(self, template_name, context=None):
        if context is None:
            context = {}

        user = users.get_current_user()
        ancestor_key = ndb.Key("User", user.nickname())
        qry = Note.owner_query(ancestor_key)
        context['notes'] = qry.fetch()

        template = jinja_env.get_template(template_name)
        return template.render(context)
    def post(self):
        if not 'X-AppEngine-TaskName' in self.request.headers:
            self.error(403)

        user_email = self.request.get('user_email')
        user = users.User(user_email)

        ancestor_key = ndb.Key("User", user.nickname())
        notes = Note.owner_query(ancestor_key).map(self._shrink_note, projection=[Note.files])

        sender_address = "Notes Team <*****@*****.**>"
        subject = "Shrink complete!"
        body = "We shrunk {} images attached to your notes!".format(len(notes))
        mail.send_mail(sender_address, user_email, subject, body)
Beispiel #4
0
      def _render_template(self, template_name, context=None):
         if context is None:
            context = {}

         user = users.get_current_user()
         ancestor_key = ndb.Key("User", user.nickname())
         qry = Note.owner_query(ancestor_key)
         context['notes'] = qry.fetch()
 

         template = jinja_env,get_template(template_name)
         return template.render(context)

         self.response.out.write(self._render_template('main.html', template_context))
Beispiel #5
0
    def post(self):
        if not 'X-AppEngine-TaskName' in self.request.headers:
            self.error(403)

        user_email = self.request.get('user_email')
        user = users.User(user_email)

        ancestor_key = ndb.Key("User", user.nickname())
        notes = Note.owner_query(ancestor_key).map(self._shrink_note,
                                                   projection=[Note.files])

        sender_address = "Notes Team <*****@*****.**>"
        subject = "Shrink complete!"
        body = "We shrunk {} images attached to your notes!".format(len(notes))
        mail.send_mail(sender_address, user_email, subject, body)
    def _render_template(self, template_name, context=None):
        if context is None:
            context = {}

        user = users.get_current_user()
        ancestor_key = ndb.Key("User", user.nickname())
        qry = Note.owner_query(ancestor_key)
        future = qry.fetch_async()

        template = jinja_env.get_template(template_name)

        context['notes'] = future.get_result()
        context['note_count'] = get_note_counter()

        return template.render(context)
    def post(self):
        if not 'X-AppEngine-TaskName' in self.request.headers:
            self.error(403)

        user_email = self.request.get('user_email')
        user = users.User(user_email)

        ancestor_key = ndb.Key("User", user.nickname())
        notes = Note.owner_query(ancestor_key).fetch()

        for note in notes:
            self._shrink_note(note)

        sender_address = "Notes Team <*****@*****.**>"
        subject = "Shrink complete!"
        body = "We shrunk all the images attached to your notes!"
        mail.send_mail(sender_address, user_email, subject, body)
Beispiel #8
0
    def post(self):
        if not 'X-AppEngine-TaskName' in self.request.headers:
            self.error(403)

        user_email = self.request.get('user_email')
        user = users.User(user_email)

        ancestor_key = ndb.Key("User", user.nickname())
        notes = Note.owner_query(ancestor_key).fetch()

        for note in notes:
            self._shrink_note(note)

        sender_address = "Notes Team <*****@*****.**>"
        subject = "Shrink complete!"
        body = "We shrunk all the images attached to your notes!"
        mail.send_mail(sender_address, user_email, subject, body)
Beispiel #9
0
    def post(self):
        # otherwise task queue request is not received
        if not 'X-Appengine-Taskname' in self.request.headers:
            self.error(403) # Forbidden
        user_email = self.request.get('user_email')
        user = users.User(user_email)

        ancestor_key = ndb.Key("User", user.nickname())
        notes = Note.owner_query(ancestor_key).fetch()

        for note in notes:
            self._shrink_note(note)

        # compose, send a mail
        sender_address = "Notes team <*****@*****.**>"
        subject = "Shrink complete"
        body = "All images attached to your notes have been shrunk"
        mail.send_mail(sender_address, user_email, subject, body)
Beispiel #10
0
    def post(self):
        user = users.get_current_user()

        if user is None:
            self.error(401)

        ancestor_key = ndb.Key("User", user.nickname())
        qry = Note.owner_query(ancestor_key)
        notes = qry.fetch()

        note = Note(parent=ndb.Key("User", user.nickname()),
                    title=self.request.get('title'),
                    content=self.request.get('content'))
        note.put()

        logout_url = users.create_logout_url(self.request.uri)
        template_context = {
            'user': user.nickname(),
            'logout_url': logout_url,
            'note_title': self.request.get('title'),
            'note_content': self.request.get('content'),
        }
        self.response.out.write(
            self._render_template('main.html', template_context))
Beispiel #11
0
	def get(self):
		qry = Note.owner_query()
		context['notes'] = qry.fetch
		template_name = jinja_env.get_template('./view.html')
		return template.render(context)