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_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 = {
|
||||
'saved_stations': saved_stations,
|
||||
'history': history,
|
||||
'amazon_enabled': settings.AMAZON_AFFILIATE_ENABLED,
|
||||
}
|
||||
return render(request, 'radio/player.html', context)
|
||||
|
||||
|
|
@ -144,6 +145,9 @@ def record_track(request):
|
|||
# ---------------------------------------------------------------------------
|
||||
|
||||
def affiliate_links(request):
|
||||
if not settings.AMAZON_AFFILIATE_ENABLED:
|
||||
return JsonResponse({'amazon_url': None, 'itunes_data': {}})
|
||||
|
||||
track = request.GET.get('track', '').strip()
|
||||
if not track:
|
||||
return JsonResponse({'error': 'track parameter required'}, status=400)
|
||||
|
|
|
|||
|
|
@ -282,6 +282,7 @@ async function deleteHistoryEntry(id, btn) {
|
|||
|
||||
async function fetchAffiliateLinks(track) {
|
||||
const section = $('affiliate-section');
|
||||
if (section && section.dataset.disabled) return;
|
||||
try {
|
||||
const res = await fetch('/radio/affiliate/?track=' + encodeURIComponent(track));
|
||||
if (!res.ok) return;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
</section>
|
||||
|
||||
<!-- ===== 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">
|
||||
<div class="affiliate-info">
|
||||
<div class="affiliate-track" id="affiliate-track-name"></div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue