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' })
def handle(self, *args, **options): do_execute = options.get('execute') if do_execute: action = "tagged" else: action = "should be tagged" modified_count = 0 total = len(Recording.objects.all()) # Look for ACLU-NJ recordings: tag = recording_tags.ACLU_NJ for recording in Recording.objects.all(): #print 'checking ' + str(recording.rec_file) if "_aclunj" in str(recording.rec_file): do_save = False if do_execute: # If this recording is all ready tagged to an organization, # assume it has been processed properly #print recording.tags if tag not in recording.tags: self.write('Recording %d (%s) %s with %s \n' % (recording.pk, recording.name, action, tag)) recording.add_tag(tag) do_save = True modified_count += 1 # Check for Police Tape embedded email # Police Tape appends email to existing privDesc: # privDesc = privDesc + "[" + email + "]"; try: potential_email = recording.private_description.rsplit( "[", 1)[1].rsplit("]", 1)[0] #if re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$", potential_email): if validate_email(potential_email): recording.email = potential_email recording.private_description = recording.private_description.rsplit( "[", 1)[0] do_save = True except: # If we couldn't parse the email from private description, assume it didn't exist pass if do_save: recording.save() else: # If not do_execute, only indicate recordings if tag not in recording.tags: modified_count += 1 self.write('Recording %d (%s) %s with %s \n' % (recording.pk, recording.name, action, tag)) self.write('%d/%d Recordings %s \n' % (modified_count, total, action))
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' })
def handle(self, *args, **options): do_execute = options.get('execute') if do_execute: action = "tagged" else: action = "should be tagged" modified_count = 0 total = len(Recording.objects.all()) # Look for ACLU-NJ recordings: tag = recording_tags.ACLU_NJ for recording in Recording.objects.all(): #print 'checking ' + str(recording.rec_file) if "_aclunj" in str(recording.rec_file): do_save = False if do_execute: # If this recording is all ready tagged to an organization, # assume it has been processed properly #print recording.tags if tag not in recording.tags: self.write('Recording %d (%s) %s with %s \n' % (recording.pk, recording.name, action, tag)) recording.add_tag(tag) do_save = True modified_count += 1 # Check for Police Tape embedded email # Police Tape appends email to existing privDesc: # privDesc = privDesc + "[" + email + "]"; try: potential_email = recording.private_description.rsplit("[", 1)[1].rsplit("]", 1)[0] #if re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$", potential_email): if validate_email(potential_email): recording.email = potential_email recording.private_description = recording.private_description.rsplit("[", 1)[0] do_save = True except: # If we couldn't parse the email from private description, assume it didn't exist pass if do_save: recording.save() else: # If not do_execute, only indicate recordings if tag not in recording.tags: modified_count += 1 self.write('Recording %d (%s) %s with %s \n' % (recording.pk, recording.name, action, tag)) self.write('%d/%d Recordings %s \n' % (modified_count, total, action))