<commit_before>from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.shortcuts import render_to_response, render, get_object_or_404
from django.views.decorators.clickjacking import xframe_options_exempt
from models import Director, Post, Postcategory, Illustration, Notice, Event, Smile, CommunityEvent
from datetime import datetime, timedelta
import re
from django import forms
from django.forms.models import modelformset_factory
from django.contrib.auth.decorators import login_required, user_passes_test, permission_required
from tinymce.widgets import TinyMCE
from django.conf  import settings

now = datetime.now # to be called in views to get the fresh now
today = datetime.now()
RECENT = today - timedelta(days = 180)
SOON   = today + timedelta(days = 60)
REALSOON  = today + timedelta(days = 4)
# mm = Post.objects.get(id = 6)
# mm.pub_date = datetime.datetime(2013, 8, 1, 13, 13, 13)
# mm.save()

def ticketing(request, id):
    """The post id is main article describing weekend. Looks up all event objects linked
    to the post. For each object, uses Eventbrite API to create an event page on Eventbrite,
    and creates all the usual tickets. Returns event id and adds it to event object.
    Makes all the Eventbrite events live, and publishes the main post and all event posts."""
    mainpost = Post.objects.get(id = id)
    events = Event.objects.filter(rpost = id)
    if request.method == 'POST': #We're going for it
        from eventbrite import Eventbrite
        eventbrite = Eventbrite(settings.TOKEN)
        capacity = 38
        eventzone = "America/New_York"
        t1 = {'ticket_class.name': 'Children (under 12)', 'ticket_class.cost': 'USD,300', 'ticket_class.quantity_total': capacity} 
        t2 = {'ticket_class.name': 'Member', 'ticket_class.cost': 'USD,500', 'ticket_class.quantity_total': capacity} 
        t3 = {'ticket_class.name': 'Adult', 'ticket_class.cost': 'USD,500', 'ticket_class.quantity_total': capacity} 
        t4 = {'ticket_class.name': 'Senior (60+)', 'ticket_class.cost': 'USD,300', 'ticket_class.quantity_total': capacity} 
        t5 = {'ticket_class.name': 'Support new programs for the Planetarium!', 'ticket_class.donation': True} 
        t1free = {'ticket_class.name': 'Children (under 12)', 'ticket_class.free': True, 'ticket_class.quantity_total': capacity} 
        t2free = {'ticket_class.name': 'Member', 'ticket_class.free': True, 'ticket_class.quantity_total': capacity} 
        t3free = {'ticket_class.name': 'Adult', 'ticket_class.free': True, 'ticket_class.quantity_total': capacity} 
        t4free = {'ticket_class.name': 'Senior (60+)', 'ticket_class.free': True, 'ticket_class.quantity_total': capacity} 
        t5free = {'ticket_class.name': 'Support new programs for the Planetarium!', 'ticket_class.donation': True} 
        tickets = [t1, t2, t3, t3, t5]
        freetickets = [t1free, t2free, t3free, t3free, t5free]
        evresponse = {}
        tkresponse = []
        for e in events:
            eventname = e.title
            eventdescription = e.content
            eventstart = loctime2ev(e.on)
            if e.end:
                eventend = loctime2ev(e.end)
            else:
                eventend = loctime2ev(e.on + timedelta(minutes = 60))
            #make a new event
            event = eventbrite.post_event({'event.name.html':eventname, 'event.description.html':eventdescription,
                                         'event.start.utc':eventstart, 'event.end.utc':eventend,
                                         'event.start.timezone':eventzone, 'event.end.timezone':eventzone,
                                         'event.currency': 'USD', 'event.capacity': capacity})
            evresponse['event'] = event
            #make tickets
            if e.free:
                ticketlist = freetickets
            else:
                ticketlist = tickets
            for ticket in ticketlist:
                tkresponse.append(eventbrite.post_event_ticket_class(event.get('id'), ticket))
            evresponse['tickets'] = tkresponse
    else: # Last chance to bail.
        pass        
    return render(request, 'ticketing.html', locals())
