def update(self): context = aq_inner(self.context) self.calendar_url = get_calendar_url(context, self.search_base_path) self.year, self.month, self.date = year, month, date = self._year_month_date_display_patch() self.prev_year, self.prev_month = prev_year, prev_month = ( self.get_previous_month(year, month)) self.next_year, self.next_month = next_year, next_month = ( self.get_next_month(year, month)) self.prev_query = '?month=%s&year=%s' % (prev_month, prev_year) self.next_query = '?month=%s&year=%s' % (next_month, next_year) self.cal = calendar.Calendar(first_weekday()) self._ts = getToolByName(context, 'translation_service') self.month_name = PLMF( self._ts.month_msgid(month), default=self._ts.month_english(month) ) # strftime %w interprets 0 as Sunday unlike the calendar. strftime_wkdays = [ wkday_to_mon1(day) for day in self.cal.iterweekdays() ] self.weekdays = [ PLMF(self._ts.day_msgid(day, format='s'), default=self._ts.weekday_english(day, format='a')) for day in strftime_wkdays ]
def update(self): context = aq_inner(self.context) sb = self.data.search_base site_url = find_site(context, as_url=True) self.calendar_url = '%s%s' % (site_url, sb and sb or '/event_listing') self.year, self.month = year, month = self.year_month_display() self.prev_year, self.prev_month = prev_year, prev_month = ( self.get_previous_month(year, month)) self.next_year, self.next_month = next_year, next_month = ( self.get_next_month(year, month)) # TODO: respect current url-query string self.prev_query = '?month=%s&year=%s' % (prev_month, prev_year) self.next_query = '?month=%s&year=%s' % (next_month, next_year) self.cal = calendar.Calendar(first_weekday()) self._ts = getToolByName(context, 'translation_service') self.month_name = PLMF(self._ts.month_msgid(month), default=self._ts.month_english(month)) # strftime %w interprets 0 as Sunday unlike the calendar. strftime_wkdays = [wkday_to_mon1(day) for day in self.cal.iterweekdays()] self.weekdays = [ PLMF(self._ts.day_msgid(day, format='s'), default=self._ts.weekday_english(day, format='a')) for day in strftime_wkdays ]
def update(self): context = aq_inner(self.context) self.calendar_url = get_calendar_url(context, self.search_base_path) self.year, self.month = year, month = self.year_month_display() self.prev_year, self.prev_month = prev_year, prev_month = ( self.get_previous_month(year, month)) self.next_year, self.next_month = next_year, next_month = ( self.get_next_month(year, month)) self.prev_query = '?month=%s&year=%s' % (prev_month, prev_year) self.next_query = '?month=%s&year=%s' % (next_month, next_year) self.cal = calendar.Calendar(first_weekday()) self._ts = getToolByName(context, 'translation_service') self.month_name = PLMF( self._ts.month_msgid(month), default=self._ts.month_english(month) ) # strftime %w interprets 0 as Sunday unlike the calendar. strftime_wkdays = [ wkday_to_mon1(day) for day in self.cal.iterweekdays() ] self.weekdays = [ PLMF(self._ts.day_msgid(day, format='s'), default=self._ts.weekday_english(day, format='a')) for day in strftime_wkdays ]
def update(self): context = aq_inner(self.context) sb = self.data.search_base site_url = find_site(context, as_url=True) self.calendar_url = '%s%s' % (site_url, sb and sb or '/event_listing') self.year, self.month = year, month = self.year_month_display() self.prev_year, self.prev_month = prev_year, prev_month = ( self.get_previous_month(year, month)) self.next_year, self.next_month = next_year, next_month = ( self.get_next_month(year, month)) # TODO: respect current url-query string self.prev_query = '?month=%s&year=%s' % (prev_month, prev_year) self.next_query = '?month=%s&year=%s' % (next_month, next_year) self.cal = calendar.Calendar(first_weekday()) self._ts = getToolByName(context, 'translation_service') self.month_name = PLMF(self._ts.month_msgid(month), default=self._ts.month_english(month)) # strftime %w interprets 0 as Sunday unlike the calendar. strftime_wkdays = [ wkday_to_mon1(day) for day in self.cal.iterweekdays() ] self.weekdays = [ PLMF(self._ts.day_msgid(day, format='s'), default=self._ts.weekday_english(day, format='a')) for day in strftime_wkdays ]
def DateFieldWidget(field, request): widget = FieldWidget(field, DateWidget(request)) widget.pattern_options.setdefault('date', {}) try: widget.pattern_options['date']['firstDay'] = first_weekday() except ComponentLookupError: pass return widget
def EuphorieDateFieldWidget(field, request): """This is identicall to the equivalent in plone.app.z3cform but needs a customization to use the EuphorieDateWidget class """ widget = FieldWidget(field, EuphorieDateWidget(request)) widget.pattern_options.setdefault("date", {}) try: widget.pattern_options["date"]["firstDay"] = first_weekday() except ComponentLookupError: pass return widget
def first_weekday(): if HAS_PAE: wkday = pae_base.wkday_to_mon1(pae_base.first_weekday()) if wkday > 1: return 1 # Default to Monday return wkday else: cal = getToolByName(getSite(), 'portal_calendar', None) if cal: wkday = cal.firstweekday if wkday == 6: # portal_calendar's Sunday is 6 return 0 # Sunday return 1 # other cases: Monday
def update(self): context = aq_inner(self.context) if IHomePage.providedBy(self.context) or \ IPloneSiteRoot.providedBy(self.context) or \ not IDexterityContent.providedBy(self.context): path = '' else: if ICommunity.providedBy(aq_inner(self.context)): community = aq_inner(self.context) portal = api.portal.get() portal_path = portal.getPhysicalPath() community_path = community.getPhysicalPath() path = '/' + '/'.join(set(community_path) - set(portal_path)) else: path = '' self.search_base = path self.state = ('published', 'intranet') self.username = api.user.get_current().id # self.user_info = get_safe_member_by_id(self.username) self.calendar_url = get_calendar_url(context, self.search_base) self.year, self.month = year, month = self.year_month_display() self.prev_year, self.prev_month = prev_year, prev_month = ( self.get_previous_month(year, month)) self.next_year, self.next_month = next_year, next_month = ( self.get_next_month(year, month)) # TODO: respect current url-query string self.prev_query = '?month=%s&year=%s' % (prev_month, prev_year) self.next_query = '?month=%s&year=%s' % (next_month, next_year) self.cal = calmodule.Calendar(first_weekday()) self._ts = getToolByName(context, 'translation_service') self.month_name = PLMF( self._ts.month_msgid(month), default=self._ts.month_english(month) ) # strftime %w interprets 0 as Sunday unlike the calendar. strftime_wkdays = [ wkday_to_mon1(day) for day in self.cal.iterweekdays() ] self.weekdays = [ PLMF(self._ts.day_msgid(day, format='s'), default=self._ts.weekday_english(day, format='a')) for day in strftime_wkdays ]
def cal(self): """ Calendar iterator over weeks and days of the month to display. """ context = aq_inner(self.context) today = localized_today(context) year, month = self.year_month_display() cal = calendar.Calendar(first_weekday()) monthdates = [dat for dat in cal.itermonthdates(year, month)] events = get_events_by_date(context, monthdates[0], monthdates[-1]) # [[day1week1, day2week1, ... day7week1], [day1week2, ...]] cal = [[]] for dat in monthdates: if len(cal[-1]) == 7: cal.append([]) date_events = None isodat = dat.isoformat() if isodat in events: date_events = events[isodat] events_string = u"" if date_events: for event in date_events: events_string += u'%s<a href="%s">%s</a>%s' % ( events_string and u"</br>" or u"", event.getURL(), event.Title, event.location and u" %s" % event.location or u"", ) cal[-1].append( { "date": dat, "day": dat.day, "prev_month": dat.month < month, "next_month": dat.month > month, "today": dat.year == today.year and dat.month == today.month and dat.day == today.day, "date_string": u"%s-%s-%s" % (dat.year, dat.month, dat.day), "events_string": events_string, "events": date_events, } ) return cal
def update(self): context = aq_inner(self.context) self.calendar_linkbase = ICalendarLinkbase(context) self.year, self.month = year, month = self.year_month_display() self.prev_year, self.prev_month = prev_year, prev_month = ( self.get_previous_month(year, month)) self.next_year, self.next_month = next_year, next_month = ( self.get_next_month(year, month)) # TODO: respect current url-query string self.prev_query = '?month=%s&year=%s' % (prev_month, prev_year) self.next_query = '?month=%s&year=%s' % (next_month, next_year) self.cal = calendar.Calendar(first_weekday()) self._ts = getToolByName(context, 'translation_service') self.month_name = PLMF(self._ts.month_msgid(month), default=self._ts.month_english(month)) self.weekdays = [PLMF(self._ts.day_msgid(day, format='s'), default=self._ts.weekday_english(day, format='a')) for day in self.cal.iterweekdays()]
def first_weekday_sun0(): return wkday_to_mon1(first_weekday())
def weekdays(self): cal = calendar.Calendar(first_weekday()) return cal.iterweekdays()