コード例 #1
0
ファイル: common.py プロジェクト: jcushman/perma
def contact(request):
    """
    Our contact form page
    """

    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            # If our form is valid, let's generate and email to our contact folks

            from_address = form.cleaned_data['email']

            content = '''
This is a message from the Perma.cc contact form, http://perma.cc/contact



Message from user
--------
%s
''' % (form.cleaned_data['message'])

            send_contact_email(
                "New message from Perma contact form",
                content,
                from_address,
                request
            )

            # redirect to a new URL:
            return HttpResponseRedirect(reverse('contact_thanks'))
        else:
            context = RequestContext(request, {'form': form})
            return render_to_response('contact.html', context)

    else:

        # Our contact form serves a couple of purposes
        # If we get a message parameter, we're getting a message from the create form
        # about a failed archive
        #
        # If we get a flagged parameter, we're getting the guid of an archive from the
        # Flag as inappropriate button on an archive page
        #
        # We likely want to clean up this contact for logic if we tack much else on
        
        message = request.GET.get('message', '')
        flagged_archive_guid = request.GET.get('flag', '')

        if flagged_archive_guid:
            message = 'http://perma.cc/%s contains material that is inappropriate.' % flagged_archive_guid


        form = ContactForm(initial={'message': message})

        context = RequestContext(request, {'form': form})
        return render_to_response('contact.html', context)
コード例 #2
0
ファイル: common.py プロジェクト: batessamantha/perma
def contact(request):
    """
    Our contact form page
    """

    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            # If our form is valid, let's generate and email to our contact folks

            from_address = form.cleaned_data['email']

            content = '''
This is a message from the Perma.cc contact form, http://perma.cc/contact



Message from user
--------
%s
''' % (form.cleaned_data['message'])

            send_contact_email(
                "New message from Perma contact form",
                content,
                from_address,
                request
            )

            # redirect to a new URL:
            return HttpResponseRedirect(reverse('contact_thanks'))
        else:
            context = RequestContext(request, {'form': form})
            return render_to_response('contact.html', context)

    else:
        form = ContactForm(initial={'message': request.GET.get('message', '')})

        context = RequestContext(request, {'form': form})
        return render_to_response('contact.html', context)
コード例 #3
0
ファイル: service.py プロジェクト: jcushman/perma
def receive_feedback(request):
    """
    Take feedback data and send it off in an email
    """

    visited_page = request.POST.get('visited_page')
    feedback_text = request.POST.get('feedback_text')
    broken_link = request.POST.get('broken_link')
    broken_text = ""
    if(broken_link):
        broken_text = '''There was a problem creating the following Perma
    %s
        
    ''' %(broken_link)
    
    from_address = request.POST.get('user_email')
    content = '''
Visited page: %s

COMMENTS
--------
%s


%s
''' % (visited_page, feedback_text, broken_text)
    logger.debug(content)
    
    send_contact_email(
        "New Perma feedback",
        content,
        from_address,
        request
    )
        
    response_object = {'submitted': 'true', 'content': content}

    return HttpResponse(json.dumps(response_object), content_type="application/json", status=201)