本文整理匯總了Python中zkpylons.model.location.Location類的典型用法代碼示例。如果您正苦於以下問題:Python Location類的具體用法?Python Location怎麽用?Python Location使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Location類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: table
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')
示例2: edit
def edit(self, id):
c.location = Location.find_by_id(id)
defaults = h.object_to_defaults(c.location, 'location')
form = render('/location/edit.mako')
return htmlfill.render(form, defaults)
示例3: _delete
def _delete(self, id):
c.location = Location.find_by_id(id)
meta.Session.delete(c.location)
meta.Session.commit()
h.flash("Location has been deleted.")
redirect_to('index')
示例4: new
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)
示例5: delete
def delete(self, id):
"""Delete the location
GET will return a form asking for approval.
POST requests will delete the item.
"""
c.location = Location.find_by_id(id)
return render('/location/confirm_delete.mako')
示例6: _edit
def _edit(self, id):
location = Location.find_by_id(id)
for key in self.form_result['location']:
setattr(location, key, self.form_result['location'][key])
# update the objects with the validated form data
meta.Session.commit()
h.flash("The Location has been updated successfully.")
redirect_to(action='index', id=None)
示例7: edit
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)
示例8: table
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')
示例9: ical
def ical(self, id):
c.schedule_collection = Location.find_by_id(id).schedule
ical = vobject.iCalendar()
for schedule in c.schedule_collection:
if not schedule.time_slot.heading:
event = ical.add('vevent')
event.add('uid').value = str(schedule.id) + '@' + Config.get('event_host')
# Created
tz = timezone(Config.get('time_zone'))
event.add('created').value = schedule.creation_timestamp.replace(tzinfo=tz)
# Last Modified
event.add('dtstamp').value = schedule.last_modification_timestamp.replace(tzinfo=tz)
event.add('last-modified').value = schedule.last_modification_timestamp.replace(tzinfo=tz)
# Start and End Time
event.add('dtstart').value = schedule.time_slot.start_time.replace(tzinfo=tz)
event.add('dtend').value = schedule.time_slot.end_time.replace(tzinfo=tz)
# Title and Author (need to add Author here)
event.add('summary').value = schedule.event.computed_title() + '. ' + h.list_to_string(schedule.event.computed_speakers())
# Abstract, if we have one
event.add('description').value = schedule.event.computed_abstract()
# Add a URL
if schedule.event.proposal:
event.add('url').value = h.url_for(qualified=True, controller='schedule', action='view_talk', id=schedule.event.proposal.id)
elif not (schedule.event.url is None or schedule.event.url == ''):
if schedule.event.url.startswith('https://') or schedule.event.url.startswith('http://'):
event.add('url').value = h.url_for(str(schedule.event.url))
else:
event.add('url').value = h.url_for(str(schedule.event.url), qualified=True)
concurrent_schedules = schedule.event.schedule_by_time_slot(schedule.time_slot)
for concurrent_schedule in concurrent_schedules:
if concurrent_schedule != schedule:
if concurrent_schedule in c.schedule_collection:
c.schedule_collection.remove(concurrent_schedule)
locations = [concurrent_schedule.location.display_name for concurrent_schedule in concurrent_schedules]
event.add('location').value = h.list_to_string(locations)
response.charset = 'utf8'
response.headers['content-type'] = 'text/calendar; charset=utf8'
response.headers.add('content-transfer-encoding', 'binary')
response.headers.add('Pragma', 'cache')
response.headers.add('Cache-Control', 'max-age=3600,public')
return ical.serialize()
示例10: index
def index(self):
c.location_collection = Location.find_all()
return render('/location/list.mako')
示例11: view
def view(self, id):
c.location = Location.find_by_id(id)
return render('/location/view.mako')