-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add export feature #176
Add export feature #176
Conversation
@@ -54,7 +54,7 @@ def balance(self): | |||
def uses_weights(self): | |||
return len([i for i in self.members if i.weight != 1]) > 0 | |||
|
|||
def get_transactions_to_settle_bill(self): | |||
def get_transactions_to_settle_bill(self, pretty_output=False): | |||
"""Return a list of transactions that could be made to settle the bill""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to have a better readability, I would create a prettify
function (inside this method) which will do the conversion if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really great, thanks a lot for your work on this!
I approve the changes but I tend to prefer to have the export feature on the settings page in order to avoid adding a new menu.
If you prefer to have them separated on another page like you did, please can you elaborate on why it's better in your opinion? or, if you agree with this proposal, could you make the change?
Thanks 👍
budget/models.py
Outdated
"date": str(bill.date), | ||
"payer_name": Person.query.get(bill.payer_id).name, | ||
"payer_weight": Person.query.get(bill.payer_id).weight, | ||
"owers": [ower.name for ower in bill.owers] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having an intermediary variable here for the owers would improve readability.
budget/templates/forms.html
Outdated
{{ input(form.export_format) }} | ||
</fieldset> | ||
<div class="actions"> | ||
<button class="btn">{{ _("Export this project") }}</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the action, consider: "Download this project's data"
budget/templates/layout.html
Outdated
@@ -51,6 +51,7 @@ <h1 class="col-2"><a class="navbar-brand" href="{{ url_for(".home") }}">#! money | |||
<a href="#" class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><strong>{{ g.project.name }}</strong> {{ _("options") }} <b class="caret"></b></a> | |||
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> | |||
<li><a class="dropdown-item" href="{{ url_for(".edit_project") }}">{{ _("Project settings") }}</a></li> | |||
<li><a class="dropdown-item" href="{{ url_for(".export_project") }}">{{ _("Export project") }}</a></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure where this should be: what about having a section in the project's settings instead?
@@ -624,6 +624,116 @@ def test_settle_zero(self): | |||
self.assertNotEqual(0.0, rounded_amount, | |||
msg='%f is equal to zero after rounding' % t['amount']) | |||
|
|||
def test_export(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for taking the time to write tests for this!
Bills and transactions can now be exported to json or csv ref spiral-project#28
Ok I amended the commit to improve readability and made some rewording. I also moved the export form to project's settings, the choice of a separate page was purely arbitrary :) |
This looks good to me! |
Add export feature
This adds the possibility to export the bills and the transactions of a project as json or csv
The exported fields are the following:
transactions: amount, receiver, ower
bills: what, payer_name, payer_weight, owers, amount, date
The link to export the project is located in the options menu
Original feature request #28