def _init_date_and_time_properties(self): start_day = self._catalog_event.startDate.strftime("%a, %b %e") start_time = self._format_time_of_day(self._catalog_event.startDate) end_day = self._catalog_event.endDate.strftime("%a, %b %e") end_time = self._format_time_of_day(self._catalog_event.endDate) if start_day == end_day: self.first_line_day = start_day self.first_line_time = '%s - %s' % (start_time, end_time) self.second_line_day = '' self.second_line_time = '' else: if is_all_day_event(self._catalog_event): one_day = datetime.timedelta(days=1) ends_at = self._catalog_event.endDate - one_day end_day = ends_at.strftime("%a, %b %e") self.first_line_day = start_day self.first_line_time = 'all-day' if start_day != end_day: # Spans more days, so we need a second line (to-) date. self.second_line_day = end_day else: # All-day event for a single day, no second line. self.second_line_day = '' self.second_line_time = '' else: self.first_line_day = start_day self.first_line_time = '%s - ' % start_time self.second_line_day = end_day self.second_line_time = end_time
def form_defaults(self): context = self.context if self.workflow is None: security_state = '' else: security_state = self.workflow.state_of(context) attendees = getattr(context, 'attendees', []) defaults = dict( title=context.title, text=context.text, start_date=context.startDate, end_date=context.endDate, location=context.location, attendees=u'\n'.join([i for i in attendees if i]), contact_name=context.contact_name, contact_email=context.contact_email, category=context.calendar_category, security_state = security_state, ) if defaults['contact_email'] is None: defaults['contact_email'] = u'' if is_all_day_event(context): defaults['all_day'] = True defaults['end_date'] -= datetime.timedelta(days=1) else: defaults['all_day'] = False return defaults
def _init_date_and_time_properties(self): start_day = self._catalog_event.startDate.strftime("%m/%d/%Y") start_time = self._format_time_of_day(self._catalog_event.startDate) end_day = self._catalog_event.endDate.strftime("%m/%d/%Y") end_time = self._format_time_of_day(self._catalog_event.endDate) followup = getattr(self._catalog_event, '_followup', False) if start_day == end_day and not followup: # genuine 1-day event. self.first_line_day = start_day self.first_line_time = '%s - %s' % (start_time, end_time) else: if is_all_day_event(self._catalog_event) or start_day != end_day and followup: # All-day event for a single day or more days, # or, the middle days of a non-all-day, but multi-day event. self.first_line_day = start_day self.first_line_time = 'all-day' elif start_day == end_day and followup: # The last day of a non-all-day, but multi-day event. self.first_line_day = start_day self.first_line_time = '- %s' % end_time else: # The first day of a non-all-day, but multi-day event. self.first_line_day = start_day self.first_line_time = '%s - ' % start_time # There is never a second line to be displayed. # As ,the idea is that now # we have the event listed once for each day. self.second_line_day = '' self.second_line_time = '' # Do not display the start day, if we already # had a previous event that showed this info. event = self._catalog_event if event.prev_start_date.date() == event.startDate.date(): self.first_line_day = ''
title=context.title, text=context.text, startDate=context.startDate, endDate=context.endDate, location=context.location, attendees=context.attendees, contact_name=context.contact_name, contact_email=context.contact_email, calendar_category=context.calendar_category, security_state = security_state, ) if fill_values['contact_email'] is None: fill_values['contact_email'] = u'' if is_all_day_event(context): fill_values['allDay'] = True fill_values['endDate'] -= datetime.timedelta(days=1) else: fill_values['allDay'] = False # Render the form and shove some default values in page_title = 'Edit ' + context.title api = TemplateAPI(context, request, page_title) client_json_data = convert_to_script(dict( tags_field = get_tags_client_data(context, request), )) # Get a layout layout_provider = get_layout_provider(context, request)