<commit_before>from django.shortcuts import render_to_response
from django.template.loader import render_to_string
from django.template import RequestContext
from django.views.decorators.csrf import csrf_exempt
from django.conf import settings
from reg.models import *
from reg.forms import *
from reg.email_utils import *

from django.forms.util import ErrorList

from django.http import Http404, HttpResponse

from sked.urls import CURRENT_EVENT

import json
from collections import defaultdict

import braintree

def register(request):
    payment_form = PaymentForm()
    ticket_form = TicketForm()

    ticket_types = TicketType.objects.filter(event=CURRENT_EVENT, enabled=True).order_by('position')

    attendees = Ticket.objects.filter(event=CURRENT_EVENT, success=True).order_by('-id')

    return render_to_response('reg/register.html', {'ticket_form': ticket_form, 'payment_form': payment_form, 'ticket_types': ticket_types, 'attendees': attendees, 'BRAINTREE_CSE_KEY': getattr(settings, "BRAINTREE_CSE_KEY", "")}, context_instance=RequestContext(request))

@csrf_exempt
def save(request):
    if request.method != "POST":
        raise Http404
    try:
        data = json.loads(request.raw_post_data)
    except:
        raise Http404
    
    sale = Sale()
    out = {'ticket_forms': [], 'success': True}
    types = defaultdict(int)
    valid_tickets = []
    for form_id, form_data in data['ticket_forms'].items():
        form_response = {'id': form_id}
        form = TicketForm(form_data)
        if form.is_valid():
            form_response['success'] = True
            valid_tickets.append(form)
            types[int(form_data['type'])] += 1<commit_msg>Prevent caching of registration page.<commit_after>from django.shortcuts import render_to_response
from django.template.loader import render_to_string
from django.template import RequestContext
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.cache import never_cache
from django.conf import settings
from reg.models import *
from reg.forms import *
from reg.email_utils import *

from django.forms.util import ErrorList

from django.http import Http404, HttpResponse

from sked.urls import CURRENT_EVENT

import json
from collections import defaultdict

import braintree

@never_cache
def register(request):
    payment_form = PaymentForm()
    ticket_form = TicketForm()

    ticket_types = TicketType.objects.filter(event=CURRENT_EVENT, enabled=True).order_by('position')

    attendees = Ticket.objects.filter(event=CURRENT_EVENT, success=True).order_by('-id')

    return render_to_response('reg/register.html', {'ticket_form': ticket_form, 'payment_form': payment_form, 'ticket_types': ticket_types, 'attendees': attendees, 'BRAINTREE_CSE_KEY': getattr(settings, "BRAINTREE_CSE_KEY", "")}, context_instance=RequestContext(request))

@csrf_exempt
def save(request):
    if request.method != "POST":
        raise Http404
    try:
        data = json.loads(request.raw_post_data)
    except:
        raise Http404
    
    sale = Sale()
    out = {'ticket_forms': [], 'success': True}
    types = defaultdict(int)
    valid_tickets = []
    for form_id, form_data in data['ticket_forms'].items():
        form_response = {'id': form_id}
        form = TicketForm(form_data)
        if form.is_valid():
            form_response['success'] = True
            valid_tickets.append(form)
            types[int(form_data['type'])] += 1
{'fraction_non_alphanumeric': 0.10362844702467344, 'fraction_numerical': 0.005805515239477504, 'mean_word_length': 4.3343653250774, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1633955', 'n_tokens_mistral': 1058, 'n_tokens_neox': 1026, 'n_words': 240}