Example #1
0
    def table(self, day=None):
        # Check if we have any schedule information to display and tell people if we don't
        if len(c.scheduled_dates) == 0:
            return render('/schedule/no_schedule_available.mako')

        # Which day should we be showing now?
        c.display_date = None
        available_days = {
            scheduled_date.strftime('%A').lower(): scheduled_date
            for scheduled_date in c.scheduled_dates
        }
        if day in available_days:
            c.display_date = available_days[day]

        if c.display_date is None:
            if date.today() in c.scheduled_dates:
                c.display_date = date.today()
            else:
                c.display_date = c.scheduled_dates[0]

        # Work out which times we should be displaying on the left hand time scale
        c.time_slots = TimeSlot.find_by_date(c.display_date)
        c.primary_times = {
            time_slot.start_time: time_slot
            for time_slot in TimeSlot.find_by_date(c.display_date,
                                                   primary=True)
        }

        # Find all locations that have non-exclusive events
        start = datetime.combine(c.display_date, time.min)
        end = datetime.combine(c.display_date, time.max)
        c.locations = Location.query().join(Schedule).join(Event).join(
            TimeSlot).filter(TimeSlot.start_time.between(
                start, end)).filter(Event.exclusive != True).all()

        # Find the list of scheduled items for the required date
        c.schedule_collection = Schedule.find_by_date(c.display_date)

        # What time period will we break the time scale on the left into
        c.time_increment = timedelta(minutes=5)

        # Build up the programme for the requested day
        c.programme = OrderedDict()
        for time_slot in c.time_slots:
            mytime = time_slot.start_time
            while mytime < time_slot.end_time:
                c.programme[mytime] = {}
                mytime = mytime + c.time_increment
        for schedule in c.schedule_collection:
            exclusive_event = schedule.time_slot.exclusive_event()
            mytime = schedule.time_slot.start_time
            if exclusive_event:
                c.programme[mytime]['exclusive'] = exclusive_event
            else:
                c.programme[mytime][schedule.location] = schedule

        if 'raw' in request.GET:
            c.raw = True
        return render('/schedule/table.mako')
Example #2
0
    def table(self, day=None):
        filter = dict(request.GET)

        if len(c.scheduled_dates) == 0:
            return render('/schedule/no_schedule_available.mako')

        c.display_date = None

        available_days = {}
        for scheduled_date in c.scheduled_dates:
            available_days[scheduled_date.strftime('%A').lower()] = scheduled_date

        if day in available_days:
            c.display_date = available_days[day]

        if c.display_date is None:
            if date.today() in c.scheduled_dates:
                c.display_date = date.today()
            else:
                c.display_date = c.scheduled_dates[0]

        c.time_slots = TimeSlot.find_by_date(c.display_date)
        c.primary_times = {}
        for time_slot in TimeSlot.find_by_date(c.display_date, primary=True):
            c.primary_times[time_slot.start_time] = time_slot

        event_type = EventType.find_by_name('presentation')
        c.locations = Location.find_scheduled_by_date_and_type(c.display_date, event_type)
        event_type = EventType.find_by_name('mini-conf')
        c.locations = c.locations + Location.find_scheduled_by_date_and_type(c.display_date, event_type)

        c.schedule_collection = Schedule.find_by_date(c.display_date)

        c.time_increment = timedelta(minutes=5)

        c.programme = OrderedDict()

        for time_slot in c.time_slots:
            time = time_slot.start_time
            while time < time_slot.end_time:
                c.programme[time] = {}
                time = time + c.time_increment

        for schedule in c.schedule_collection:
            exclusive_event = schedule.time_slot.exclusive_event()
            time = schedule.time_slot.start_time
            if exclusive_event:
                c.programme[time]['exclusive'] = exclusive_event
            else:
                c.programme[time][schedule.location] = schedule

        if filter.has_key('raw'):
            return render('/schedule/table_raw.mako')
        else:
            return render('/schedule/table.mako')
