Add AMAZON_AFFILIATE_ENABLED flag, disabled by default
This commit is contained in:
parent
0f4a7e96d3
commit
945da36c95
4 changed files with 7 additions and 1 deletions
|
|
@ -98,3 +98,4 @@ LASTFM_API_SECRET = os.environ.get('LASTFM_API_SECRET', '')
|
||||||
|
|
||||||
# Amazon affiliate
|
# Amazon affiliate
|
||||||
AMAZON_AFFILIATE_TAG = os.environ.get('AMAZON_AFFILIATE_TAG', 'diora-20')
|
AMAZON_AFFILIATE_TAG = os.environ.get('AMAZON_AFFILIATE_TAG', 'diora-20')
|
||||||
|
AMAZON_AFFILIATE_ENABLED = os.environ.get('AMAZON_AFFILIATE_ENABLED', 'True') == 'True'
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ def index(request):
|
||||||
context = {
|
context = {
|
||||||
'saved_stations': saved_stations,
|
'saved_stations': saved_stations,
|
||||||
'history': history,
|
'history': history,
|
||||||
|
'amazon_enabled': settings.AMAZON_AFFILIATE_ENABLED,
|
||||||
}
|
}
|
||||||
return render(request, 'radio/player.html', context)
|
return render(request, 'radio/player.html', context)
|
||||||
|
|
||||||
|
|
@ -144,6 +145,9 @@ def record_track(request):
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
def affiliate_links(request):
|
def affiliate_links(request):
|
||||||
|
if not settings.AMAZON_AFFILIATE_ENABLED:
|
||||||
|
return JsonResponse({'amazon_url': None, 'itunes_data': {}})
|
||||||
|
|
||||||
track = request.GET.get('track', '').strip()
|
track = request.GET.get('track', '').strip()
|
||||||
if not track:
|
if not track:
|
||||||
return JsonResponse({'error': 'track parameter required'}, status=400)
|
return JsonResponse({'error': 'track parameter required'}, status=400)
|
||||||
|
|
|
||||||
|
|
@ -282,6 +282,7 @@ async function deleteHistoryEntry(id, btn) {
|
||||||
|
|
||||||
async function fetchAffiliateLinks(track) {
|
async function fetchAffiliateLinks(track) {
|
||||||
const section = $('affiliate-section');
|
const section = $('affiliate-section');
|
||||||
|
if (section && section.dataset.disabled) return;
|
||||||
try {
|
try {
|
||||||
const res = await fetch('/radio/affiliate/?track=' + encodeURIComponent(track));
|
const res = await fetch('/radio/affiliate/?track=' + encodeURIComponent(track));
|
||||||
if (!res.ok) return;
|
if (!res.ok) return;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- ===== AFFILIATE / TRACK INFO ===== -->
|
<!-- ===== AFFILIATE / TRACK INFO ===== -->
|
||||||
<section class="affiliate-section" id="affiliate-section" style="display:none;">
|
<section class="affiliate-section" id="affiliate-section" style="display:none;"{% if not amazon_enabled %} data-disabled="true"{% endif %}>
|
||||||
<img class="affiliate-artwork" id="affiliate-artwork" src="" alt="Album art">
|
<img class="affiliate-artwork" id="affiliate-artwork" src="" alt="Album art">
|
||||||
<div class="affiliate-info">
|
<div class="affiliate-info">
|
||||||
<div class="affiliate-track" id="affiliate-track-name"></div>
|
<div class="affiliate-track" id="affiliate-track-name"></div>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue