Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
375 changes: 334 additions & 41 deletions arcsi/api/item.py

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions arcsi/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def broadcast_audio(
episode_name,
image_file_name,
):
## TODO yield them
broadcast_file_path = media_path(
norms_show_name, str(episode_number), audio_file_name
)
Expand Down Expand Up @@ -244,6 +245,18 @@ def process_files(
return item, image_file_name, error, error_message


def delete_file(archive_base, archive_idx, archive_name):
Comment thread
pvj marked this conversation as resolved.
os.remove(
safe_join(
app.config["UPLOAD_FOLDER"],
archive_base,
archive_idx,
secure_filename(archive_name),
)
)
return True


def save_file(norms_show_name, episode_number, archive_file, archive_file_name):
formed_file_name = form_filename(archive_file, archive_file_name)
app.logger.debug("STATUS/SAVE FILE: formed_file_name: {}".format(formed_file_name))
Expand Down
35 changes: 35 additions & 0 deletions arcsi/handler/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import time

from botocore.exceptions import ClientError
from botocore.config import Config
from werkzeug.utils import safe_join, secure_filename

from flask import current_app as app

Expand Down Expand Up @@ -62,6 +64,39 @@ def download(self, space, path):
)
return self.dl_file_url

def media_path(self, show, number, item_name):
try:
os.makedirs("{}/{}/{}".format(app.config["UPLOAD_FOLDER"], show, number))
except FileExistsError as err:
pass
media_file_path = safe_join(
app.config["UPLOAD_FOLDER"], show, number, secure_filename(item_name)
)
return media_file_path

def tmp_save_file(self, base_url, media_url, dir):
presigned_url = self.download(base_url, media_url)
(name, url) = (media_url.rsplit("/", 1)[1], presigned_url)
tmp_name = (
media_path(
base_url,
str(dir),
name,
),
)
resp = requests.get(url, stream=True)
if resp.ok:

with open(
tmp_name,
"wb",
) as _tmp_file:
for chunk in resp.iter_content(chunk_size=4 * 1024):
_tmp_file.write(chunk)
return True, tmp_name
else:
return False, tmp_name

# TODO STUB lets see what the final architecture would look like
def batch_upload(self):
upload_queue = UploadQueue(100)
Expand Down
38 changes: 34 additions & 4 deletions arcsi/static/generalstyles.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
body {
background-color: #d09cf8;
color: #23282d;
font-family: 'Rubik', "Segoe UI","Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
color: #23282d;
font-family: 'Rubik', "Segoe UI","Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
}

