예제 #1
0
def _site(user, app, context):
    info = ''
    if context.method=='post':
        title = context.get_argument('title')
        subtitle = context.get_argument('subtitle')
        date_format = context.get_argument('date_format')
        time_format = context.get_argument('time_format')
        tz = context.get_argument('time_zone')
        ss = tz.split(',', 3)
        siteconfig.set_site_settings(
                title=title,
                subtitle=subtitle,
                date_format=date_format,
                time_format=time_format,
                tz_h_offset=int(ss[0]),
                tz_m_offset=int(ss[1]),
                tz_dst=int(ss[2]),
                tz_name=ss[3]
        )
        info = 'Site configuration saved.'
    site = siteconfig.get_site_settings(False)
    tz = site.get_tzinfo()
    now = runtime.convert_datetime(datetime.datetime.now(), tz)
    return {
            '__view__' : 'manage_site',
            'info' : info,
            'site' : site,
            'date_formats' : siteconfig.date_format_samples(now),
            'time_formats' : siteconfig.time_format_samples(now),
            'timezones' : runtime.get_timezone_list(),
    }
예제 #2
0
 def test_date_format_samples(self):
     dt = datetime(2008, 2, 21)
     self.assertEquals([
         ('%Y-%m-%d', '2008-02-21'),
         ('%y-%m-%d', '08-02-21'),
         ('%d/%m/%Y', '21/02/2008'),
         ('%d/%m/%y', '21/02/08'),
         ('%m/%d/%Y', '02/21/2008'),
         ('%m/%d/%y', '02/21/08'),
         ('%b %d, %Y', 'Feb 21, 2008'),
         ('%b %d, %y', 'Feb 21, 08'),
         ('%B %d, %Y', 'February 21, 2008'),
         ('%B %d, %y', 'February 21, 08'),
     ], siteconfig.date_format_samples(dt))
예제 #3
0
 def test_date_format_samples(self):
     dt = datetime(2008, 2, 21)
     self.assertEquals(
         [
             ("%Y-%m-%d", "2008-02-21"),
             ("%y-%m-%d", "08-02-21"),
             ("%d/%m/%Y", "21/02/2008"),
             ("%d/%m/%y", "21/02/08"),
             ("%m/%d/%Y", "02/21/2008"),
             ("%m/%d/%y", "02/21/08"),
             ("%b %d, %Y", "Feb 21, 2008"),
             ("%b %d, %y", "Feb 21, 08"),
             ("%B %d, %Y", "February 21, 2008"),
             ("%B %d, %y", "February 21, 08"),
         ],
         siteconfig.date_format_samples(dt),
     )