-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #281 from clabs/dev
Improve player and web link refactor
- Loading branch information
Showing
25 changed files
with
3,805 additions
and
567 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
20 changes: 20 additions & 0 deletions
20
src/rockon/bands/migrations/0013_band_mean_age_under_27.py
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Generated by Django 5.1 on 2024-08-22 09:52 | ||
|
||
from __future__ import annotations | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("rockonbands", "0012_bandvote_event"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="band", | ||
name="mean_age_under_27", | ||
field=models.BooleanField(default=False), | ||
), | ||
] |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Generated by Django 5.1 on 2024-08-22 10:33 | ||
|
||
from __future__ import annotations | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("rockonbands", "0013_band_mean_age_under_27"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="band", | ||
name="is_coverband", | ||
field=models.BooleanField(default=False), | ||
), | ||
] |
32 changes: 32 additions & 0 deletions
32
src/rockon/bands/migrations/0015_alter_bandmedia_media_type.py
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Generated by Django 5.1 on 2024-08-22 11:08 | ||
|
||
from __future__ import annotations | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("rockonbands", "0014_band_is_coverband"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="bandmedia", | ||
name="media_type", | ||
field=models.CharField( | ||
choices=[ | ||
("unknown", "Unbekannt"), | ||
("audio", "Audio"), | ||
("document", "Dokument"), | ||
("link", "Link"), | ||
("logo", "Logo"), | ||
("press_photo", "Pressefoto"), | ||
("web", "Webseite"), | ||
], | ||
default="unknown", | ||
max_length=32, | ||
), | ||
), | ||
] |
42 changes: 42 additions & 0 deletions
42
src/rockon/bands/migrations/0016_remove_band_facebook_remove_band_homepage.py
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Generated by Django 5.1 on 2024-08-22 11:10 | ||
|
||
from __future__ import annotations | ||
|
||
from django.db import migrations | ||
|
||
|
||
def copy_urls_to_bandmedia(apps, schema_editor): | ||
Band = apps.get_model("rockonbands", "Band") | ||
BandMedia = apps.get_model("rockonbands", "BandMedia") | ||
for band in Band.objects.all(): | ||
if band.facebook: | ||
BandMedia.objects.create( | ||
band=band, | ||
media_type="web", | ||
url=band.facebook, | ||
) | ||
if band.homepage: | ||
BandMedia.objects.create( | ||
band=band, | ||
media_type="web", | ||
url=band.homepage, | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("rockonbands", "0015_alter_bandmedia_media_type"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(copy_urls_to_bandmedia), | ||
migrations.RemoveField( | ||
model_name="band", | ||
name="facebook", | ||
), | ||
migrations.RemoveField( | ||
model_name="band", | ||
name="homepage", | ||
), | ||
] |
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
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ console.debug('bandbewerbung-form.js loaded') | |
const DateTime = luxon.DateTime | ||
|
||
$(document).ready(() => { | ||
console.debug('document ready') | ||
const toastAudioPlayerElement = document.getElementById('toastAudioPlayer') | ||
const toastAudioPlayer = bootstrap.Toast.getOrCreateInstance( | ||
toastAudioPlayerElement | ||
|
@@ -21,9 +22,18 @@ $(document).ready(() => { | |
const url = $('#url_input').val() | ||
if (url === '') return | ||
$('#url_input').val('') | ||
api_add_url(url) | ||
api_add_url(url, 'link') | ||
$('#add_url').prop('disabled', true) | ||
}) | ||
$('#add_web_url').on('click', event => { | ||
event.preventDefault() | ||
console.debug('add url') | ||
const url = $('#web_url_input').val() | ||
if (url === '') return | ||
$('#web_url_input').val('') | ||
api_add_web_url(url, 'web') | ||
$('#add_web_url').prop('disabled', true) | ||
}) | ||
$(document).on('click', '[data-remove-url]', event => { | ||
event.preventDefault() | ||
const id = event.currentTarget.dataset.removeUrl | ||
|
@@ -50,6 +60,14 @@ $(document).ready(() => { | |
$('#add_url').prop('disabled', true) | ||
} | ||
}) | ||
$('#web_url_input').on('blur change', function () { | ||
const url = $(this).val() | ||
if (isValidURL(url)) { | ||
$('#add_web_url').prop('disabled', false) | ||
} else { | ||
$('#add_web_url').prop('disabled', true) | ||
} | ||
}) | ||
$('#selectedFileDocument').on('change', event => { | ||
console.debug('file selected', event) | ||
const file = event.target.files[0] | ||
|
@@ -132,6 +150,11 @@ const li_add_url = url => { | |
$('#url_list').append(element) | ||
} | ||
|
||
const li_add_web_url = url => { | ||
const element = `<li id="url-${url.id}"><a href="${url.url}" target="_blank">${url.url}</a><span class="btn btn-default btn-xs" data-remove-url="${url.id}"><i class="fa fa-trash"></i></span></li>` | ||
$('#web_url_list').append(element) | ||
} | ||
|
||
const li_add_document = document => { | ||
const element = `<li id="document-${document.id}" class="list-group-item d-flex justify-content-between align-items-center"><a href="${document.file}" target="_blank">${document.file_name_original}</a><span class="btn btn-default btn-xs" data-remove-document="${document.id}"><i class="fa fa-trash"></i></span></li>` | ||
$('#document_list').append(element) | ||
|
@@ -176,6 +199,8 @@ const send_form = () => { | |
} | ||
form_obj['are_students'] = form_obj['are_students'] || false | ||
form_obj['has_management'] = form_obj['has_management'] || false | ||
form_obj['mean_age_under_27'] = form_obj['mean_age_under_27'] || false | ||
form_obj['is_coverband'] = form_obj['is_coverband'] || false | ||
form_obj['federal_state'] = $('#federal_state').val() || null | ||
|
||
console.debug('form obj', form_obj) | ||
|
@@ -202,11 +227,11 @@ const save_success = data => { | |
alert("Bandbewerbung gespeichert.") | ||
} | ||
|
||
const api_add_url = url => { | ||
console.debug('add url') | ||
const api_add_url = (url, type) => { | ||
console.debug('add url api') | ||
media_obj = { | ||
url: url, | ||
media_type: 'link', | ||
media_type: type, | ||
band: window.rockon_data.band_id | ||
} | ||
$.ajax({ | ||
|
@@ -225,6 +250,29 @@ const api_add_url = url => { | |
}) | ||
} | ||
|
||
const api_add_web_url = (url, type) => { | ||
console.debug('add web url api') | ||
media_obj = { | ||
url: url, | ||
media_type: type, | ||
band: window.rockon_data.band_id | ||
} | ||
$.ajax({ | ||
type: 'POST', | ||
url: window.rockon_data.api_url_new_media + 'upload/', | ||
data: JSON.stringify(media_obj), | ||
contentType: 'application/json', | ||
headers: { | ||
'X-CSRFToken': $('[name=csrfmiddlewaretoken]').val() | ||
}, | ||
mode: 'same-origin', | ||
dataType: 'json', | ||
success: data => li_add_web_url(data), | ||
error: data => ajax_error(data), | ||
complete: data => ajax_complete(data) | ||
}) | ||
} | ||
|
||
const api_remove_url = id => { | ||
console.debug('remove url') | ||
$.ajax({ | ||
|
@@ -289,9 +337,6 @@ ajax_error = (data, form_obj, url) => { | |
// FIXME: needs error handling | ||
console.error(data) | ||
const response = responseJSON | ||
if (response.homepage || response.facebook) { | ||
return alert('Bitte gibt bei Homepage und Facebook die URL immer mit http:// oder https:// am Anfang ein.') | ||
} | ||
$('#api_message').html(` | ||
<div class="alert alert-danger alert-dismissible fade show" role="alert"> | ||
<strong>Fehler!</strong> Bitte schicke uns folgenden Text an <a href="mailto:[email protected]">[email protected]</a>: <br> | ||
|
Oops, something went wrong.