From e24f76617ad0edbe6839179a5751a9e7d4a0b217 Mon Sep 17 00:00:00 2001 From: Brian Ryall Date: Tue, 1 Jun 2021 22:54:02 -0400 Subject: [PATCH 1/2] add checks for lastest fava which changed querytable api --- fava_envelope/__init__.py | 15 +++++++++++++++ fava_envelope/templates/EnvelopeBudget.html | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/fava_envelope/__init__.py b/fava_envelope/__init__.py index 9492874..b5df683 100644 --- a/fava_envelope/__init__.py +++ b/fava_envelope/__init__.py @@ -2,6 +2,7 @@ """ from fava.ext import FavaExtensionBase +from fava import __version__ as fava_version from beancount.core.number import Decimal, D from .modules.beancount_envelope import BeancountEnvelope @@ -93,3 +94,17 @@ def generate_envelope_query_tables(self, month): envelope_table_rows.append(row) return (envelope_table_types, envelope_table_rows) + + def use_new_querytable(self): + """ + from redstreet/fava_investor + fava added the ledger as a first required argument to + querytable.querytable after version 1.18, so in order to support both, + we have to detect the version and adjust how we call it from inside our + template + """ + split_version = fava_version.split('.') + if len(split_version) != 2: + split_version = split_version[:2] + major, minor = split_version + return int(major) > 1 or (int(major) == 1 and int(minor) > 18) diff --git a/fava_envelope/templates/EnvelopeBudget.html b/fava_envelope/templates/EnvelopeBudget.html index c06a2c1..301469e 100644 --- a/fava_envelope/templates/EnvelopeBudget.html +++ b/fava_envelope/templates/EnvelopeBudget.html @@ -1,3 +1,4 @@ +{% set new_querytable = extension.use_new_querytable() %} {% import "_query_table.html" as querytable with context %} {% set currency = request.args.get('currency') %} {% if currency == None%} @@ -27,7 +28,15 @@

{% if not (module == m) %}