Skip to content
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

Accept display options for MathesarMoney type #1205

Merged
merged 53 commits into from
May 5, 2022

Conversation

silentninja
Copy link
Contributor

@silentninja silentninja commented Mar 21, 2022

Fixes #1105 by adding display options support for MathesarMoney type.

Features List

  • The frontend should be able to set any of these display options.

  • mathesar.tests.api.test_column_api.test_column_create_display_options

  • The frontend should know what the choices are for any display option that supports a set of choices.

  • mathesar.tests.api.test_ui_types_api.test_type_list

  • mathesar.api.display_options.money_display_options_schema

  • The display options should be validated.

  • mathesar.tests.api.test_column_api.test_column_create_wrong_display_options

  • If any of the display options end up changing other display options, the backend should handle that.

    • mathesar.tests.api.test_column_api.test_column_update_mathesar_money_display_options
  • When we infer a column as a money type, we should set the display options for that column based on the currency symbols in the original CSV/other file.

  • mathesar.tests.display_options_inference.test_money.test_display_options_inference

Additional fix

  • Fix DRF error mixin to allow custom error exceptions inside Serializer validations

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the master branch of the repository
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no
    visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@silentninja silentninja changed the title Mathesar 1105 money display option Accept display options for MathesarMoney type Mar 21, 2022
@silentninja silentninja added the needs: unblocking Blocked by other work label Apr 29, 2022
@silentninja silentninja changed the base branch from master to number-display-options April 29, 2022 17:19
@silentninja silentninja changed the base branch from number-display-options to master April 29, 2022 17:25
@silentninja
Copy link
Contributor Author

Blocked by #1335

@silentninja silentninja removed the pr-status: revision A PR awaiting follow-up work from its author after review label Apr 29, 2022
@silentninja silentninja removed the needs: unblocking Blocked by other work label Apr 29, 2022
@silentninja silentninja marked this pull request as ready for review April 29, 2022 22:26
@seancolsen seancolsen self-assigned this Apr 30, 2022
Copy link
Contributor

@seancolsen seancolsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked at the diff at all here. (It's kind of baffling to me that so many changes would be required for what seems like a relatively limited addition to the API, so I haven't even bothered to try understanding what's going on under the hood.)

I did verify that the API is working as I need it to work though.

The following display options, seem to work well according to these recent and somewhat ad-hoc specs:

  • number_format
  • currency_symbol
  • currency_symbol_location

And that's all I need in order to continue working on #259, so I'd like to get this merged.

But I'll hold off on merging until we get a proper backend review.

@kgodey kgodey removed the request for review from dmos62 April 30, 2022 02:09
@kgodey kgodey assigned mathemancer and unassigned seancolsen and silentninja Apr 30, 2022
@kgodey kgodey added the pr-status: review A PR awaiting review label Apr 30, 2022
@kgodey
Copy link
Contributor

kgodey commented Apr 30, 2022

@seancolsen Most of the complexity here is because money has required display options that we need to set from the backend. If we infer a column in a CSV as MONEY, we need to also figure out what the currency is and set the display option accordingly. No other type has anything like that.

I've assigned @mathemancer to review this since it touches type casting logic.

@silentninja silentninja requested a review from mathemancer May 2, 2022 13:08
Copy link
Contributor

@mathemancer mathemancer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good. Let's get it merged!

@mathemancer
Copy link
Contributor

Ach, it has merge conflicts. @silentninja Go ahead and merge after resolving those.

@silentninja silentninja enabled auto-merge May 5, 2022 20:07
@silentninja silentninja merged commit 6fbace7 into master May 5, 2022
@silentninja silentninja deleted the mathesar-1105-money-display-option branch May 5, 2022 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-status: review A PR awaiting review
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Implement display options for the custom Money type
6 participants