示例#1
0
    def post(self, key):
        '''
        Resend post with *key* as key to the contact given in the posted
        JSON. Corresponding activity ID is given inside the posted json.
        Here is the format : {"contactId":"data","activityId":"data"}
        '''
        common = CommonManager.get_common(key)
        idInfos = self.request.body

        ids = json_decode(idInfos)

        if common and idInfos:

            contactId = ids["contactId"]
            activityId = ids["activityId"]

            contact = ContactManager.getTrustedContact(contactId)
            activity = ActivityManager.get_activity(activityId)

            if not contact:
                self.return_failure("Contact not found", 404)
            elif not activity:
                self.return_failure("Activity not found", 404)
            else:
                info = "Attemp to resend a common to contact: {}."
                logger.info(info.format(contact.name))
                self.forward_to_contact(common, contact, activity)
        else:
            self.return_failure("Common not found", 404)
示例#2
0
    def post(self, key):
        '''
        Resend post with *key* as key to the contact given in the posted
        JSON. Corresponding activity ID is given inside the posted json.
        Here is the format : {"contactId":"data","activityId":"data"}
        '''
        common = CommonManager.get_common(key)
        idInfos = self.request.body

        ids = json_decode(idInfos)

        if common and idInfos:

            contactId = ids["contactId"]
            activityId = ids["activityId"]

            contact = ContactManager.getTrustedContact(contactId)
            activity = ActivityManager.get_activity(activityId)

            if not contact:
                self.return_failure("Contact not found", 404)
            elif not activity:
                self.return_failure("Activity not found", 404)
            else:
                info = "Attemp to resend a common to contact: {}."
                logger.info(info.format(contact.name))
                self.forward_to_contact(common, contact, activity)
        else:
            self.return_failure("Common not found", 404)
示例#3
0
def ensure_that_common_date_is_ok_with_time_zone(step):
    world.date_common = world.commons[0]

    common_db = CommonManager.get_common(world.date_common["_id"])
    date = date_util.convert_utc_date_to_timezone(common_db.date)
    date = date_util.get_db_date_from_date(date)

    assert world.date_common["date"] == date
示例#4
0
def ensure_that_common_date_is_ok_with_time_zone(step):
    world.date_common = world.commons[0]

    common_db = CommonManager.get_common(world.date_common["_id"])
    date = date_util.convert_utc_date_to_timezone(common_db.date)
    date = date_util.get_db_date_from_date(date)

    assert world.date_common["date"] == date
示例#5
0
 def get(self, id):
     '''
     Retrieves common corresponding to id. Returns a 404 response if
     common is not found.
     '''
     common = CommonManager.get_common(id)
     if common:
         self.on_common_found(common, id)
     else:
         self.return_failure("Common not found.", 404)
示例#6
0
 def get(self, id):
     '''
     Retrieves common corresponding to id. Returns a 404 response if
     common is not found.
     '''
     common = CommonManager.get_common(id)
     if common:
         self.on_common_found(common, id)
     else:
         self.return_failure("Common not found.", 404)
示例#7
0
    def delete(self, id):
        '''
        Deletes common corresponding to id.
        '''
        common = CommonManager.get_common(id)
        if common:
            user = UserManager.getUser()

            if common.authorKey == user.key:
                self.create_owner_deletion_activity(common, "deletes",
                                                    "common")
                self.send_deletion_to_contacts("commons/contact/", common)

            common.delete()
            self.return_success("Common deleted.")
        else:
            self.return_failure("Common not found.", 404)
示例#8
0
    def delete(self, id):
        '''
        Deletes common corresponding to id.
        '''
        common = CommonManager.get_common(id)
        if common:
            user = UserManager.getUser()

            if common.authorKey == user.key:
                self.create_owner_deletion_activity(
                        common, "deletes", "common")
                self.send_deletion_to_contacts("commons/contact/", common)

            common.delete()
            self.return_success("Common deleted.")
        else:
            self.return_failure("Common not found.", 404)
示例#9
0
def when_i_get_first_from_its_id(step):
    world.common = CommonManager.get_common(world.commons[0]._id)
示例#10
0
def when_i_get_first_from_its_id(step):
    world.common = CommonManager.get_common(world.commons[0]._id)