Exemple #1
0
def copy(mailout, user):
    recipients = mailout.recipient_set.all()

    new_mailout = Mailout(subject=mailout.subject, body=mailout.body, organisation=mailout.organisation, created_by=user)
    new_mailout.save()
    for r in recipients:
        new_recipient = Recipient(mailout=new_mailout, user=r.user)
        new_recipient.save()

    return new_mailout.pk
Exemple #2
0
def copy(mailout, user):
    recipients = mailout.recipient_set.all()

    new_mailout = Mailout(subject=mailout.subject,
                          body=mailout.body,
                          organisation=mailout.organisation,
                          created_by=user)
    new_mailout.save()
    for r in recipients:
        new_recipient = Recipient(mailout=new_mailout, user=r.user)
        new_recipient.save()

    return new_mailout.pk
Exemple #3
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
Exemple #4
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