Example #3
0
    def table(self, day=None):
        # Check if we have any schedule information to display and tell people if we don't
        if len(c.scheduled_dates) == 0:
            return render('/schedule/no_schedule_available.mako')

        # Which day should we be showing now?
        c.display_date = None
        available_days = { scheduled_date.strftime('%A').lower(): scheduled_date for scheduled_date in c.scheduled_dates }
        if day in available_days:
            c.display_date = available_days[day]

        if c.display_date is None:
            if date.today() in c.scheduled_dates:
                c.display_date = date.today()
            else:
                c.display_date = c.scheduled_dates[0]

        # Work out which times we should be displaying on the left hand time scale
        c.time_slots = TimeSlot.find_by_date(c.display_date)
        c.primary_times = { time_slot.start_time: time_slot  for time_slot in TimeSlot.find_by_date(c.display_date, primary=True) }

        # Find all locations that have non-exclusive events
        start = datetime.combine(c.display_date, time.min)
        end   = datetime.combine(c.display_date, time.max)
        c.locations = Location.query().join(Schedule).join(Event).join(TimeSlot).filter(TimeSlot.start_time.between(start, end)).filter(Event.exclusive != True).all()

        # Find the list of scheduled items for the required date
        c.schedule_collection = Schedule.find_by_date(c.display_date)

        # What time period will we break the time scale on the left into
        c.time_increment = timedelta(minutes=5)

        # Build up the programme for the requested day
        c.programme = OrderedDict()
        for time_slot in c.time_slots:
            mytime = time_slot.start_time
            while mytime < time_slot.end_time:
                c.programme[mytime] = {}
                mytime = mytime + c.time_increment
        for schedule in c.schedule_collection:
            exclusive_event = schedule.time_slot.exclusive_event()
            mytime = schedule.time_slot.start_time
            if exclusive_event:
                c.programme[mytime]['exclusive'] = exclusive_event
            else:
                c.programme[mytime][schedule.location] = schedule

        if 'raw' in request.GET:
            c.raw = True
        return render('/schedule/table.mako')
Example #4
0
    def _delete(self, id):
        c.time_slot = TimeSlot.find_by_id(id)
        meta.Session.delete(c.time_slot)
        meta.Session.commit()

        h.flash("Time Slot has been deleted.")
        redirect_to('index')
Example #5
0
    def new(self):
        c.signed_in_person = h.signed_in_person()
        c.events = Event.find_all()
        c.schedule = Schedule.find_all()
        c.time_slot = TimeSlot.find_all()
        if not c.signed_in_person.registration:
            return render('/vote/no_rego.mako')
        c.votes = Vote.find_by_rego(c.signed_in_person.registration.id)
        defaults = {'vote.vote_value': 1}
        args = request.GET
        eventid = args.get('eventid', 0)
        revoke = args.get('revoke', 0)
        c.eventid = eventid
        if int(eventid) != 0 and c.votes.count() < 4 and revoke == 0:
            c.vote = Vote()
            c.vote.rego_id = c.signed_in_person.registration.id
            c.vote.vote_value = 1
            c.vote.event_id = eventid
            meta.Session.add(c.vote)
            meta.Session.commit()
        if int(eventid) != 0 and int(revoke) != 0:
            c.vote = Vote.find_by_event_rego(
                eventid, c.signed_in_person.registration.id)
            meta.Session.delete(c.vote)
            meta.Session.commit()
            redirect_to('new')

        form = render('/vote/new.mako')
        return htmlfill.render(form, defaults)
