Skip to content

Commit

Permalink
Disable adding new transactions by default
Browse files Browse the repository at this point in the history
Setup for this feature is a little more complicated, and it tends to
throw strange errors.
  • Loading branch information
nylen committed Oct 24, 2014
1 parent b632025 commit 81d93b5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion money_templates/templates/page_account_details.html
Expand Up @@ -144,7 +144,7 @@
</table>
</div>
{% include "txactions_page_block.html" %}
{% if accounts|length == 1 %}
{% if can_add_transactions %}
<div class="block">
<p>
<strong>Add new transaction</strong>
Expand Down
10 changes: 9 additions & 1 deletion money_views/views.py
Expand Up @@ -89,7 +89,14 @@ def account(request, key):
modify_form_data['save_rule'] = True
modify_form = forms.ModifyForm(choices, modify_form_data, auto_id="modify_id_%s")

if len(accounts) == 1:
try:
can_add_transactions = settings.ENABLE_ADD_TRANSACTIONS
except AttributeError:
can_add_transactions = False

can_add_transactions = (can_add_transactions and len(accounts) == 1)

if can_add_transactions:
new_transaction_form = forms.NewTransactionForm(choices)
else:
new_transaction_form = None
Expand Down Expand Up @@ -121,6 +128,7 @@ def account(request, key):
'api_functions_js': json.dumps(api.function_urls.urls_dict),
'accounts': accounts,
'current_accounts_key': accounts_key(accounts),
'can_add_transactions': can_add_transactions,
'account': accounts[0],
'page': page,
'filter_form': filter_form,
Expand Down
7 changes: 7 additions & 0 deletions settings.example.py
Expand Up @@ -163,6 +163,13 @@
NUM_MERCHANTS_BATCH_CATEGORIZE = 50
NUM_TRANSACTIONS_PER_PAGE = 50

# This feature requires a little more setup. Namely, the GnuCash API must be
# properly set up (which generally requires building GnuCash from source) and
# it must be made available to the application's virtualenv. Also, the user
# running the application must have write access to the gnucash_api_home/
# directory.
ENABLE_ADD_TRANSACTIONS = False


if SHOW_DEBUG_TOOLBAR:
MIDDLEWARE_CLASSES += (
Expand Down

0 comments on commit 81d93b5

Please sign in to comment.