Exemplo n.º 1
0
def new(users, user, organisation_id=None):
    """Make and return a new mailout to be sent to the given list of users."""

    if not user.is_staff:
        organisation_id = user.get_profile().representativeprofile.organisation.id

    organisation = None
    if organisation_id:
        organisation = Organisation.objects.get(pk=organisation_id)

    mailout = Mailout(created_by=user, organisation=organisation)
    mailout.save()

    for u in users:
        r = Recipient(user=u)
        r.mailout = mailout
        r.save()

    return mailout
Exemplo n.º 2
0
def new(users, user, organisation_id=None):
    """Make and return a new mailout to be sent to the given list of users."""

    if not user.is_staff:
        organisation_id = user.get_profile(
        ).representativeprofile.organisation.id

    organisation = None
    if organisation_id:
        organisation = Organisation.objects.get(pk=organisation_id)

    mailout = Mailout(created_by=user, organisation=organisation)
    mailout.save()

    for u in users:
        r = Recipient(user=u)
        r.mailout = mailout
        r.save()

    return mailout