Ejemplo n.º 1
0
    def post(self):
        '''
        Creates a common and corresponding activity. Then common is
        propagated to all trusted contacts.

        Errors are stored inside activity.
        '''

        file = self.request.files['common'][0]

        if file:
            filebody = file["body"]
            filename = file['filename']

            common = Common(title="New Common",
                            path=filename,
                            contentType=file["content_type"],
                            authorKey=UserManager.getUser().key,
                            author=UserManager.getUser().name,
                            isFile=True)
            common.save()

            common.put_attachment(filebody, filename)
            common.save()

            self.create_owner_creation_activity(common, "publishes", "common")

            self.send_creation_to_contacts(CONTACT_PATH, common)

            logger.info("Common %s successfuly posted." % filename)
            self.return_json(common.toJson(), 201)

        else:
            self.return_failure("No common posted.", 400)
Ejemplo n.º 2
0
    def post(self):
        '''
        Creates a common and corresponding activity. Then common is
        propagated to all trusted contacts.

        Errors are stored inside activity.
        '''

        filebody = self.request.body
        filename = self.get_argument("qqfile")
        try:
            tag = self.get_argument("tag")
        except:
            tag = "all"
        filetype = mimetypes.guess_type(filename)[0] or \
                'application/octet-stream'

        if filebody:

            common = Common(
                title="New Common",
                path=filename,
                contentType=filetype,
                authorKey=UserManager.getUser().key,
                author=UserManager.getUser().name,
                isMine=True,
                isFile=True,
                tags=[tag]
            )
            common.save()

            common.put_attachment(content=filebody, name=filename)
            common.save()

            self.create_owner_creation_activity(
                    common, "publishes", "common")

            self.send_creation_to_contacts(CONTACT_PATH, common)

            logger.info("Common %s successfuly posted." % filename)
            self.return_json(common.toJson(), 201)

        else:
            self.return_failure("No common posted.", 400)
Ejemplo n.º 3
0
    def post(self):
        '''
        Creates a common and corresponding activity. Then common is
        propagated to all trusted contacts.

        Errors are stored inside activity.
        '''

        filebody = self.request.body
        filename = self.get_argument("qqfile")
        try:
            tag = self.get_argument("tag")
        except:
            tag = "all"
        filetype = mimetypes.guess_type(filename)[0] or \
                'application/octet-stream'

        if filebody:

            common = Common(title="New Common",
                            path=filename,
                            contentType=filetype,
                            authorKey=UserManager.getUser().key,
                            author=UserManager.getUser().name,
                            isMine=True,
                            isFile=True,
                            tags=[tag])
            common.save()

            common.put_attachment(content=filebody, name=filename)
            common.save()

            self.create_owner_creation_activity(common, "publishes", "common")

            self.send_creation_to_contacts(CONTACT_PATH, common)

            logger.info("Common %s successfuly posted." % filename)
            self.return_json(common.toJson(), 201)

        else:
            self.return_failure("No common posted.", 400)
Ejemplo n.º 4
0
    def post(self):
        '''
        Creates a common and corresponding activity. Then common is
        propagated to all trusted contacts.

        Errors are stored inside activity.
        '''

        file = self.request.files['common'][0]

        if file:
            filebody = file["body"]
            filename = file['filename']

            common = Common(
                title="New Common",
                path=filename,
                contentType=file["content_type"],
                authorKey=UserManager.getUser().key,
                author=UserManager.getUser().name,
                isFile=True
            )
            common.save()

            common.put_attachment(filebody, filename)
            common.save()

            self.create_owner_creation_activity(
                    common, "publishes", "common")

            self.send_creation_to_contacts(CONTACT_PATH, common)

            logger.info("Common %s successfuly posted." % filename)
            self.return_json(common.toJson(), 201)

        else:
            self.return_failure("No common posted.", 400)