Esempio n. 1
0
def sendAnnounce(request, announce_id):
    announcement = get_object_or_404(Announcement, pk=announce_id)
    if (not request.user.has_perm('announce.uniauth') and
            request.user.profile.member_organization !=
            announcement.member_organization):
        return HttpResponseRedirect(reverse('announce:announcements'))
    if request.method == 'POST' and announcement.sent is False:
        glean = announcement.glean
        mail_from_source(announcement)
        announcement.sent = True
        announcement.sent_by = request.user
        announcement.save()
        return HttpResponseRedirect(
            reverse('announce:detailannounce', args=(announce_id,)))
    else:
        return HttpResonseRedirect(
            reverse('announce:combinedannounce', args=(annouce_id,)))
Esempio n. 2
0
 def test_mail_from_source_no_recipients(self):
     county = create_county()
     user = create_user_and_profile()
     user.profile.counties.add(county)
     glean = create_glean(
         created_by=user,
         date=date.today() + timedelta(days=3),
         counties=county
     )
     announce = create_announcement(glean=glean)
     self.assertEqual(mail_from_source(announce), 0)
Esempio n. 3
0
def detailAnnounce(request, announce_id):
    announcement = get_object_or_404(Announcement, pk=announce_id)
    if (not request.user.has_perm('announce.uniauth') and
            request.user.profile.member_organization !=
            announcement.member_organization):
        return HttpResponseRedirect(reverse('announce:announcements'))
    body = render_mail(template, announcement, request.user.profile)
    glean = announcement.glean
    source = primary_source(announcement.glean)
    if request.method == 'POST' and announcement.sent is False:
        mail_from_source(announcement)
        announcement.sent = True
        announcement.sent_by = request.user
        announcement.save()
        return HttpResponseRedirect(
            reverse('announce:detailannounce', args=(announce_id,)))
    else:
        return render(
            request,
            'announce/announce_detail.html',
            {'announcement': announcement,
             'test': body,
             'glean': glean,
             'source': source})
Esempio n. 4
0
 def test_mail_from_source_testing_email(self):
     county = create_county()
     user = create_user_and_profile()
     user.profile.counties.add(county)
     glean = create_glean(
         created_by=user,
         date=date.today() + timedelta(days=3),
         counties=county
     )
     announce = create_announcement(glean=glean)
     memo = announce.member_organization
     memo.testing_email = "*****@*****.**"
     memo.testing = True
     memo.save()
     self.assertEqual(mail_from_source(announce), 1)
Esempio n. 5
0
    def test_mail_from_source_normal_function(self):
        county = create_county()
        user = create_user_and_profile()
        glean = create_glean(
            created_by=user,
            date=date.today() + timedelta(days=3),
            counties=county
        )
        announce = create_announcement(glean=glean)
        memo = announce.member_organization
        memo.testing = False
        memo.save()

        user = create_user_and_profile(tasks_gleaning=True)
        user.profile.counties.add(county)
        user = create_user_and_profile(tasks_gleaning=True)
        user.profile.counties.add(county)
        user = create_user_and_profile(tasks_gleaning=True)
        user.profile.counties.add(county)
        announce.populate_recipients()
        self.assertEqual(mail_from_source(announce), 3)