Creating a budget overview from a SuperX export.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.6 KiB

2 months ago
"""Superx Budget GUI"""
from pathlib import Path
2 months ago
from pyramid.authorization import Allow, Authenticated, Everyone
from pyramid.config import Configurator
from pyramid.httpexceptions import HTTPFound
2 months ago
from pyramid.session import JSONSerializer, SignedCookieSessionFactory
from pyramid.view import notfound_view_config
from ..exceptions import BudgetParserError, SuperXParserError # noqa: F401
2 months ago
from ..overview import create_overview # noqa: F401
XLSX_CONTENT_TYPE = "application/octet-stream"
class Root:
2 months ago
__acl__ = [(Allow, Everyone, "login"), (Allow, Authenticated, "view")] # noqa: RUF012
def __init__(self, request):
pass
2 months ago
def main(global_config, **settings): # noqa: ARG001
"""This function returns a Pyramid WSGI application."""
with Configurator(settings=settings) as config:
session_factory = SignedCookieSessionFactory(
settings["session.secret"], serializer=JSONSerializer()
)
config.set_session_factory(session_factory)
config.set_root_factory(Root)
config.add_request_method(
2 months ago
lambda r: Path( # noqa: ARG005
settings["budgets.dir"]
),
"budgets_dir",
reify=True,
)
age = int(settings.get("static_views.cache_max_age", 0))
config.add_static_view("static", "static", cache_max_age=age)
config.include("pyramid_jinja2")
config.include(".security")
config.scan()
return config.make_wsgi_app()
@notfound_view_config()
2 months ago
def not_found(context, request): # noqa: ARG001
return HTTPFound("/")