Пример #1
0
def confirm(request):
    try:
        event = Event()
        scheduledStatus = EventStatus.objects.get(name = "Scheduled")
        confirmedStatus = EventStatus.objects.get(name = "Confirmed")
        
        try:
            event = Event.objects.get(id = request.POST['event_id'])
            #matchup = Matchup.objects.get(id = request.POST['matchup_id'])
        except:
            raise Exception, "Unable to find specified time slot."
        
        # check to see if event has already progressed into scheduling, in that case we can not delete it
        if event.eventStatus != scheduledStatus:
            raise Exception, "Game (id: %d) has not been scheduled." % event.id

        event.eventStatus = confirmedStatus
        event.save()
        
        # generate email response
        send_event_confirmed_notification(event.id)
        
        response = {'status': "Confirmed for <b>%s</b> at <a href='%s'>%s</a>." % (event, 
                                                           event.rink.get_absolute_url(), 
                                                           event.rink)}
    except Exception, error:
        response = {'error': str(error)}
Пример #2
0
def create(request):
    
    # attempt to create a new event
    try:
        event = Event()
        event.dateTimeEvent = datetime(*strptime("%s %s:%s %s" % (request.POST['event_date'], 
                                                        request.POST['event_hour'], 
                                                        request.POST['event_minute'], 
                                                        request.POST['event_am']), "%m/%d/%Y %I:%M %p")[:6])
        event.eventStatus = EventStatus.objects.get(name = "Available")
        event.eventType = EventType.objects.get(id = request.POST['event_type'])
        event.rink = Rink.objects.get(id = request.POST['event_rink'])
        event.homeTeam = request.user.get_profile().team
        event.season = Season.objects.get(isCurrentSeason = True)
        event.save()
        
        #timeSlots = Event.objects.all().filter(eventType = request.POST['event_type'], homeTeam = request.user.get_profile().team, season = Season.objects.get(isCurrentSeason = True)).count()
        #timeSlot = timeSlots + 1
        
        response = {'object_id': event.id,
                    'eventType': str(event.eventType), 
                    'rink': str(event.rink), 
                    'date': strftime("%b %e, %Y", event.dateTimeEvent.timetuple()),
                    'time': strftime("%I:%M %p", event.dateTimeEvent.timetuple())}
        
    except Exception, error:
        response = {'error': str(error)}
Пример #3
0
def reject(request):
    try:
        event = Event()
        availableStatus = EventStatus.objects.get(name = "Available")
        scheduledStatus = EventStatus.objects.get(name = "Scheduled")
        
        try:
            event = Event.objects.get(id = request.POST['event_id'])
            #matchup = Matchup.objects.get(id = request.POST['matchup_id'])
        except:
            raise Exception, "Unable to find specified time slot."
        
        # check to see if event has already progressed into scheduling, in that case we can not delete it
        if event.eventStatus != scheduledStatus:
            raise Exception, "Game (id: %d) has not been scheduled." % event.id

        event.eventStatus = availableStatus
        event.awayTeam = None
        event.matchup = None
        event.save()
        
        # generate email response
        send_event_rejected_notification(event.id)
        
        response = {'status': "Rejected game request."}
    except Exception, error:
        response = {'error': str(error)}
Пример #4
0
def schedule(request):
    try:
        event = Event()
        matchup = Matchup()
        availableStatus = EventStatus.objects.get(name = "Available")
        scheduledStatus = EventStatus.objects.get(name = "Scheduled")
        
        try:
            event = Event.objects.get(id = request.POST['event_id'])
            matchup = Matchup.objects.get(id = request.POST['matchup_id'])
        except:
            raise Exception, "Unable to find specified time slot."
        
        # check to see if event has already progressed into scheduling, in that case we can not delete it
        if event.eventStatus != availableStatus:
            raise Exception, "Game has already been scheduled for this time slot."

        event.eventStatus = scheduledStatus
        event.awayTeam = request.user.get_profile().team
        event.matchup = matchup
        event.save()
        
        # generate email response
        send_event_scheduled_notification(event.id)
        
        response = {'status': "Game requested on <b>%s</b> at <a href='%s'>%s</a>." % (event, 
                                                                                       event.rink.get_absolute_url(), 
                                                                                       event.rink)}
    except Exception, error:
        response = {'error': str(error)}