コード例 #1
0
ファイル: poll_forms.py プロジェクト: franck260/vpt
    def __init__(self):

        # Grid initialization
        super(EditPollsGrid, self).__init__(
            Poll, Poll.all(joined_attrs=["choices"]))  #@UndefinedVariable

        # Creation of customized date fields to edit the poll dates
        self.append(
            create_date_field("formatted_start_dt",
                              "start_dt",
                              DT_FORMAT,
                              today_by_default=True))
        self.append(
            create_date_field("formatted_end_dt",
                              "end_dt",
                              DT_FORMAT,
                              today_by_default=False))
        self.append(
            Field(name="formatted_possible_dates",
                  value=lambda model: "[%s]" % ",".join([
                      formatting.format_date(dt, DT_FORMAT)
                      for dt in model.possible_dates
                  ])))

        # Grid configuration
        inc = [
            TITLE(self.title),
            FORMATTED_START_DT(self.formatted_start_dt),
            FORMATTED_END_DT(self.formatted_end_dt),
            FORMATTED_POSSIBLE_DATES_READONLY(self.formatted_possible_dates)
        ]
        self.configure(include=inc)
コード例 #2
0
    def __init__(self, mapping, fvars):

        # Parent constructor
        web.application.__init__(self, mapping, fvars) #@UndefinedVariable

        # The views are bound once for all to the configuration
        config.views = web.template.render("app/views/", globals={
            "all_seasons": lambda: Season.all(),
            "all_polls": lambda: Poll.all(),
            "webparts": webparts,
            "formatting": formatting,
            "dates": dates,
            "zip": zip,
            "getattr": getattr,
            "hasattr": hasattr,
            "class_name": lambda x: x.__class__.__name__,
            "namedtuple": collections.namedtuple,
            "config": config,
            "result_statuses": Result.STATUSES,
            "Events": Events
        })

        # The ORM is bound once since it dynamically loads the engine from the configuration
        config.orm = meta.init_orm(lambda : config.engine)

        # Binds the hooking mechanism & the SQL Alchemy processor
        self.add_processor(web.loadhook(http.init_hooks))
        self.add_processor(web.unloadhook(http.execute_hooks))        
        self.add_processor(http.sqlalchemy_processor)

        # Binds the webparts initialization mechanism
        self.add_processor(web.loadhook(webparts.init_webparts))
コード例 #3
0
ファイル: test_polls.py プロジェクト: franck260/vpt
 def test_all(self):
     
     all_polls = Poll.all()
     self.assertEqual(len(all_polls), 3)
     
     # Checks the order by clause
     self.assertEqual(all_polls[0].start_dt, datetime.date(2011, 5, 28))
     self.assertEqual(all_polls[1].start_dt, datetime.date(2012, 4, 5))
     self.assertEqual(all_polls[2].start_dt, datetime.date(2020, 10, 1))
コード例 #4
0
ファイル: main.py プロジェクト: franck260/vpt
 def GET(self):
     
     open_polls = filter(lambda poll: not poll.expired, Poll.all())
     
     return config.views.layout(
         config.views.index(
             pending_tournaments(),
             open_polls,
             News.all()
         )
     )
コード例 #5
0
ファイル: poll_forms.py プロジェクト: franck260/vpt
    def __init__(self):
        
        # Grid initialization
        super(EditPollsGrid, self).__init__(Poll, Poll.all(joined_attrs=["choices"])) #@UndefinedVariable

        # Creation of customized date fields to edit the poll dates
        self.append(create_date_field("formatted_start_dt", "start_dt", DT_FORMAT, today_by_default=True))
        self.append(create_date_field("formatted_end_dt", "end_dt", DT_FORMAT, today_by_default=False))
        self.append(
            Field(
                name="formatted_possible_dates",
                value=lambda model: "[%s]" % ",".join([formatting.format_date(dt, DT_FORMAT) for dt in model.possible_dates])
            )
        )
        
        # Grid configuration
        inc = [
            TITLE(self.title),
            FORMATTED_START_DT(self.formatted_start_dt),
            FORMATTED_END_DT(self.formatted_end_dt),
            FORMATTED_POSSIBLE_DATES_READONLY(self.formatted_possible_dates)
        ]
        self.configure(include=inc)
コード例 #6
0
ファイル: main.py プロジェクト: franck260/vpt
    def GET(self):

        open_polls = filter(lambda poll: not poll.expired, Poll.all())

        return config.views.layout(
            config.views.index(pending_tournaments(), open_polls, News.all()))