def get(self, resource_id=None): """Fetch group(s)""" logging.info('invitations::get', extra=dict(resource_id=resource_id)) if resource_id is None: if self.user.is_admin: invites = self.db.get_group_invites() else: invites = self.db.get_group_invites(self.owner.email) self.dump([JsGroupInvitation.from_db(db) for db in invites]) else: invite = self.db.get_group_invite(int(resource_id)) self.dump(JsGroupInvitation.from_db(invite))
def get_invitations(self): self._verify_owner() if self.db.user.is_admin: invites = self.db.get_group_invites() else: invites = self.db.get_group_invites(self.owner.email) return [ GroupInvitation.from_db(db) for db in invites ]
def get_invitations(self): self._verify_owner() if self.db.user.is_admin: invites = self.db.get_group_invites() else: invites = self.db.get_group_invites(self.owner.email) return [GroupInvitation.from_db(db) for db in invites]
def post(self): """Create a new invitation""" logging.info('invitations::post', extra=dict(body=self.request.body)) data = json.loads(self.request.body) group = self.db.get_group(data.group_id) db = self.db.add_group_invite(group, data.email) self.dump(JsGroupInvitation.from_db(db))