def urls(self, allocation): """Returns the options for the js contextmenu for the given allocation as well as other links associated with the event. """ items = utils.EventUrls(self.context, self.request, exposure) start = utils.utctimestamp( allocation.display_start(settings.timezone())) end = utils.utctimestamp(allocation.display_end(settings.timezone())) items.move_url('edit-allocation', dict(id=allocation.id)) # Reservation res_add = lambda n, v, p, t: \ items.menu_add(_(u'Reservations'), n, v, p, t) if allocation.is_separate: res_add(_(u'Reserve'), 'reserve', dict(id=allocation.id, start=start, end=end), 'overlay') items.default_url('reserve', dict(id=allocation.id, start=start, end=end)) else: res_add(_(u'Reserve'), 'reserve-group', dict(group=allocation.group), 'overlay') items.default_url('reserve', dict(group=allocation.group)) res_add(_(u'Manage'), 'reservations', dict(group=allocation.group), 'inpage') # menu entries for single items entry_add = lambda n, v, p, t: \ items.menu_add(_('Entry'), n, v, p, t) entry_add(_(u'Edit'), 'edit-allocation', dict(id=allocation.id), 'overlay') entry_add(_(u'Remove'), 'remove-allocation', dict(id=allocation.id), 'overlay') if allocation.in_group: # menu entries for group items group_add = lambda n, v, p, t: \ items.menu_add(_('Recurrences'), n, v, p, t) group_add(_(u'List'), 'group', dict(name=allocation.group), 'overlay') group_add(_(u'Remove'), 'remove-allocation', dict(group=allocation.group), 'overlay') # view selections if 'agendaDay' in self.context.available_views: items.menu_add( _(u'Reservations'), _(u'Daily View'), 'view', dict(selected_view='agendaDay', specific_date=allocation.start.strftime('%Y-%m-%d')), 'window') return items
def add_allocation( self, resource, start, end, partly_available=False, quota=1, quota_limit=1, approve_manually=False ): browser = self.admin_browser s = utils.utctimestamp(start) e = utils.utctimestamp(end) allocate_url = '/%s/allocate?start=%s&end=%s' % (resource, s, e) browser.open(self.infolder(allocate_url)) # Plone formats the English run tests like this: 1:30 AM # Python does not do single digit hours so we strip. ds = start.strftime('%I:%M %p').lstrip('0') de = end.strftime('%I:%M %p').lstrip('0') self.assertTrue(ds in browser.contents) self.assertTrue(de in browser.contents) browser.getControl('Partly available').selected = partly_available browser.getControl('Quota', index=0).value = str(quota) browser.getControl('Reservation Quota Limit').value = str(quota_limit) browser.getControl( 'Manually approve reservation requests' ).selected = approve_manually browser.getControl('Allocate').click()
def load_slot_data(self, resource, start, end): browser = self.admin_browser s = utils.utctimestamp(start) e = utils.utctimestamp(end) slots_url = '/%s/slots?start=%s&end=%s' % (resource, s, e) browser.open(self.infolder(slots_url)) return json.loads(browser.contents.replace('\n', ''))
def add_allocation( self, resource, start, end, partly_available=False, quota=1, quota_limit=1, approve_manually=False, recurrence=None, separately=None ): browser = self.admin_browser s = utils.utctimestamp(start) e = utils.utctimestamp(end) allocate_url = '/%s/allocate?start=%s&end=%s' % (resource, s, e) browser.open(self.infolder(allocate_url)) # Plone formats the English run tests like this: 1:30 AM # Python does not do single digit hours so we strip. ds = start.strftime('%I:%M %p').lstrip('0') de = end.strftime('%I:%M %p').lstrip('0') self.assertTrue(ds in browser.contents) self.assertTrue(de in browser.contents) browser.getControl('Partly available').selected = partly_available browser.getControl('Quota', index=0).value = str(quota) browser.getControl('Reservation Quota Limit').value = str(quota_limit) if recurrence: browser.getControl('Recurrence').value = recurrence if separately is not None: browser.getControl('Separately reservable').selected = separately if recurrence: browser.getControl('Recurrence').value = recurrence if separately is not None: browser.getControl('Separately reservable').selected = separately browser.getControl( 'Manually approve reservation requests' ).selected = approve_manually browser.getControl('Allocate').click()
def urls(self, allocation): """Returns the options for the js contextmenu for the given allocation as well as other links associated with the event. """ items = utils.EventUrls(self.context, self.request, exposure) start = utils.utctimestamp(allocation.display_start) end = utils.utctimestamp(allocation.display_end) items.move_url('edit-allocation', dict(id=allocation.id)) # Reservation res_add = lambda n, v, p, t: \ items.menu_add(_(u'Reservations'), n, v, p, t) if allocation.is_separate: res_add( _(u'Reserve'), 'reserve', dict(id=allocation.id, start=start, end=end), 'overlay' ) items.default_url( 'reserve', dict(id=allocation.id, start=start, end=end) ) else: res_add( _(u'Reserve'), 'reserve-group', dict(group=allocation.group), 'overlay' ) items.default_url( 'reserve', dict(group=allocation.group) ) if allocation.in_recurrence: manage_params = dict(recurring_allocation_id=allocation.id) else: manage_params = dict(group=allocation.group) res_add(_(u'Manage'), 'reservations', manage_params, 'inpage') # menu entries for single items entry_add = lambda n, v, p, t: \ items.menu_add(_('Entry'), n, v, p, t) entry_add( _(u'Edit'), 'edit-allocation', dict(id=allocation.id), 'overlay' ) entry_add( _(u'Remove'), 'remove-allocation', dict(id=allocation.id), 'overlay' ) if not allocation.in_group and not allocation.in_recurrence: return items group_add = lambda n, v, p, t: \ items.menu_add(_('Recurrences'), n, v, p, t) if allocation.in_recurrence: params = dict(recurrence_id=allocation.recurrence_id) group_add( _(u'List'), 'group', params, 'overlay' ) group_add( _(u'Remove'), 'remove-allocation', params, 'overlay' ) elif allocation.in_group: # menu entries for group items group_add( _(u'List'), 'group', dict(name=allocation.group), 'overlay' ) group_add( _(u'Remove'), 'remove-allocation', dict(group=allocation.group), 'overlay' ) return items
def urls(self, allocation): """Returns the options for the js contextmenu for the given allocation as well as other links associated with the event. """ items = utils.EventUrls(self.context, self.request, exposure) start = utils.utctimestamp( allocation.display_start(settings.timezone())) end = utils.utctimestamp( allocation.display_end(settings.timezone())) items.move_url('edit-allocation', dict(id=allocation.id)) # Reservation res_add = lambda n, v, p, t: \ items.menu_add(_(u'Reservations'), n, v, p, t) if allocation.is_separate: res_add( _(u'Reserve'), 'reserve', dict(id=allocation.id, start=start, end=end), 'overlay' ) items.default_url( 'reserve', dict(id=allocation.id, start=start, end=end) ) else: res_add( _(u'Reserve'), 'reserve-group', dict(group=allocation.group), 'overlay' ) items.default_url( 'reserve', dict(group=allocation.group) ) res_add( _(u'Manage'), 'reservations', dict(group=allocation.group), 'inpage' ) # menu entries for single items entry_add = lambda n, v, p, t: \ items.menu_add(_('Entry'), n, v, p, t) entry_add( _(u'Edit'), 'edit-allocation', dict(id=allocation.id), 'overlay' ) entry_add( _(u'Remove'), 'remove-allocation', dict(id=allocation.id), 'overlay' ) if allocation.in_group: # menu entries for group items group_add = lambda n, v, p, t: \ items.menu_add(_('Recurrences'), n, v, p, t) group_add( _(u'List'), 'group', dict(name=allocation.group), 'overlay' ) group_add( _(u'Remove'), 'remove-allocation', dict(group=allocation.group), 'overlay' ) # view selections if 'agendaDay' in self.context.available_views: items.menu_add( _(u'Reservations'), _(u'Daily View'), 'view', dict( selected_view='agendaDay', specific_date=allocation.start.strftime('%Y-%m-%d') ), 'window' ) return items