def get_by_pid_rid_skill(conn, proj_id, role_id, skill): """Get another format of project info by project id and specific role with specific skill Param: conn -- database connection proj_id -- project digit id role_id -- role digit id skill -- skill digit id Return: Project text info """ query = "SELECT * FROM project WHERE ID = " + str(proj_id) + ";" result = conn.execute(query) if result.rowcount == 0: return None row = result.fetchone() proj = Project(row['project_title'], row['description'], row['dreamerID'], row['category'], status=row['project_status'], hidden=row['is_hidden'], hidden_reason=row['hidden_reason']) proj.id = row['ID'] proj.is_modified_after_hidden = row['is_modified_after_hidden'] proj.roles = Role.get_text_by_id(conn, role_id) proj.create_time = row['create_time'] proj.last_update = row['last_update'] return proj.info()
def info(self, conn): """Return invitation info Param: conn -- database connection Return: invitation info """ return { 'id': self.id, 'project_id': self.project_id, 'role_invite': self.role_invite, 'invitor': self.invitor, 'invitee': self.invitee, 'general_text': self.general_text, 'status': self.status, 'Role_information': Role.get_text_by_id(conn, self.role_invite), 'Project_title': Project.get_by_id(conn, self.project_id)['title'] }
def get_by_invitee(conn, user_id): """Get all invitations for a collaborator's Param: conn -- database connection user_id -- collaborator digit id Return: list of invitations info """ # IMPORTANT: Avoid corss import # This import cannot be moved up or it will cause infinite recursive import from projects.role import Role query = "SELECT * FROM invitation where invitee = " + str( user_id) + " order by ID desc;" result = conn.execute(query) invitations = [] for i in range(result.rowcount): row = result.fetchone() if row['status'] == -1: invitation_status = 'Pending' if row['status'] == 0: invitation_status = 'Declined' if row['status'] == 1: invitation_status = 'Approved' if row['status'] == 9: invitation_status = 'Finished' invi = { 'InvitationID': row['ID'], 'projectID': row['projectID'], 'Role_invited': row['role_invited'], 'Invitor': row['invitor'], 'Invitor_name': Dreamer.get_by_id(conn, row['invitor'])['name'], 'Invitee': row['invitee'], 'Invitation_status': invitation_status, 'General_text': row['general_text'], 'Role_information': Role.get_text_by_id(conn, row['role_invited']), 'Project_title': Project.get_by_id(conn, row['projectID'])['title'] } invitations.append(invi) return {'invitations': invitations, 'amount': result.rowcount}