Exemplo n.º 1
0
def send_email_intern(request):
    sent = 0
    if request.method != 'POST':
        raise Http404
    emails = set()
    sender = request.POST.get('sender')
    if request.POST.get('allsubscription') == 'on':
        m_emails = MemberDao.members_for_email_with_subscription().values_list('email',
                                                                               flat=True)
        emails.update(m_emails)
    if request.POST.get('allshares') == 'on':
        emails.update(MemberDao.members_for_email_with_shares(
        ).values_list('email', flat=True))
    if request.POST.get('all') == 'on':
        emails.update(MemberDao.members_for_email(
        ).values_list('email', flat=True))
    if request.POST.get('recipients'):
        emails.update(re.split(r'[\s,;]+', request.POST.get('recipients')))
    if request.POST.get('allsingleemail'):
        emails.update(re.split(r'[\s,;]+', request.POST.get('singleemail')))

    files = []
    append_attachements(request, files)

    if len(emails) > 0:
        formemails.internal(
            request.POST.get('subject'),
            request.POST.get('message'),
            request.POST.get('textMessage'),
            emails, files, sender=sender
        )
        sent = len(emails)
    return redirect('mail-result', numsent=sent)
Exemplo n.º 2
0
def contact_member(request, member_id, job_id):
    '''
    member contact form
    '''
    member = request.user.member
    contact_member = get_object_or_404(Member, id=int(member_id))
    is_sent = False

    if request.method == 'POST':
        # send mail to member
        files = []
        append_attachements(request, files)
        formemails.contact_member(request.POST.get('subject'),
                                  request.POST.get('message'),
                                  member, contact_member,
                                  request.POST.get('copy'), files)
        is_sent = True
    job = JobDao.job_by_id(job_id)
    renderdict = get_menu_dict(request)
    renderdict.update({
        'admin':
        request.user.is_staff or job.type.activityarea.coordinator == member,
        'usernameAndEmail':
        member.first_name + ' ' + member.last_name + '<' + member.email + '>',
        'member_id':
        member_id,
        'member_name':
        contact_member.first_name + ' ' + contact_member.last_name,
        'is_sent':
        is_sent,
        'job_id':
        job_id
    })
    return render(request, 'contact_member.html', renderdict)
Exemplo n.º 3
0
def contact_member(request, member_id):
    '''
    member contact form
    '''
    member = request.user.member
    contact_member = get_object_or_404(Member, id=int(member_id))
    is_sent = False
    back_url = request.META.get('HTTP_REFERER') or reverse('home')

    if request.method == 'POST':
        # send mail to member
        back_url = request.POST.get('back_url')
        files = []
        append_attachements(request, files)
        formemails.contact_member(request.POST.get('subject'),
                                  request.POST.get('message'),
                                  member, contact_member,
                                  request.POST.get('copy'), files)
        is_sent = True
    renderdict = get_menu_dict(request)
    renderdict.update({
        'admin':
        request.user.has_perm('juntagrico.is_operations_group')
        or request.user.has_perm('juntagrico.is_area_admin'),
        'usernameAndEmail':
        member.first_name + ' ' + member.last_name + '<' + member.email + '>',
        'member_id':
        member_id,
        'member_name':
        contact_member.first_name + ' ' + contact_member.last_name,
        'is_sent':
        is_sent,
        'back_url':
        back_url
    })
    return render(request, 'contact_member.html', renderdict)