Example #6
0
    def new(self):
        c.signed_in_person = h.signed_in_person()
        c.events = Event.find_all()
        c.schedule = Schedule.find_all()
        c.time_slot = TimeSlot.find_all()
        if not c.signed_in_person.registration:
          return render('/vote/no_rego.mako')
        c.votes = Vote.find_by_rego(c.signed_in_person.registration.id)
        defaults = {
            'vote.vote_value': 1 
        }
        args = request.GET
        eventid = args.get('eventid',0)
        revoke = args.get('revoke',0)
        c.eventid = eventid
        if int(eventid) != 0 and c.votes.count() < 4 and revoke == 0:
            c.vote = Vote()
            c.vote.rego_id = c.signed_in_person.registration.id
            c.vote.vote_value = 1
            c.vote.event_id = eventid
            meta.Session.add(c.vote)
            meta.Session.commit()
        if int(eventid) != 0 and int(revoke) != 0:
            c.vote = Vote.find_by_event_rego(eventid,c.signed_in_person.registration.id)
            meta.Session.delete(c.vote)
            meta.Session.commit()
            redirect_to('new')
  

        form = render('/vote/new.mako')
        return htmlfill.render(form, defaults)
Example #7
0
    def _delete(self, id):
        c.time_slot = TimeSlot.find_by_id(id)
        meta.Session.delete(c.time_slot)
        meta.Session.commit()

        h.flash("Time Slot has been deleted.")
        redirect_to('index')
Example #8
0
    def __before__(self, **kwargs):
        if h.signed_in_person():
            c.can_edit = h.signed_in_person().has_role('organiser')
        else:
            c.can_edit = False

        c.scheduled_dates = TimeSlot.find_scheduled_dates()
        c.subsubmenu = [['/programme/schedule/' + scheduled_date.strftime('%A').lower(), scheduled_date.strftime('%A')] for scheduled_date in c.scheduled_dates]
Example #9
0
    def __before__(self, **kwargs):
        if h.signed_in_person():
            c.can_edit = h.signed_in_person().has_role('organiser')
        else:
            c.can_edit = False

        c.scheduled_dates = TimeSlot.find_scheduled_dates()
        c.subsubmenu = [['/programme/schedule/' + scheduled_date.strftime('%A').lower(), scheduled_date.strftime('%A')] for scheduled_date in c.scheduled_dates]
Example #10
0
    def delete(self, id):
        """Delete the time_slot

        GET will return a form asking for approval.

        POST requests will delete the item.
        """
        c.time_slot = TimeSlot.find_by_id(id)
        return render('/time_slot/confirm_delete.mako')
Example #11
0
    def new(self):
        c.time_slots = TimeSlot.find_all()
        c.locations = Location.find_all()
        c.events = Event.find_all()

        form = render('/schedule/new.mako')
        object = {'schedule': self.form_result}
        defaults = NewScheduleSchema().from_python(object)
        return htmlfill.render(form, defaults)
Example #12
0
    def delete(self, id):
        """Delete the time_slot

        GET will return a form asking for approval.

        POST requests will delete the item.
        """
        c.time_slot = TimeSlot.find_by_id(id)
        return render('/time_slot/confirm_delete.mako')
Example #13
0
    def new(self):
        c.time_slots = TimeSlot.find_all()
        c.locations = Location.find_all()
        c.events = Event.find_all()

        form = render('/schedule/new.mako')
        object = { 'schedule': self.form_result }
        defaults = NewScheduleSchema().from_python(object)
        return htmlfill.render(form, defaults)
Example #14
0
    def edit(self, id):
        c.time_slot = TimeSlot.find_by_id(id)

        defaults = h.object_to_defaults(c.time_slot, 'time_slot')
        defaults['time_slot.start_date'] = c.time_slot.start_time.strftime('%d/%m/%y')
        defaults['time_slot.start_time'] = c.time_slot.start_time.strftime('%H:%M:%S')
        defaults['time_slot.end_date'] = c.time_slot.end_time.strftime('%d/%m/%y')
        defaults['time_slot.end_time'] = c.time_slot.end_time.strftime('%H:%M:%S')

        form = render('/time_slot/edit.mako')
        return htmlfill.render(form, defaults)
