def test_parse_support_email_from_user_email(self): """ Ensure the correct support email address is returned. """ institution = Institution.objects.create( name='Example University', base_domain='example.ac.uk', support_email='*****@*****.**', ) test_cases = { "*****@*****.**": institution.support_email, "*****@*****.**": settings.DEFAULT_SUPPORT_EMAIL } for user_email, support_email in test_cases.items(): result = Institution.parse_support_email_from_user_email(user_email) self.assertEqual(result, support_email)
def user_created_notification(user): """ Notify support that a user has created an account. """ subject = _('{company_name} User Account Created'.format( company_name=settings.COMPANY_NAME)) support_email = Institution.parse_support_email_from_user_email(user.email) context = { 'first_name': user.first_name, 'last_name': user.last_name, 'university': user.profile.institution.name, 'reason': user.reason_for_account, 'to': support_email, } text_template_path = 'notifications/user/created.txt' html_template_path = 'notifications/user/created.html' email_user(subject, context, text_template_path, html_template_path)
def project_created_notification(project): """ Notify support that a new project has been created. """ subject = _('{company_name} Project Created'.format( company_name=settings.COMPANY_NAME)) support_email = Institution.parse_support_email_from_user_email( project.tech_lead.email) context = { 'code': project.code, 'university': project.tech_lead.profile.institution.name, 'technical_lead': project.tech_lead, 'title': project.title, 'to': support_email, } text_template_path = 'notifications/project/created.txt' html_template_path = 'notifications/project/created.html' email_user(subject, context, text_template_path, html_template_path)