Пример #1
0
 def post(self):
     if not access.can_upload_image(users.get_current_user(),
                                    users.is_current_user_admin()):
         raise Forbidden
     # After the file is uploaded, grab the blob key and return the image URL.
     upload_files = self.get_uploads(
         'file')  # 'file' is file upload field in the form
     #
     # the below line can be removed once this bug is fixed by google:
     # https://code.google.com/p/googleappengine/issues/detail?id=2749
     upload_files = blobstore.BlobInfo.get(
         [blob.key() for blob in upload_files])
     #
     blob_info = upload_files[0]
     last_upload = model.WikiUpload.get_by_name(blob_info.filename)
     if last_upload:
         last_upload.is_latest = False
         last_upload.put()
     upload = model.WikiUpload(
         blob_key=str(blob_info.key()),
         user=model.WikiUser.get_or_create(users.get_current_user()),
         short_key=md5(str(blob_info.key())).hexdigest(),
         content_type=blob_info.content_type,
         filename=blob_info.filename,
         size=blob_info.size,
         is_latest=True)
     upload.put()
     image_page_url = "/w/file/view/" + upload.short_key
     return self.redirect(image_page_url)
Пример #2
0
 def get(self):
     if not access.can_upload_image(users.get_current_user(),
                                    users.is_current_user_admin()):
         raise Forbidden
     lst = model.WikiUpload.get_recently_added(100)
     html = view.view_file_list(lst, users.get_current_user(),
                                users.is_current_user_admin())
     self.reply(html, "text/html")
Пример #3
0
 def get(self):
     if not access.can_upload_image(users.get_current_user(),
                                    users.is_current_user_admin()):
         raise Forbidden
     lst = images.Image.find_all()
     html = view.view_image_list(lst, users.get_current_user(),
                                 users.is_current_user_admin())
     self.reply(html, "text/html")
Пример #4
0
    def post(self):
        if not access.can_upload_image(users.get_current_user(), users.is_current_user_admin()):
            raise Forbidden
        # After the file is uploaded, grab the blob key and return the image URL.
        upload_files = self.get_uploads('file')  # 'file' is file upload field in the form
        blob_info = upload_files[0]

        image_page_url = "/w/image/view?key=" + str(blob_info.key())
        return self.redirect(image_page_url)
Пример #5
0
    def post(self):
        if not access.can_upload_image(users.get_current_user(), users.is_current_user_admin()):
            raise Forbidden
        # After the file is uploaded, grab the blob key and return the image URL.
        upload_files = self.get_uploads('file')  # 'file' is file upload field in the form
        blob_info = upload_files[0]

        image_page_url = "/w/image/view?key=" + str(blob_info.key())
        return self.redirect(image_page_url)
Пример #6
0
    def get(self):
        user = users.get_current_user()
        is_admin = users.is_current_user_admin()
        if not access.can_upload_image(user, is_admin):
            raise Forbidden

        submit_url = blobstore.create_upload_url(self.request.path)

        html = view.view_image_upload_page(user, is_admin, submit_url)
        self.reply(html, "text/html")
Пример #7
0
    def get(self):
        user = users.get_current_user()
        is_admin = users.is_current_user_admin()
        if not access.can_upload_image(user, is_admin):
            raise Forbidden

        submit_url = blobstore.create_upload_url(self.request.path)

        html = view.view_image_upload_page(user, is_admin, submit_url)
        self.reply(html, "text/html")
Пример #8
0
    def get(self):
        if not access.can_upload_image(users.get_current_user(),
                                       users.is_current_user_admin()):
            raise Forbidden

        img = images.Image.get_by_key(self.request.get("key"))

        data = {
            "meta":
            img.get_info(),
            "versions": [
                ("thumbnail", img.get_url(75, True), img.get_code(75, True)),
                ("small", img.get_url(200, False), img.get_code(200, False)),
                ("medium", img.get_url(500, False), img.get_code(500, False)),
            ]
        }

        page_title = "Image:" + img.get_key()
        data["pages"] = model.WikiContent.find_backlinks_for(page_title)

        html = view.view_image(data,
                               user=users.get_current_user(),
                               is_admin=users.is_current_user_admin())
        self.reply(html, 'text/html')