img {
Expand Down Expand Up @@ -152,6 +152,27 @@ section ul {
overflow: auto;
}

.add-airing > div p {
font-weight: 250;
min-width: 64%;
max-width: 65%;
}

.add-airing > div input[type=date],
.add-airing > div select {
margin: 0.7rem 0;
}

.add-media > div span {
font-size: 1.3rem;
margin-left: -3rem;
cursor: pointer;
border-style: double;
}
.add-media > div p {
min-width: 64%;
max-width: 65%;
}
.add-infos {
display: flex;
flex-direction: column;
Expand All @@ -171,7 +192,16 @@ section ul {
.add-infos > div label {
margin: 0 0.4rem 0 0;
font-weight: 500;
flex: 0 0 15rem;
flex: 0 0 20rem;
}

.add-infos > div input {
margin-right: 1rem;
}

.add-infos > div input[type=file] {
margin-bottom: 1rem;
margin-top: 1rem;
}

.add-infos > div input[type=button],
Expand Down Expand Up @@ -219,4 +249,4 @@ section ul {

#topbutt:hover {
opacity: 1;
}
}
11 changes: 7 additions & 4 deletions arcsi/templates/item/add.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ <h2>{% block title %}Add episode to archive{% endblock %}</h2>
</div>

<div>
<label for="play_date">Play date *</label>
<input type="date" name="play_date" id="play_date" required>
<label for="date_info">Schedule</label>
<p>The station schedule rotates weekly. If any broadcasting type is selected the episode airs the next time the show is broadcasted. If no episode is added during the week then the show airs the most recent episode by default.</p>
<p>Summary: Set date the day your show is airing, within one week from today.</p>
<label for="play_date">Play date *</label>
<input type="date" name="play_date" id="play_date" required>
</div>

<article class="add-infos add-airing">
<div>
<label for="live">Live</label>
Expand Down Expand Up @@ -113,7 +116,7 @@ <h2>{% block title %}Add episode to archive{% endblock %}</h2>
<span onclick="play_file.value=''"><b>Reset</b></span>
</div>
</article>

<div>
<input type="submit" value="Add">
</div>
Expand Down
2 changes: 1 addition & 1 deletion arcsi/templates/item/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ <h2>{% block title %}Edit episode item{% endblock %}</h2>
<article class="add-infos add-airing">
<div>
<label for="live">Live</label>
<input type="hidden" name="live" id="live"
<input type="hidden" name="live" id="live"
{% if item.live %} value="1" {% else %} value="0" {% endif %}>
<input type="checkbox" onclick="this.previousElementSibling.value=this.checked?1:0"
{% if item.live %} checked {% endif %}>
Expand Down
8 changes: 4 additions & 4 deletions arcsi/templates/show/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h2>{% block title %}Edit radio show{% endblock %}</h2>
<label for="description">Show description *</label>
<textarea name="description" id="description" value="{{ show.description }}" required>{{ show.description }}</textarea>
</div>

<div>
<label for="contact_address">Contact address *</label>
<input name="contact_address" id="contact_address" value="{{ show.contact_address }}">
Expand Down Expand Up @@ -68,14 +68,14 @@ <h2>{% block title %}Edit radio show{% endblock %}</h2>
<label for="frequency">Frequency (new-show-per-month) *</label>
<input type="number" name="frequency" id="frequency" value="{{ show.frequency }}">
</div>

<div>
<label for="week">Week *</label>
<input type="number" name="week" id="week" value="{{ show.week }}">
<label for="day">Day *</label>
<input type="number" name="day" id="day" value="{{ show.day }}">
</div>

<div>
<label for="start">Start</label>
<input type="time" name="start" id="start" value="{{ show.start }}">
Expand All @@ -93,7 +93,7 @@ <h2>{% block title %}Edit radio show{% endblock %}</h2>
</article>

<article class="add-infos add-media">
<p>Please use an <b>image</b> between <b>200-500 kB</b> as your show's cover</p>
<p>Please use an <b>image</b> between <b>200-500 kB</b> as your show's cover</p>

<div>
<label for="image_file">Cover image</label>
Expand Down
44 changes: 30 additions & 14 deletions test/postman/functional_test.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -1730,8 +1730,10 @@
" pm.expect(show.name).to.be.an(\"string\")\r",
" pm.expect(show.archive_lahmastore_base_url).to.be.an(\"string\")\r",
" pm.expect(show.id).to.be.an(\"number\")\r",
" })\r",
" pm.expect(item.airing).to.be.an(\"boolean\");\r",
" })\r",
" if (item.airing != null) {\r",
" pm.expect(item.airing).to.be.an(\"boolean\");\r",
" }\r",
" pm.expect(item.archive_lahmastore).to.be.an(\"boolean\");\r",
" pm.expect(item.archived).to.be.an(\"boolean\");\r",
" pm.expect(item.broadcast).to.be.an(\"boolean\");\r",
Expand Down Expand Up @@ -2291,9 +2293,11 @@
" pm.expect(show.name).to.be.an(\"string\")\r",
" pm.expect(show.archive_lahmastore_base_url).to.be.an(\"string\")\r",
" pm.expect(show.id).to.be.an(\"number\")\r",
" })\r",
" pm.expect(item.airing).to.be.an(\"boolean\");\r",
" pm.expect(item.archive_lahmastore).to.be.an(\"boolean\");\r",
" })\r",
" if (item.airing != null) {\r",
" pm.expect(item.airing).to.be.an(\"boolean\");\r",
" }\r",
" pm.expect(item.archive_lahmastore).to.be.an(\"boolean\");\r",
" pm.expect(item.archived).to.be.an(\"boolean\");\r",
" pm.expect(item.broadcast).to.be.an(\"boolean\");\r",
" pm.expect(item.live).to.be.an(\"boolean\");\r",
Expand Down Expand Up @@ -2576,7 +2580,9 @@
" pm.expect(show.archive_lahmastore_base_url).to.be.an(\"string\")\r",
" pm.expect(show.id).to.be.an(\"number\")\r",
" })\r",
" pm.expect(item.airing).to.be.an(\"boolean\");\r",
" if (item.airing != null) {\r",
" pm.expect(item.airing).to.be.an(\"boolean\");\r",
" }\r",
" pm.expect(item.archive_lahmastore).to.be.an(\"boolean\");\r",
" pm.expect(item.archived).to.be.an(\"boolean\");\r",
" pm.expect(item.broadcast).to.be.an(\"boolean\");\r",
Expand Down Expand Up @@ -3191,8 +3197,10 @@
" pm.expect(show.name).to.be.an(\"string\")\r",
" pm.expect(show.archive_lahmastore_base_url).to.be.an(\"string\")\r",
" pm.expect(show.id).to.be.an(\"number\")\r",
" })\r",
" pm.expect(item.airing).to.be.an(\"boolean\");\r",
" })\r",
" if (item.airing != null) {\r",
" pm.expect(item.airing).to.be.an(\"boolean\");\r",
" }\r",
" pm.expect(item.archive_lahmastore).to.be.an(\"boolean\");\r",
" pm.expect(item.archived).to.be.an(\"boolean\");\r",
" pm.expect(item.broadcast).to.be.an(\"boolean\");\r",
Expand Down Expand Up @@ -3810,7 +3818,9 @@
" pm.expect(show.archive_lahmastore_base_url).to.be.an(\"string\")\r",
" pm.expect(show.id).to.be.an(\"number\")\r",
" })\r",
" pm.expect(item.airing).to.be.an(\"boolean\");\r",
" if (item.airing != null) {\r",
" pm.expect(item.airing).to.be.an(\"boolean\");\r",
" }\r",
" pm.expect(item.archive_lahmastore).to.be.an(\"boolean\");\r",
" pm.expect(item.archived).to.be.an(\"boolean\");\r",
" pm.expect(item.broadcast).to.be.an(\"boolean\");\r",
Expand Down Expand Up @@ -4233,8 +4243,10 @@
" pm.expect(show.name).to.be.an(\"string\")\r",
" pm.expect(show.archive_lahmastore_base_url).to.be.an(\"string\")\r",
" pm.expect(show.id).to.be.an(\"number\")\r",
" })\r",
" pm.expect(item.airing).to.be.an(\"boolean\");\r",
" })\r",
" if (item.airing != null) {\r",
" pm.expect(item.airing).to.be.an(\"boolean\");\r",
" }\r",
" pm.expect(item.archive_lahmastore).to.be.an(\"boolean\");\r",
" pm.expect(item.archived).to.be.an(\"boolean\");\r",
" pm.expect(item.broadcast).to.be.an(\"boolean\");\r",
Expand Down Expand Up @@ -4694,7 +4706,9 @@
" pm.expect(show.archive_lahmastore_base_url).to.be.an(\"string\")\r",
" pm.expect(show.id).to.be.an(\"number\")\r",
" })\r",
" pm.expect(item.airing).to.be.an(\"boolean\");\r",
" if (item.airing != null) {\r",
" pm.expect(item.airing).to.be.an(\"boolean\");\r",
" }\r",
" pm.expect(item.archive_lahmastore).to.be.an(\"boolean\");\r",
" pm.expect(item.archived).to.be.an(\"boolean\");\r",
" pm.expect(item.broadcast).to.be.an(\"boolean\");\r",
Expand Down Expand Up @@ -5104,7 +5118,9 @@
" pm.expect(show.archive_lahmastore_base_url).to.be.an(\"string\")\r",
" pm.expect(show.id).to.be.an(\"number\")\r",
" })\r",
" pm.expect(item.airing).to.be.an(\"boolean\");\r",
" if (item.airing != null) {\r",
" pm.expect(item.airing).to.be.an(\"boolean\");\r",
" }\r",
" pm.expect(item.archive_lahmastore).to.be.an(\"boolean\");\r",
" pm.expect(item.archived).to.be.an(\"boolean\");\r",
" pm.expect(item.broadcast).to.be.an(\"boolean\");\r",
Expand Down Expand Up @@ -6426,4 +6442,4 @@
"response": []
}
]
}
}
Loading