Example #1
0
def upload_no_captcha(request):
    if request.method == 'POST':  # If the form has been submitted...
        recording = Recording()
        # Check if recording submitted by ACLU-NJ Police Tape
        # These recording filenames are of form XXXX_aclunj.XXX
        #print 'checking ' + str(request.FILES['rec_file'].name)

        tag = recording_tags.ACLU_NJ
        if "_aclunj." in str(request.FILES['rec_file'].name):
            #print str(request.FILES['rec_file'].name) + ' will be tagged with ' + tag
            recording.add_tag(tag)
            # Police Tape appends email to existing privDesc:
            # privDesc = privDesc + "[" + email + "]";

            #recording.email = request.POST.get('private_description', '').rsplit("[", 1)[1].rsplit("]", 1)[0]
            potential_emails = request.POST.get('private_description',
                                                '').rsplit("[", 1)
            if len(potential_emails) > 1:
                potential_emails = potential_emails[1].rsplit("]", 1)
            potential_email = ''
            if len(potential_emails) > 0:
                potential_email = potential_emails[0]
            if validate_email(potential_email):
                recording.email = potential_email
                private_descriptions = request.POST.get(
                    'private_description',
                    'No description available').rsplit("[", 1)
                if len(private_descriptions) > 0:
                    recording.private_description = private_descriptions[0]
            else:
                recording.private_description = request.POST.get(
                    'private_description', 'No description available')
        else:
            recording.private_description = request.POST.get(
                'private_description', 'No description available')

        recording.public_description = request.POST.get(
            'public_description', 'No description available')
        recording.name = request.POST.get('name', 'No description available')
        recording.public_description = request.POST.get(
            'public_description', 'No description available')
        recording.location = request.POST.get('location',
                                              'No description available')
        recording.rec_file = request.FILES['rec_file']
        recording.date = datetime.now()
        recording.save()
        return HttpResponseRedirect('/victory')  # Redirect after POST
    else:
        form = RecordingNoCaptchaForm()  # An unbound form

    featureset = Recording.objects.filter(
        featured=True).all().order_by('-date')
    return render_to_response('upload_nocaptcha.html', {
        'form': form,
        'featured': list(featureset)[0:5],
        'cat': 'upload'
    })
Example #2
0
def upload_no_captcha(request):
    if request.method == 'POST':  # If the form has been submitted...
        recording = Recording()
        # Check if recording submitted by ACLU-NJ Police Tape 
        # These recording filenames are of form XXXX_aclunj.XXX
        #print 'checking ' + str(request.FILES['rec_file'].name)

        tag = recording_tags.ACLU_NJ
        if "_aclunj." in str(request.FILES['rec_file'].name):
            #print str(request.FILES['rec_file'].name) + ' will be tagged with ' + tag
            recording.add_tag(tag)
            # Police Tape appends email to existing privDesc:
            # privDesc = privDesc + "[" + email + "]";

            #recording.email = request.POST.get('private_description', '').rsplit("[", 1)[1].rsplit("]", 1)[0]
            potential_emails = request.POST.get('private_description', '').rsplit("[", 1)
            if len(potential_emails) > 1:
                potential_emails = potential_emails[1].rsplit("]", 1)
            potential_email = ''
            if len(potential_emails) > 0:
                potential_email = potential_emails[0]
            if validate_email(potential_email):
                recording.email = potential_email
                private_descriptions = request.POST.get('private_description', 'No description available').rsplit("[", 1)
                if len(private_descriptions) > 0:
                    recording.private_description = private_descriptions[0]
            else:
                recording.private_description = request.POST.get('private_description', 'No description available')
        else:
            recording.private_description = request.POST.get('private_description', 'No description available')

        recording.public_description = request.POST.get('public_description', 'No description available')
        recording.name = request.POST.get('name', 'No description available')
        recording.public_description = request.POST.get('public_description', 'No description available')
        recording.location = request.POST.get('location', 'No description available')
        recording.rec_file = request.FILES['rec_file']
        recording.date = datetime.now()
        recording.save()
        return HttpResponseRedirect('/victory')  # Redirect after POST
    else:
        form = RecordingNoCaptchaForm()  # An unbound form

    featureset = Recording.objects.filter(featured=True).all().order_by('-date')
    return render_to_response('upload_nocaptcha.html', {
        'form': form,
        'featured': list(featureset)[0:5],
        'cat': 'upload'
    })