mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-04-23 17:18:44 +02:00
47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
from import_export import fields, resources, widgets
|
|
|
|
from apps.currencies.models import Currency, ExchangeRate, ExchangeRateService
|
|
|
|
|
|
class CurrencyResource(resources.ModelResource):
|
|
exchange_currency = fields.Field(
|
|
attribute="exchange_currency",
|
|
column_name="exchange_currency",
|
|
widget=widgets.ForeignKeyWidget("currencies.Currency", "name"),
|
|
)
|
|
|
|
class Meta:
|
|
model = Currency
|
|
|
|
|
|
class ExchangeRateResource(resources.ModelResource):
|
|
from_currency = fields.Field(
|
|
attribute="from_currency",
|
|
column_name="from_currency",
|
|
widget=widgets.ForeignKeyWidget("currencies.Currency", "name"),
|
|
)
|
|
to_currency = fields.Field(
|
|
attribute="to_currency",
|
|
column_name="to_currency",
|
|
widget=widgets.ForeignKeyWidget("currencies.Currency", "name"),
|
|
)
|
|
|
|
class Meta:
|
|
model = ExchangeRate
|
|
|
|
|
|
class ExchangeRateServiceResource(resources.ModelResource):
|
|
target_currencies = fields.Field(
|
|
attribute="target_currencies",
|
|
column_name="target_currencies",
|
|
widget=widgets.ManyToManyWidget("currencies.Currency", field="name"),
|
|
)
|
|
target_accounts = fields.Field(
|
|
attribute="target_accounts",
|
|
column_name="target_accounts",
|
|
widget=widgets.ForeignKeyWidget("accounts.Account", field="name"),
|
|
)
|
|
|
|
class Meta:
|
|
model = ExchangeRateService
|