|
|
|
@ -2,16 +2,16 @@
@@ -2,16 +2,16 @@
|
|
|
|
|
|
|
|
|
|
from tempfile import NamedTemporaryFile |
|
|
|
|
|
|
|
|
|
from pyramid.view import view_config |
|
|
|
|
from pyramid.httpexceptions import HTTPFound |
|
|
|
|
from pyramid_mailer.message import Message, Attachment |
|
|
|
|
from pyramid.view import view_config |
|
|
|
|
from pyramid_mailer.message import Attachment, Message |
|
|
|
|
|
|
|
|
|
from . import XLSX_CONTENT_TYPE, Root |
|
|
|
|
from ..budget import parse_budget_file |
|
|
|
|
from ..exceptions import BudgetParserError, SuperXParserError |
|
|
|
|
from ..helpers import find_budget_file, find_recipients, get_sheet_of_file |
|
|
|
|
from ..overview import create_overview |
|
|
|
|
from ..superx import parse_exported_file |
|
|
|
|
from ..helpers import find_recipients, find_budget_file, get_sheet_of_file |
|
|
|
|
from ..overview import create_overview # noqa: F401 |
|
|
|
|
from ..exceptions import BudgetParserError, SuperXParserError # noqa: F401 |
|
|
|
|
from . import XLSX_CONTENT_TYPE, Root |
|
|
|
|
|
|
|
|
|
MAIL_MESSAGE_BODY = """Hallo an Alle, |
|
|
|
|
|
|
|
|
@ -35,10 +35,10 @@ def _map_from_form_data(request, prefix):
@@ -35,10 +35,10 @@ def _map_from_form_data(request, prefix):
|
|
|
|
|
row_str = key.split("-")[-1] |
|
|
|
|
row = int(row_str) |
|
|
|
|
try: |
|
|
|
|
value = float(value) |
|
|
|
|
as_number = float(value) |
|
|
|
|
except ValueError: |
|
|
|
|
value = 0 |
|
|
|
|
result[row] = value |
|
|
|
|
as_number = 0 |
|
|
|
|
result[row] = as_number |
|
|
|
|
return result |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -48,7 +48,7 @@ def _map_from_form_data(request, prefix):
@@ -48,7 +48,7 @@ def _map_from_form_data(request, prefix):
|
|
|
|
|
renderer="superx_budget:pyramid/templates/start.jinja2", |
|
|
|
|
permission="view", |
|
|
|
|
) |
|
|
|
|
def index(context, request): |
|
|
|
|
def index(context, request): # noqa: ARG001 |
|
|
|
|
return {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -58,7 +58,7 @@ def index(context, request):
@@ -58,7 +58,7 @@ def index(context, request):
|
|
|
|
|
renderer="superx_budget:pyramid/templates/overview.jinja2", |
|
|
|
|
permission="view", |
|
|
|
|
) |
|
|
|
|
def superx_upload(context, request): |
|
|
|
|
def superx_upload(context, request): # noqa: ARG001 |
|
|
|
|
upload = request.POST.get("superx") |
|
|
|
|
|
|
|
|
|
if upload == b"" or not upload.filename.endswith(".xlsx"): |
|
|
|
@ -122,7 +122,7 @@ def superx_upload(context, request):
@@ -122,7 +122,7 @@ def superx_upload(context, request):
|
|
|
|
|
renderer="superx_budget:pyramid/templates/sent.jinja2", |
|
|
|
|
permission="view", |
|
|
|
|
) |
|
|
|
|
def send_overview(context, request): |
|
|
|
|
def send_overview(context, request): # noqa: ARG001 |
|
|
|
|
export_date = request.POST.get("export_date").strip() |
|
|
|
|
tmp_recipients = request.POST.get("recipients").strip() |
|
|
|
|
recipients = tmp_recipients.splitlines() |
|
|
|
@ -165,7 +165,7 @@ def send_overview(context, request):
@@ -165,7 +165,7 @@ def send_overview(context, request):
|
|
|
|
|
|
|
|
|
|
xls_name = f"{export_date}-Budget-Overview-{budget_year}.xlsx" |
|
|
|
|
with NamedTemporaryFile() as tmp: |
|
|
|
|
sheet._parent.save(tmp.name) |
|
|
|
|
sheet._parent.save(tmp.name) # noqa: SLF001 |
|
|
|
|
tmp.seek(0) |
|
|
|
|
attachment = Attachment(xls_name, XLSX_CONTENT_TYPE, tmp) |
|
|
|
|
message.attach(attachment) |
|
|
|
|