def notify_invitor(self, conn, smtp, accept=True): """Send an email to invitor for notification Param: conn -- database connection smtp -- smtp server object accept -- boolean if invitation is accepted Return: Smtp send result """ proj = Project.get_by_id(conn, self.project_id) role = Role.get_by_id(conn, self.role_invite) col = Collaborator.get_by_id(conn, self.invitee) dre = Dreamer.get_by_id(conn, self.invitor) subject = '[DreamMatchmaker]You have a invitation status update' if accept: acceptance = 'accepted' else: acceptance = 'declined' content = f'''<p>Hello {dre['name']},</p> <p> Your invitation to <b>{col['name']}</b> for project <b>"{proj['title']}"</b>, role <b>"{role['title']}"</b></p> <p> has been <b>{acceptance}</b>.</p> <p>Dream Matchmaker Team</p> ''' result = smtp.send_email_html(dre['email'], content, subject) return result
def notify_result(self, conn, smtp, accept=True): """Notify application result to applicant through email Param: conn -- database connection smtp -- smtp server accept -- application approved or not Return: smtp send result """ proj = Project.get_by_id(conn, self.project_id) role = Role.get_by_id(conn, self.role_apply) col = Collaborator.get_by_id(conn, self.applicant) dre = Dreamer.get_by_id(conn, proj['owner']) subject = '[DreamMatchmaker]You have an application status update' if accept: acceptance = 'accepted' else: acceptance = 'declined' content = f'''<p>Hello {col['name']},</p> <p> Your application to join project <b>"{proj['title']}"</b> as <b>"{role['title']}"</b></p> <p> has been {acceptance}.</p> <p>Dream Matchmaker Team</p> ''' result = smtp.send_email_html(col['email'], content, subject) return result
def notify_invitee_auto_decline(self, conn, smtp): """Send an email to invitees for auto decline notification Param: conn -- database connection smtp -- smtp server object Return: Smtp send result """ proj = Project.get_by_id(conn, self.project_id) role = Role.get_by_id(conn, self.role_invite) col = Collaborator.get_by_id(conn, self.invitee) dre = Dreamer.get_by_id(conn, self.invitor) subject = '[DreamMatchmaker]You have a invitation status update' content = f'''<p>Hello {col['name']},</p> <p> Your invitation from <b>{dre['name']}</b> for project <b>"{proj['title']}"</b>, role <b>"{role['title']}"</b></p> <p> has been automaticlly cancelled due to "Role is fullfilled".</p> <p>Dream Matchmaker Team</p> ''' result = smtp.send_email_html(col['email'], content, subject) return result
def notify_invitee(self, conn, smtp): """Send an email to invitee for notification Param: conn -- database connection smtp -- smtp server object Return: Smtp send result """ proj = Project.get_by_id(conn, self.project_id) role = Role.get_by_id(conn, self.role_invite) col = Collaborator.get_by_id(conn, self.invitee) dre = Dreamer.get_by_id(conn, self.invitor) subject = '[DreamMatchmaker]You have a new project invitation' content = f'''<p>Hello {col['name']},</p> <p> <b>{dre['name']}</b> has invited you to join project <b>"{proj['title']}"</b> as <b>"{role['title']}"</b>.</p> <p> The following message is from the invitor:</p> <p> {self.general_text}<p> <p> You can view the invitation in your dashboard.</p> <p>Dream Matchmaker Team</p> ''' result = smtp.send_email_html(col['email'], content, subject) return result
def notify_applicant(self, conn, smtp): """Notify application to applicant through email Param: conn -- database connection smtp -- smtp server Return: smtp send result """ proj = Project.get_by_id(conn, self.project_id) role = Role.get_by_id(conn, self.role_apply) col = Collaborator.get_by_id(conn, self.applicant) dre = Dreamer.get_by_id(conn, proj['owner']) subject = '[DreamMatchmaker]You have created a new project application' content = f'''<p>Hello {col['name']},</p> <p> You have applied to join project <b>"{proj['title']}"</b> as <b>"{role['title']}"</b>.</p> <p> The following message is leaved to project owner:</p> <p> {self.general_text}<p> <p> The project owner will view your application. The result will be notified through email.</p> <p>Dream Matchmaker Team</p> ''' result = smtp.send_email_html(col['email'], content, subject) return result
def notify_owner(self, conn, smtp): """Notify application to project owner through email Param: conn -- database connection smtp -- smtp server Return: smtp send result """ proj = Project.get_by_id(conn, self.project_id) role = Role.get_by_id(conn, self.role_apply) col = Collaborator.get_by_id(conn, self.applicant) dre = Dreamer.get_by_id(conn, proj['owner']) subject = '[DreamMatchmaker]You have a new project application' content = f'''<p>Hello {dre['name']},</p> <p> <b>{col['name']}</b> has applied to join your project <b>"{proj['title']}"</b> as <b>"{role['title']}"</b></p> <p> The following message is from the applicant:</p> <p> {self.general_text}<p> <p> You can view and accept or decline the application on the website.</p> <p>Dream Matchmaker Team</p> ''' result = smtp.send_email_html(dre['email'], content, subject) return result
def get_by_applicant(conn, user_ID): """Get all applications by a collaborator Param: conn -- database connection user_ID -- collaborator digit id Return: list of all application info for the collaborator """ # query by applicant query = "SELECT * FROM application where applicant = " + str( user_ID) + " order by ID desc;" result = conn.execute(query) applications = [] for i in range(result.rowcount): row = result.fetchone() # fetch information if row['status'] == -1: application_status = 'Pending' if row['status'] == 0: application_status = 'Declined' if row['status'] == 1: application_status = 'Approved' if row['status'] == 9: application_status = 'Finished' appli = { 'ApplicationID': row['ID'], 'projectID': row['projectID'], 'project_title': Project.get_by_id(conn, row['projectID'])['title'], 'Role_applied': row['role_applied'], 'Role_title': Role.get_by_id(conn, row['role_applied'])['title'], 'Applicant': row['applicant'], 'Application_status': application_status, 'General_text': row['general_text'] } applications.append(appli) return {'applications': applications, 'amount': result.rowcount}