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)
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)
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
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
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)
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)
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)
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)
def when_i_get_first_from_its_id(step): world.common = CommonManager.get_common(world.commons[0]._id)
def when_i_get_first_from_its_id(step): world.common = CommonManager.get_common(world.commons[0]._id)