Esempio 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)
Esempio n. 2
0
def add_three_commons_to_the_database_with_different_dates(step):
    file = open(TEST_COMMON)

    for i in range(1, 4):
        common = Common(title="Common 0%d" % i,
                        author=world.browser.user.name,
                        authorKey=world.browser.user.key,
                        date=datetime.datetime(2011, 11, i),
                        path="vimqrc.pdf",
                        isMine=i != 3)
        common.save()
        common.put_attachment(file.read(), "vimqrc.pdf")
Esempio n. 3
0
def add_three_commons_to_the_database_with_different_dates(step):
    file = open(TEST_COMMON)

    for i in range(1, 4):
        common = Common(
            title="Common 0%d" % i,
            author=world.browser.user.name,
            authorKey=world.browser.user.key,
            date=datetime.datetime(2011, 11, i),
            path="vimqrc.pdf",
            isMine=i != 3
        )
        common.save()
        common.put_attachment(file.read(), "vimqrc.pdf")
Esempio n. 4
0
def and_5_commons(step, nbcommons, tag):
    file = open("./apps/commons/tests/vimqrc.pdf")
    for i in range(1, int(nbcommons) + 1):
        common = Common(title="Common 0%d" % i,
                        author=world.user.name,
                        authorKey=world.user.key,
                        date=datetime.datetime(2011, 11, i),
                        path="test.jpg",
                        contentType="image/jpeg",
                        isMine=True,
                        tags=[tag])
        common.save()
        common.put_attachment(file.read(), "vimqrc.pdf")
        common.save()
Esempio n. 5
0
def and_5_commons(step, nbcommons, tag):
    file = open("./apps/commons/tests/vimqrc.pdf")
    for i in range(1, int(nbcommons) + 1):
        common = Common(
            title = "Common 0%d" % i,
            author =  world.user.name,
            authorKey = world.user.key,
            date = datetime.datetime(2011, 11, i),
            path = "test.jpg",
            contentType = "image/jpeg",
            isMine = True,
            tags = [tag]
        )
        common.save()
        common.put_attachment(file.read(), "vimqrc.pdf")
        common.save()
Esempio n. 6
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)
Esempio n. 7
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)
Esempio n. 8
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)