Example #15
0
    def edit(self, id):
        c.time_slots = TimeSlot.find_all()
        c.locations = Location.find_all()
        c.events = Event.find_all()
        c.schedule = Schedule.find_by_id(id)

        defaults = h.object_to_defaults(c.schedule, 'schedule')
        defaults['schedule.time_slot'] = c.schedule.time_slot_id
        defaults['schedule.location'] = c.schedule.location_id
        defaults['schedule.event'] = c.schedule.event_id

        form = render('/schedule/edit.mako')
        return htmlfill.render(form, defaults)
Example #16
0
    def edit(self, id):
        c.time_slots = TimeSlot.find_all()
        c.locations = Location.find_all()
        c.events = Event.find_all()
        c.schedule = Schedule.find_by_id(id)


        defaults = h.object_to_defaults(c.schedule, 'schedule')
        defaults['schedule.time_slot'] = c.schedule.time_slot_id
        defaults['schedule.location'] = c.schedule.location_id
        defaults['schedule.event'] = c.schedule.event_id

        form = render('/schedule/edit.mako')
        return htmlfill.render(form, defaults)
Example #17
0
    def edit(self, id):
        c.time_slot = TimeSlot.find_by_id(id)

        defaults = h.object_to_defaults(c.time_slot, 'time_slot')
        defaults['time_slot.start_date'] = c.time_slot.start_time.strftime(
            '%d/%m/%Y')
        defaults['time_slot.start_time'] = c.time_slot.start_time.strftime(
            '%H:%M')
        defaults['time_slot.end_date'] = c.time_slot.end_time.strftime(
            '%d/%m/%Y')
        defaults['time_slot.end_time'] = c.time_slot.end_time.strftime('%H:%M')

        form = render('/time_slot/edit.mako')
        return htmlfill.render(form, defaults)
Example #18
0
    def _edit(self, id):
        time_slot = TimeSlot.find_by_id(id)

        for key in self.form_result['time_slot']:
            setattr(time_slot, key, self.form_result['time_slot'][key])

        results = self.form_result['time_slot']
        time_slot.start_time=datetime.combine(results['start_date'], results['start_time'])
        time_slot.end_time=datetime.combine(results['end_date'], results['end_time'])

        # update the objects with the validated form data
        meta.Session.commit()
        h.flash("The Time Slot has been updated successfully.")
        redirect_to(action='index', id=None)
Example #19
0
    def _new(self):
        results = self.form_result['time_slot']
        results['start_time'] = datetime.combine(results['start_date'],
                                                 results['start_time'])
        results['end_time'] = datetime.combine(results['end_date'],
                                               results['end_time'])
        del results['start_date']
        del results['end_date']

        c.time_slot = TimeSlot(**results)
        meta.Session.add(c.time_slot)
        meta.Session.commit()

        h.flash("Time Slot created")
        redirect_to(action='index')
Example #20
0
    def _edit(self, id):
        time_slot = TimeSlot.find_by_id(id)

        for key in self.form_result['time_slot']:
            setattr(time_slot, key, self.form_result['time_slot'][key])

        results = self.form_result['time_slot']
        time_slot.start_time = datetime.combine(results['start_date'],
                                                results['start_time'])
        time_slot.end_time = datetime.combine(results['end_date'],
                                              results['end_time'])

        # update the objects with the validated form data
        meta.Session.commit()
        h.flash("The Time Slot has been updated successfully.")
        redirect_to(action='index', id=None)
Example #21
0
 def view(self, id):
     c.time_slot = TimeSlot.find_by_id(id)
     return render('/time_slot/view.mako')
Example #22
0
 def index(self):
     c.time_slot_collection = TimeSlot.find_all()
     return render('/time_slot/list.mako')
Example #23
0
 def index(self):
     c.time_slot_collection = TimeSlot.find_all()
     return render('/time_slot/list.mako')
Example #24
0
 def view(self, id):
     c.time_slot = TimeSlot.find_by_id(id)
     return render('/time_slot/view.mako')