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

Add support for Euros #583

Open
wants to merge 55 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
c304f92
Add Euros to currency options
duncte123 Jul 26, 2023
48bd336
Support euros in the front-end
duncte123 Jul 26, 2023
1f367ba
Store the currency in the store
duncte123 Jul 27, 2023
83bc8c3
Set default currency in reducer to make the tests happy
duncte123 Jul 27, 2023
8c43244
Clarify comment
duncte123 Jul 27, 2023
f3fded7
Display donation currency on reading and processing pages
duncte123 Jul 28, 2023
25a86d6
Extract currency from donation for processing bundle
duncte123 Jul 30, 2023
52e0bda
Fix the prize grid and prize page not showing the proper currency
duncte123 Aug 14, 2023
a418860
Overlooked tests
duncte123 Aug 14, 2023
b6aeb61
Merge branch 'master' into feat/euros
duncte123 Aug 14, 2023
a530978
Merge migrations
duncte123 Aug 14, 2023
e731d71
Merge branch 'master' into feat/euros
duncte123 Aug 24, 2023
6be0c20
Merge branch 'master' into feat/euros
duncte123 Sep 9, 2023
6180d2b
Merge branch 'master' into feat/euros
duncte123 Nov 15, 2023
cb749ce
Merge branch 'master' into feat/euros
duncte123 Nov 22, 2023
d7a4ab2
Merge master
duncte123 Dec 31, 2023
940ef6c
Merge branch 'master' into feat/euros
duncte123 Jan 1, 2024
68ae6a7
Merge branch 'master' into feat/euros
duncte123 Jan 23, 2024
d893643
add `start` field to Milestone model (#647)
uraniumanchor Feb 13, 2024
60de322
add video links (#648)
uraniumanchor Feb 14, 2024
51473b8
always sort donations on read page (#649)
uraniumanchor Feb 14, 2024
ce9b690
[apiv2] Add more fields to runs to match v1 details (#651)
faultyserver Feb 17, 2024
9e2bda0
fix Milestone start validation (#654)
uraniumanchor Feb 21, 2024
44c46fa
Bump selenium from 4.16.0 to 4.18.1 (#653)
dependabot[bot] Feb 21, 2024
227aadf
Update responses requirement from ~=0.24.1 to ~=0.25.0 (#650)
dependabot[bot] Feb 21, 2024
825a81e
Bump pre-commit from 3.5.0 to 3.6.2 (#652)
dependabot[bot] Feb 21, 2024
badf7c9
Merge branch 'master' into feat/euros
duncte123 Mar 11, 2024
b89ba9f
Lint
duncte123 Mar 12, 2024
decf09e
Merge remote-tracking branch 'upstream/master' into feat/euros
duncte123 Apr 13, 2024
71ee57f
Merge migrations
duncte123 Apr 13, 2024
590411c
Set min frac digits to 0 when max is also 0
duncte123 Apr 14, 2024
5c0927e
Merge upstream
duncte123 Jul 29, 2024
ff37f34
Merge remote-tracking branch 'upstream/master' into feat/euros
duncte123 Aug 29, 2024
34e8489
Update from master
duncte123 Aug 29, 2024
1aaed51
Merge remote-tracking branch 'upstream/master' into feat/euros
duncte123 Oct 12, 2024
468cc1b
Merge database migrations
duncte123 Oct 14, 2024
4a0aadd
Merge branch 'master' into feat/euros
duncte123 Oct 24, 2024
587e655
update react-router to 6.4 (#730)
uraniumanchor Nov 1, 2024
61a6d59
ads API v2 (#731)
uraniumanchor Nov 1, 2024
a5aa715
create/edit Interview on v2 (#734)
uraniumanchor Nov 1, 2024
61f2eac
Bump selenium from 4.25.0 to 4.26.1 (#733)
dependabot[bot] Nov 1, 2024
7021450
clean up Milestone V2 API (#735)
uraniumanchor Nov 1, 2024
f29e3de
update API V2 validation (#736)
uraniumanchor Nov 6, 2024
51c2501
permissions tweaks to Bids (#737)
uraniumanchor Nov 6, 2024
21098ff
add DonationBid to v2, under donations/bids (#738)
uraniumanchor Nov 12, 2024
d6e7dbb
add Country/Region to V2 (#739)
uraniumanchor Nov 12, 2024
1690e5c
Bump selenium from 4.26.1 to 4.27.1 (#743)
dependabot[bot] Nov 29, 2024
df5e594
Bump pre-commit from 3.8.0 to 4.0.1 (#727)
dependabot[bot] Dec 11, 2024
d4b6e67
update pre-commit config for 4.x (#745)
uraniumanchor Dec 12, 2024
cddb935
do not override filter_queryset on viewsets (#746)
uraniumanchor Dec 12, 2024
9bd37f2
Bump channels from 4.1.0 to 4.2.0 (#740)
dependabot[bot] Dec 12, 2024
2fe74d1
Update from main
duncte123 Dec 15, 2024
518b53c
Merge upstream/main
duncte123 Jan 19, 2025
f80a3ac
Make merge migration
duncte123 Jan 19, 2025
1e90071
Remove duped code
duncte123 Jan 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bundles/@types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ declare global {
interface Window {
AdminApp: any;
TrackerApp: any;
currency: string;
duncte123 marked this conversation as resolved.
Show resolved Hide resolved
}
}
13 changes: 12 additions & 1 deletion bundles/public/util/currency.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
export function asCurrency(amount: string | number) {
return `$${Number(amount).toFixed(2)}`;
const currency = getCurrencySymbol();

return `${currency}${Number(amount).toFixed(2)}`;
}

export function getCurrencySymbol(): string {
switch (window.currency.toUpperCase()) {
case 'EUR':
return '€';
default:
return '$';
}
}
duncte123 marked this conversation as resolved.
Show resolved Hide resolved

export function parseCurrency(amount?: string) {
Expand Down
4 changes: 3 additions & 1 deletion bundles/tracker/donation/components/Donate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const Donate = (props: DonateProps) => {
updateDonation,
]);
const updateComment = React.useCallback((comment: string) => updateDonation({ comment }), [updateDonation]);
const currencySymbol = CurrencyUtils.getCurrencySymbol();

return (
<Container>
Expand Down Expand Up @@ -169,7 +170,8 @@ const Donate = (props: DonateProps) => {
key={amountPreset}
look={Button.Looks.OUTLINED}
onClick={updateAmountPreset(amountPreset)}>
${amountPreset}
{currencySymbol}
{amountPreset}
duncte123 marked this conversation as resolved.
Show resolved Hide resolved
</Button>
))}
</div>
Expand Down
3 changes: 3 additions & 0 deletions bundles/tracker/donation/components/DonateInitializer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type DonateInitializerProps = {
};
initialIncentives: InitialIncentive[];
event: {
paypalcurrency: string;
receivername: string;
};
step: number;
Expand Down Expand Up @@ -115,6 +116,8 @@ const DonateInitializer = (props: DonateInitializerProps) => {
};
});

window.currency = event.paypalcurrency;

dispatch(
EventDetailsActions.loadEventDetails({
csrfToken,
duncte123 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
6 changes: 5 additions & 1 deletion bundles/uikit/CurrencyInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as React from 'react';
import classNames from 'classnames';
import ReactNumeric from 'react-numeric';

import * as CurrencyUtils from '@public/util/currency';

import InputWrapper, { InputWrapperPassthroughProps } from './InputWrapper';

import styles from './CurrencyInput.mod.css';
Expand All @@ -20,6 +22,8 @@ type CurrencyInputProps = InputWrapperPassthroughProps & {
// - entering thousandths or beyond
// - formatting according to user's locale
const CurrencyInput = (props: CurrencyInputProps) => {
const currencySymbol = CurrencyUtils.getCurrencySymbol();
duncte123 marked this conversation as resolved.
Show resolved Hide resolved

const {
size = InputWrapper.Sizes.NORMAL,
value,
Expand All @@ -28,7 +32,7 @@ const CurrencyInput = (props: CurrencyInputProps) => {
name,
label,
hint,
leader = '$',
leader = currencySymbol,
trailer,
marginless = false,
className,
Expand Down
23 changes: 23 additions & 0 deletions tracker/migrations/0031_add_euros_to_donation_and_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.20 on 2023-07-26 10:40

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('tracker', '0030_add_bid_chain'),
]

operations = [
migrations.AlterField(
model_name='donation',
name='currency',
field=models.CharField(choices=[('USD', 'US Dollars'), ('CAD', 'Canadian Dollars'), ('EUR', 'Euros')], max_length=8, verbose_name='Currency'),
),
migrations.AlterField(
model_name='event',
name='paypalcurrency',
field=models.CharField(choices=[('USD', 'US Dollars'), ('CAD', 'Canadian Dollars'), ('EUR', 'Euros')], default='USD', max_length=8, verbose_name='Currency'),
),
]
6 changes: 5 additions & 1 deletion tracker/models/donation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
'DonorCache',
]

_currencyChoices = (('USD', 'US Dollars'), ('CAD', 'Canadian Dollars'))
_currencyChoices = (
('USD', 'US Dollars'),
('CAD', 'Canadian Dollars'),
('EUR', 'Euros'),
)

DonorVisibilityChoices = (
('FULL', 'Fully Visible'),
Expand Down
6 changes: 5 additions & 1 deletion tracker/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
]

_timezoneChoices = [(x, x) for x in pytz.common_timezones]
_currencyChoices = (('USD', 'US Dollars'), ('CAD', 'Canadian Dollars'))
_currencyChoices = (
('USD', 'US Dollars'),
('CAD', 'Canadian Dollars'),
('EUR', 'Euros'),
)


logger = logging.getLogger(__name__)
Expand Down