Beispiel #1
0
def get_recipient(value, request=None):
    recipients = Message.get(value).members + Message.get(value).externals
    if recipients:
        if (len(recipients)) > 1:
            return 'Mehrere Empfänger'
        recipient = recipients[0]
        if recipient.lastname == 'Verein':
            return 'Alle Mitglieder'
        return '{}, {}'.format(recipient.lastname, recipient.firstname)
Beispiel #2
0
def test__mail__print_or_sent_type_3(database, setUp):
    "It returns `Brief und E-Mail` if message is sent for multiple Members."
    from ..mail import print_or_sent_type, Message
    msg = Message.get(242)
    msg.printed = datetime.now()
    msg.sent = datetime.now()
    assert print_or_sent_type(msg.id) == "Brief und E-Mail"
Beispiel #3
0
def test__mail__print_or_sent_date_2(database, setUp):
    """It returns sent date if message is sent."""
    from ..mail import print_or_sent_date, Message
    now = datetime(2016, 3, 25, 9, 37)
    msg = Message.get(243)
    msg.sent = now
    assert print_or_sent_date(msg.id) == "25.03.2016 09:37"
Beispiel #4
0
def print_or_sent_type(value, request=None):
    message = Message.get(value)
    if message.sent and message.printed:
        return 'Brief und E-Mail'
    if message.sent:
        return 'E-Mail'
    if message.printed:
        return 'Brief'
Beispiel #5
0
def test__mail__MailPreviewView_1(browser, setUp):
    """It generates pdfs for recipients regardless of email."""
    from sw.allotmentclub import Message, Member
    message = Message.get(243)
    message.members.append(Member.create(
        email='*****@*****.**', street='Musterstrasse'))
    transaction.commit()
    browser.login()
    with mock.patch('sw.allotmentclub.browser.letter.datetime') as dt:
        dt.now.return_value = datetime(2016, 3, 25)
        browser.open('http://localhost/mail/243/preview')
    assertFileEqual(browser.contents, 'test_mail_preview_1.pdf')
Beispiel #6
0
def test__mail__MailSentView_1(browser, setUp, mailer):
    """It does not sent mail if already sent."""
    from sw.allotmentclub import Message, Member
    assert 0 == len(mailer.outbox)
    message = Message.get(243)
    message.members.append(Member.create(
        email='*****@*****.**', street='Musterstrasse'))
    transaction.commit()
    browser.login()
    browser.open('http://localhost/mail/243/send')
    assert browser.json['message'] == '1 E-Mail(s) erfolgreich versendet'
    assert 1 == len(mailer.outbox)
    assert 'Willkommen' in mailer.outbox[0].subject

    browser.open('http://localhost/mail/243/send')
    assert browser.json['message'] == 'Keine E-Mail versendet'
    assert 1 == len(mailer.outbox)
    assert browser.json['redirect'] == '/api/mail/243/download'
Beispiel #7
0
def test__mail__print_or_sent_type_2(database, setUp):
    """It returns `Brief` if message is printed."""
    from ..mail import print_or_sent_type, Message
    msg = Message.get(243)
    msg.printed = datetime.now()
    assert print_or_sent_type(msg.id) == "Brief"
Beispiel #8
0
def test__mail__print_or_sent_type_1(database, setUp):
    """It returns `E-Mail` if message is sent."""
    from ..mail import print_or_sent_type, Message
    msg = Message.get(243)
    msg.sent = datetime.now()
    assert print_or_sent_type(msg.id) == "E-Mail"
Beispiel #9
0
def print_or_sent_date(value, request=None):
    message = Message.get(value)
    if message.sent:
        return date_time(message.sent)
    if message.printed:
        return date_time(message.printed)