Exemple #1
0
def initialize(request):
    user = users.get_current_user()
    if user:
        url = users.create_logout_url('/')
        url_string = 'logout'
        email = user.email().strip()
        member_key = ndb.Key('Member', email)
        member = member_key.get()
        if member is None:
            name = re.sub('\W+', ' ', email.split('@')[0]).title()
            member = Member(id=email, name=name)
            member.put()
    else:
        url = users.create_login_url()
        url_string = 'login'
        member = None
    template_values = {
        'url': url,
        'url_string': url_string,
        'user': user,
        'member': member,
        'upload': blobstore.create_upload_url('/upload')
    }

    return template_values
Exemple #2
0
    def get(self):
        """ Default blob url get.

        Override in child class to send back a different url then endpoint requested from
        :return: blobstore upload url
        """
        return {
            'url': blobstore.create_upload_url(self.request.path)
        }
Exemple #3
0
    def get_upload_url(cls, message):
        blob_upload_url = blobstore.create_upload_url('/directors')

        resp = cls(
            blob_response_type=message.type,
            blob_response_string=blob_upload_url
        )

        return resp
 def get(self):
     upload_url = blobstore.create_upload_url('/upload_photo')
     # To upload files to the blobstore, the request method must be "POST"
     # and enctype must be set to "multipart/form-data".
     self.response.out.write("""
         <html><body>
         <form action="{0}" method="POST" enctype="multipart/form-data">
           Upload File: <input type="file" name="file"><br>
           <input type="submit" name="submit" value="Submit">
         </form>
         </body></html>""".format(upload_url))
    def get(self):
	
        page_title = "Upload GTFS"
        
        parsed = urlparse(self.request.url)
        upload_url = blobstore.create_upload_url(parsed.path)

        template_values = {
            'page_title': page_title,
            'upload_url' : upload_url,
        }
        
        template = JINJA_ENVIRONMENT.get_template('templates/operator_upload_gtfs.html')
        self.response.write(template.render(template_values))
Exemple #6
0
 def get(self, key):
     if key == "":  # query
         if not users.is_current_user_admin():
             raise AppError("User must be administrator.")
         return query(self, BlobInfo)
     elif key == "create":
         return {
             "upload_url": blobstore.create_upload_url("/api/files/upload")
         }
     key = str(urllib.unquote(key))
     blob_info = bs.BlobInfo.get(key)
     if blob_info:
         self.send_blob(blob_info)
         raise BreakError
     else:
         self.error(404)
         return {"error": "File not found with key " + key}
Exemple #7
0
 def get(self, key):
   if key == "":  # query
     if not config.is_current_user_admin():
       raise AppError("User must be administrator.")
     return restful.query(self, BlobInfo)
   elif key == "create":
     return {
         "upload_url": blobstore.create_upload_url("/api/files/upload")
     }
   key = str(urllib.unquote(key))
   blob_info = bs.BlobInfo.get(key)
   if blob_info:
     self.send_blob(blob_info)
     raise BreakError
   else:
     self.error(404)
     return {"error": "File not found with key " + key}
Exemple #8
0
 def get(self):
     upload_url = blobstore.create_upload_url('/file_upload')
     self.response.headers['Content-Type'] = "application/json"
     self.response.out.write(json.dumps(upload_url))
 def get(self):
     upload_url = blobstore.create_upload_url('/file_upload')
     self.response.headers['Content-Type'] = "application/json"
     self.response.out.write(json.dumps(upload_url))