<commit_msg>Can't leave the seniors out.<commit_after>from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.shortcuts import render_to_response, render, get_object_or_404
from django.views.decorators.clickjacking import xframe_options_exempt
from models import Director, Post, Postcategory, Illustration, Notice, Event, Smile, CommunityEvent
from datetime import datetime, timedelta
import re
from django import forms
from django.forms.models import modelformset_factory
from django.contrib.auth.decorators import login_required, user_passes_test, permission_required
from tinymce.widgets import TinyMCE
from django.conf  import settings

now = datetime.now # to be called in views to get the fresh now
today = datetime.now()
RECENT = today - timedelta(days = 180)
SOON   = today + timedelta(days = 60)
REALSOON  = today + timedelta(days = 4)
# mm = Post.objects.get(id = 6)
# mm.pub_date = datetime.datetime(2013, 8, 1, 13, 13, 13)
# mm.save()

def ticketing(request, id):
    """The post id is main article describing weekend. Looks up all event objects linked
    to the post. For each object, uses Eventbrite API to create an event page on Eventbrite,
    and creates all the usual tickets. Returns event id and adds it to event object.
    Makes all the Eventbrite events live, and publishes the main post and all event posts."""
    mainpost = Post.objects.get(id = id)
    events = Event.objects.filter(rpost = id)
    if request.method == 'POST': #We're going for it
        from eventbrite import Eventbrite
        eventbrite = Eventbrite(settings.TOKEN)
        capacity = 38
        eventzone = "America/New_York"
        t1 = {'ticket_class.name': 'Children (under 12)', 'ticket_class.cost': 'USD,300', 'ticket_class.quantity_total': capacity} 
        t2 = {'ticket_class.name': 'Member', 'ticket_class.cost': 'USD,500', 'ticket_class.quantity_total': capacity} 
        t3 = {'ticket_class.name': 'Adult', 'ticket_class.cost': 'USD,500', 'ticket_class.quantity_total': capacity} 
        t4 = {'ticket_class.name': 'Senior (60+)', 'ticket_class.cost': 'USD,300', 'ticket_class.quantity_total': capacity} 
        t5 = {'ticket_class.name': 'Support new programs for the Planetarium!', 'ticket_class.donation': True} 
        t1free = {'ticket_class.name': 'Children (under 12)', 'ticket_class.free': True, 'ticket_class.quantity_total': capacity} 
        t2free = {'ticket_class.name': 'Member', 'ticket_class.free': True, 'ticket_class.quantity_total': capacity} 
        t3free = {'ticket_class.name': 'Adult', 'ticket_class.free': True, 'ticket_class.quantity_total': capacity} 
        t4free = {'ticket_class.name': 'Senior (60+)', 'ticket_class.free': True, 'ticket_class.quantity_total': capacity} 
        t5free = {'ticket_class.name': 'Support new programs for the Planetarium!', 'ticket_class.donation': True} 
        tickets = [t1, t2, t3, t4, t5]
        freetickets = [t1free, t2free, t3free, t4free, t5free]
        evresponse = {}
        tkresponse = []
        for e in events:
            eventname = e.title
            eventdescription = e.content
            eventstart = loctime2ev(e.on)
            if e.end:
                eventend = loctime2ev(e.end)
            else:
                eventend = loctime2ev(e.on + timedelta(minutes = 60))
            #make a new event
            event = eventbrite.post_event({'event.name.html':eventname, 'event.description.html':eventdescription,
                                         'event.start.utc':eventstart, 'event.end.utc':eventend,
                                         'event.start.timezone':eventzone, 'event.end.timezone':eventzone,
                                         'event.currency': 'USD', 'event.capacity': capacity})
            evresponse['event'] = event
            #make tickets
            if e.free:
                ticketlist = freetickets
            else:
                ticketlist = tickets
            for ticket in ticketlist:
                tkresponse.append(eventbrite.post_event_ticket_class(event.get('id'), ticket))
            evresponse['tickets'] = tkresponse
    else: # Last chance to bail.
        pass        
    return render(request, 'ticketing.html', locals())

{'fraction_non_alphanumeric': 0.1102792632204397, 'fraction_numerical': 0.017112299465240642, 'mean_word_length': 2.9623352165725048, 'pattern_counts': {'":': 0, '<': 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': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '68880', 'n_tokens_mistral': 2630, 'n_tokens_neox': 2393, 'n_words': 680}