-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
72 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
Django==2.2 | ||
cachetools==3.1.1 | ||
celery==4.3.0 | ||
django-authtools==1.6.0 | ||
django-celery-beat==1.4.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,43 @@ | ||
from django.contrib import admin | ||
|
||
from .models import PriceOracle, PriceOracleTicker, Token | ||
from .exchanges import CannotGetTokenPriceFromApi | ||
|
||
|
||
@admin.register(PriceOracle) | ||
class PriceOracleAdmin(admin.ModelAdmin): | ||
list_display = ('name', ) | ||
ordering = ('name',) | ||
|
||
|
||
@admin.register(PriceOracleTicker) | ||
class PriceOracleTicker(admin.ModelAdmin): | ||
list_display = ('price_oracle_name', 'token_symbol', 'ticker', 'inverse') | ||
list_display = ('token_symbol', 'price_oracle_name', 'ticker', 'inverse', 'price') | ||
list_filter = (('token', admin.RelatedOnlyFieldListFilter), 'inverse') | ||
list_select_related = ('price_oracle', 'token') | ||
search_fields = ['token__symbol', '=token__address', 'price_oracle__name'] | ||
|
||
def price_oracle_name(self, obj): | ||
return obj.price_oracle.name | ||
|
||
def token_symbol(self, obj): | ||
return obj.token.symbol | ||
|
||
def get_queryset(self, request): | ||
return super().get_queryset(request).select_related('price_oracle', 'token') | ||
|
||
|
||
@admin.register(Token) | ||
class TokenAdmin(admin.ModelAdmin): | ||
list_display = ('address', 'name', 'symbol', 'decimals', 'fixed_eth_conversion', 'relevance', 'gas') | ||
list_display = ('relevance', 'address', 'name', 'symbol', 'decimals', 'fixed_eth_conversion', 'gas') | ||
list_filter = ('gas', 'decimals', 'fixed_eth_conversion') | ||
ordering = ('relevance',) | ||
search_fields = ['symbol', 'address', 'name'] | ||
readonly_fields = ('eth_value', 'price_oracle_ticker_pairs') | ||
|
||
def eth_value(self, obj: Token): | ||
try: | ||
return obj.get_eth_value() | ||
except CannotGetTokenPriceFromApi: | ||
return None | ||
|
||
def price_oracle_ticker_pairs(self, obj: Token): | ||
return [(price_oracle_ticker.price_oracle.name, price_oracle_ticker.ticker) for price_oracle_ticker | ||
in obj.price_oracle_tickers.all()] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters