Exemplo n.º 1
0
 def clean_events(self):
     data = self.cleaned_data
     debate_count = 0
     ie_count = 0
     congress_count = 0
     tournament = db.get(data['tournament'])
     cur_event = db.get(data['event'])
     student = StudentInfo.all().filter('userID =', users.get_current_user())
     entries = models.Entries.all().filter('tournament =', tournament.key()).filter('student =', student.key())
     
     # count some entries. Whee.
     for entry in entries:
         if entry.event.eventType == 'debate':
             debate_count = debate_count + 1
         elif (entry.event.eventType == 'ie') or (entry.event.eventType == 'duo'):
             ie_count = ie_count + 1
         elif entry.event.eventType == 'congress':
             congress_count = congress_count + 1
     
     # You can't add more events than are allowed. 
     if (cur_event.eventType == 'debate') and (debate_count >= tournament.individualDebateEntryLimit):
         raise forms.ValidationError("You are already registered for the maximum number of debate events.")
     elif (cur_event.eventType == 'ie') and (ie_count >= tournament.individualIeEntryLimit):
         raise forms.ValidationError("You are already registered for the maximum number of individual and duo events.")
     elif (cur_event.eventType == 'duo') and (ie_count >= tournament.individualIeEntryLimit):
         raise forms.ValidationError("You are already registered for the maximum number of individual and duo events.")
     elif (cur_event.eventType == 'congress') and (congress_count >= tournament.individualCongressEntryLimit):
         raise forms.ValidationError("You are already registered for the maximum number of congress events.")
     
     return data
Exemplo n.º 2
0
def _getStudentEvents():
    student = users.get_current_user()
    query = StudentInfo.all().filter("studentID = ", student.user_id())
    record = query.get()
    if record:
        events = record.events
    else:
        events = "No Events! Damn."
    return events
Exemplo n.º 3
0
def entries(request, tournament_id=None):
    tournament = models.Tournaments.get_by_id(int(tournament_id))
    student = StudentInfo.get().filter('userID =', users.get_current_user())
    entries = models.Entries.all().filter('tournament =', tournament.key()).filter('student =', student.key())
    return render_to_response(
        'busticket/entries.html', {
        'entries' : entries,
        'tournament' : tournament,
        }
    )
Exemplo n.º 4
0
def tournament_entry(request, tournament_id=None):
    if request.method == 'POST':
        tournament = models.Tournaments.get_by_id(int(tournament_id))
        student = StudentInfo.get().filter('userID = ', users.get_current_user())
        entry_form = forms.EntryForm(tournament.key(), request.POST)
        if entry_form.is_valid():
            entry = entry_form.save(commit=False)
            entry.student = student.key()
            entry.put()
            response = '/entries/%s' % tournament_id
            return HttpResponseRedirect(response)
    else:
        tournament = models.Tournaments.get_by_id(int(tournament_id))
        entry_form = forms.EntryForm(tournament_id)
    return render_to_response('busticket/entryform.html', {
        'tournament' : tournament,
        'entry_form' : entry_form,
    })
Exemplo n.º 5
0
def get_partner_choices(tournament_id):

    students = StudentInfo.all()
    choices = [(p.key(), p.userID.nickname) for p in students]
    return choices