def mail_project_complete(project): with TenantLanguage(project.owner.primary_language): subject = _(u"The project '{0}' has been realised").format(project.title) survey_link = Survey.url(project, user_type='initiator') send_mail( template_name="projects/mails/project_complete.mail", subject=subject, to=project.owner, title=project.title, receiver_name=project.owner.short_name, survey_link=mark_safe(survey_link) if survey_link else None, site=tenant_url(), link='/go/projects/{0}'.format(project.slug) ) if project.organization: with TenantLanguage(project.owner.primary_language): subject = _(u"The project '{0}' has been realised").format(project.title) survey_link = Survey.url(project, user_type='organization') send_mail( template_name="projects/mails/organization_project_complete.mail", subject=subject, to=project.organization, title=project.title, receiver_name=project.organization.name, survey_link=mark_safe(survey_link) if survey_link else None, site=tenant_url(), link='/go/projects/{0}'.format(project.slug) )
def mail_project_complete(project): with TenantLanguage(project.owner.primary_language): subject = _(u"The project '{0}' has been realised").format( project.title) survey_link = Survey.url(project, user_type='initiator') send_mail(template_name="projects/mails/project_complete.mail", subject=subject, to=project.owner, title=project.title, receiver_name=project.owner.short_name, survey_link=mark_safe(survey_link) if survey_link else None, site=tenant_url(), link='/go/projects/{0}'.format(project.slug)) if project.organization: with TenantLanguage(project.owner.primary_language): subject = _(u"The project '{0}' has been realised").format( project.title) survey_link = Survey.url(project, user_type='organization') send_mail( template_name="projects/mails/organization_project_complete.mail", subject=subject, to=project.organization, title=project.title, receiver_name=project.organization.name, survey_link=mark_safe(survey_link) if survey_link else None, site=tenant_url(), link='/go/projects/{0}'.format(project.slug))
def test_complete_with_organization(self): self.project.organization = OrganizationFactory.create(email='*****@*****.**') self.project.status = self.complete self.project.save() self.assertEquals(len(mail.outbox), 2) initiator_email = mail.outbox[0] self.assertEqual(initiator_email.to, [self.project.owner.email]) self.assertTrue('has been realised' in initiator_email.subject) self.assertTrue(Survey.url(self.project, user_type='initiator') in initiator_email.body) organization_email = mail.outbox[1] self.assertEqual(organization_email.to, [self.project.organization.email]) self.assertTrue('has been realised' in organization_email.subject) self.assertTrue(Survey.url(self.project, user_type='organization') in organization_email.body)
def test_survey_url_project(self): url = urlparse( Survey.url(self.project) ) query = parse_qs(url.query) self.assertEqual(url.netloc, 'example.com') self.assertEqual(query['theme'], [self.theme.slug]) self.assertEqual(query['project_id'], [str(self.project.id)]) self.assertTrue('task_id' not in query)
def test_survey_url_user_type(self): url = urlparse( Survey.url(self.task, user_type='initiator'), ) query = parse_qs(url.query) self.assertEqual(url.netloc, 'example.com') self.assertEqual(query['theme'], [self.theme.slug]) self.assertEqual(query['project_id'], [str(self.project.id)]) self.assertEqual(query['task_id'], [str(self.task.id)]) self.assertEqual(query['user_type'], ['initiator'])
def test_complete_with_organization(self): self.survey = SurveyFactory(link='https://example.com/survey/1/', active=True) self.project.organization = OrganizationFactory.create( email='*****@*****.**') self.project.status = self.complete self.project.save() self.assertEquals(len(mail.outbox), 2) initiator_email = mail.outbox[0] self.assertEqual(initiator_email.to, [self.project.owner.email]) self.assertTrue('has been realised' in initiator_email.subject) self.assertTrue( Survey.url(self.project, user_type='initiator') in initiator_email.body) organization_email = mail.outbox[1] self.assertEqual(organization_email.to, [self.project.organization.email]) self.assertTrue('has been realised' in organization_email.subject) self.assertTrue( Survey.url(self.project, user_type='organization') in organization_email.body)
def __init__(self, instance, *args, **kwargs): TaskMemberMailSender.__init__(self, instance, *args, **kwargs) self.template_mail = 'task_member_realized.mail' self.receiver = self.task_member.member with TenantLanguage(self.receiver.primary_language): self.subject = _('You realised a task!') survey_url = Survey.url(self.task) self.ctx = {'task': self.task, 'receiver': self.receiver, 'sender': self.task.author, 'link': self.task_link, 'survey_link': mark_safe(survey_url) if survey_url else None, 'site': self.site, 'task_list': self.task_list, 'project_link': self.project_link}
def test_survey_url_no_celebration(self): self.project.celebrate_results = False self.project.save() self.assertIsNone(Survey.url(self.project))
def test_survey_url_no_survey(self): self.survey.delete() self.assertIsNone(Survey.url(self.task))
def __init__(self, *args, **kwargs): TaskMemberMailSender.__init__(self, *args, **kwargs) survey_url = Survey.url(self.task) self.ctx['survey_link'] = mark_safe(survey_url) if survey_url else None self.ctx['time_spent'] = self.task_member.time_spent