Пример #1
0
        def testmatches(self, filter_id):
            u = accounts.user(cherrypy.request.login)
            f = accounts.importfilters(u)
            f.load_test_filter(u.id, filter_id)
            transactions = []
            for a in u.get_accounts():
                for t in a.get_transactions():
                    if f.testmatch(t):
                        transactions.append(t)

            return serve_template('/management/importfilters/testmatches.html', self, matches=transactions)
Пример #2
0
    def import2(self, accid, datafile):
        """ """
        user = accounts.user(cherrypy.request.login)
        data = datafile.file.read()
        filename = "{}_{}_{}.csv".format(accid, datetime.datetime.utcnow().strftime("%Y%m%d"), randint(10000, 99999))

        with open(os.path.join(config.HERE, 'static', 'imports', filename), 'w') as f:
            f.write(data)

        account = accounts.account(accid)
        account.import_transactions(filename)
        return self.view(accid)
Пример #3
0
def serve_template(templatename, caller, **kwargs):
    if isinstance(caller, htmlobjects.Page):
        page = caller
    else:
        try:
            page = caller.page
        except AttributeError:
            page = None

    try:
        path = urlparse.urlparse(cherrypy.url())[2].strip('/').split('/')
    except KeyError:
        path = ''

    GET = cherrypy.request.params
    u = user(cherrypy.request.login)
    return "\n".join([
        _header(page=page, user=u, GET=GET, path=path, **kwargs),
        _template(templatename, page=page, user=u, GET=GET, **kwargs),
        _footer(page=page, user=u, GET=GET, **kwargs)
    ])
Пример #4
0
 def add(self, account_name, account_number, sort_code, profile):
     u = accounts.user(cherrypy.request.login)
     accounts.account.add(u.id, account_name, account_number, sort_code, profile)
     return self.parent.index()
Пример #5
0
 def index(self, query):
     user = accounts.user(cherrypy.request.login)
     transactions = accounts.account.search_transactions(user, query)
     return serve_template('search/index.html', self, transactions=transactions, categories=accounts.transaction.get_categories())
Пример #6
0
 def index(self):
     user = accounts.user(cherrypy.request.login)
     return serve_template('index.html', self, accounts=user.get_accounts())
Пример #7
0
 def monthly_change(self):
     u = accounts.user(cherrypy.request.login)
     months, data = accounts.reports.monthly_change(u.id)
     return serve_template('/reports/monthly_change.html', self, months=months, data=data, categories=accounts.transaction.category_lookup())
Пример #8
0
 def category_totals(self):
     u = accounts.user(cherrypy.request.login)
     return serve_template('/reports/category_totals.html', self, totals=accounts.reports.category_totals(u.id))
Пример #9
0
 def add(self, field, position, pattern, category):
     u = accounts.user(cherrypy.request.login)
     accounts.importfilters.create(u.id, field, position, pattern, category)
     return self.index()
Пример #10
0
 def index(self):
     u = accounts.user(cherrypy.request.login)
     filters = accounts.importfilters.get_all(u.id)
     return serve_template('/management/importfilters/index.html', self, filters=filters)