Esempio n. 1
0
    def __init__(self, request):
        super(BetsViewer, self).__init__(request)
        #self.layout.main_menu = make_main_menu(self.request).render()
        #self.layout.ctx_menu = make_ctx_menu(self.request).output()
        make_context_menu(self.request)
        
        self.accounts = AccountingManager(self.request.db)
        
        self.teams = NFLTeamManager(self.request.db)
        self.games = NFLGameManager(self.request.db)
        self.odds = NFLOddsManager(self.request.db)
        self.bets = BetsManager(self.request.db)
        
        settings = self.get_app_settings()
        url = settings['vignewton.nfl.odds.url']
        self.odds.oddscache.set_url(url)
        
        self.context = self.request.matchdict['context']
        # make dispatch table
        self._cntxt_meth = dict(
            main=self.main_view,
            allpending=self.view_all_pending_bets,
            allclosed=self.view_all_closed_bets,
            )

        if self.context in self._cntxt_meth:
            self._cntxt_meth[self.context]()
        else:
            msg = 'Undefined Context: %s' % self.context
            self.layout.content = '<b>%s</b>' % msg
Esempio n. 2
0
 def __init__(self, session):
     self.session = session
     self.games = NFLGameManager(self.session)
     self.teams = NFLTeamManager(self.session)
     self.odds = NFLOddsManager(self.session)
     self.accounts = AccountingManager(self.session)
     # FIXME: put this in config or database
     self.max_bet = 500
Esempio n. 3
0
 def __init__(self, request):
     super(UserManagementViewer, self).__init__(request)
     prepare_main_data(self.request)
     self.users = UserManager(self.request.db)
     self.accounts = AccountingManager(self.request.db)
     self._dispatch_table = dict(
         list=self.list_users,
         add=self.add_user,
         delete=self.delete_user,
         confirmdelete=self.confirm_delete_user,
         view=self.view_user,
         listgroups=self.list_groups,
         viewgroup=self.view_group,
     )
     self.context = self.request.matchdict['context']
     self._view = self.context
     self.dispatch()
Esempio n. 4
0
def setup(env):
    request = env['request']
    db = request.db
    env['db'] = db
    settings = env['registry'].settings

    url = settings['vignewton.nfl.schedule.url']
    env['url'] = url
    odds_url = settings['vignewton.nfl.odds.url']
    from vignewton.managers.nflgames import NFLTeamManager
    tm = NFLTeamManager(db)
    env['tm'] = tm
    from vignewton.managers.odds import NFLOddsManager
    om = NFLOddsManager(db)
    env['om'] = om
    om.oddscache.set_url(odds_url)
    if not om.get_current_odds():
        filename = 'testdata/o.pickle'
        if not os.path.isfile(filename):
            om.update_current_odds()
        else:
            om.populate_from_pickle(filename)
    from vignewton.managers.nflgames import NFLGameManager
    gm = NFLGameManager(db)
    env['gm'] = gm
    gm.set_schedule_url(url)
    update_game_schedule = False
    if update_game_schedule:
        update_games(gm)
    env['ug'] = update_games
    from vignewton.managers.accounting import AccountingManager
    am = AccountingManager(db)
    am.initialize_bets_manager()
    env['am'] = am
    #env['games'] = om.oddscache.get_latest()[0].content
    #env['bg'] = env['games'][-3]
    from vignewton.managers.util import determine_max_bet
    env['dmb'] = determine_max_bet
    env['game'] = gm.query().get(125)
    backup_cache(gm, om)
    from vignewton.managers.bets import BetsManager
    bm = BetsManager(db)
    env['bm'] = bm
    from vignewton.managers.util import chop_ical_nflgame_desc
    env['cind'] = chop_ical_nflgame_desc
    env['g'] = gm.get(131)
Esempio n. 5
0
def populate_accounting_tables(session):
    db = session
    try:
        with transaction.manager:
            for ttype in TRANSACTION_TYPES:
                x = TransactionType()
                x.name = ttype
                db.add(x)
    except IntegrityError:
        transaction.abort()
            
    try:
        from vignewton.managers.accounting import AccountingManager
        am = AccountingManager(db)
        for acct in ['Cash', 'Wagers', 'JuiceInsurance', 'InTheWild']:
            am.add_account('%s_Account' % acct)
    except IntegrityError:
        transaction.abort()