diff --git a/.gitignore b/.gitignore index a93567f..b8e6050 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,7 @@ __pycache__ *.pyc db.sqlite3 credentials -polyphonic/settings.py \ No newline at end of file +polyphonic/settings.py +env +text.* +static \ No newline at end of file diff --git a/Makefile b/Makefile index 82928ef..0496122 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,27 @@ -DROPZONE=https://github.com/enyo/dropzone/archive/v5.7.0.zip - +PYTHON=env/bin/python +DROPZONE=5.7.0 dev-setup: - pip install -r requirements.txt - pip install -r dev-requirements.txt - ./manage.py migrate - ./manage.py createsuperuser --username admin --email admin@localhost + env/bin/pip install -r requirements.txt + env/bin/pip install -r dev-requirements.txt + ${PYTHON} manage.py migrate + ${PYTHON} manage.py createsuperuser --username admin --email admin@localhost -interface/static/dropzone/dropzone.js: - wget -O dropzone.zip ${DROPZONE} - unzip -d interface/static dropzone.zip \ No newline at end of file +upgrade: + ${PYTHON} manage.py migrate + ${PYTHON} manage.py collectstatic + ${MAKE} libraries + +libraries: static/dropzone static/fonts/Quicksand_Book.otf + +static/dropzone: + wget -O dropzone-${DROPZONE}.zip https://github.com/enyo/dropzone/archive/v${DROPZONE}.zip + unzip dropzone-${DROPZONE}.zip + mv dropzone-${DROPZONE}/dist static/dropzone + rm -rf dropzone-${DROPZONE} dropzone-${DROPZONE}.zip + +static/fonts/Quicksand_Book.otf: + wget -O quicksand.zip https://dl.dafont.com/dl/?f=quicksand + mkdir -p static/fonts + unzip -d static/fonts quicksand.zip + rm quicksand.zip \ No newline at end of file diff --git a/interface/migrations/0016_auto_20200910_2025.py b/interface/migrations/0016_auto_20200910_2025.py new file mode 100644 index 0000000..0ee32f9 --- /dev/null +++ b/interface/migrations/0016_auto_20200910_2025.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.1 on 2020-09-10 10:25 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('interface', '0015_resource_media_type'), + ] + + operations = [ + migrations.AlterField( + model_name='resource', + name='media_type', + field=models.CharField(choices=[('audio', 'Audio'), ('video', 'Video'), ('general', 'General')], default='*', max_length=10), + ), + ] diff --git a/interface/models.py b/interface/models.py index 2752ba8..0001fb6 100644 --- a/interface/models.py +++ b/interface/models.py @@ -18,7 +18,7 @@ BUCKET = settings.AWS_BUCKET MEDIA_TYPES = [ ('audio', "Audio"), ('video', "Video"), - ('*', "General"), + ('general', "General"), ] def generate_code(length=9): @@ -63,7 +63,12 @@ class Resource(models.Model): media_type = models.CharField(max_length=10, choices=MEDIA_TYPES, default='*') def key_template(self): - return "{}_${{filename}}".format(slugify(self.name)) + return "{}/${{filename}}".format(slugify(self.name)) + + def accept(self): + if self.media_type == 'general': + return ".*" + return f"{self.media_type}/*" def presigned_url(self): if not self.key: diff --git a/interface/static/interface/css/polyphonic.css b/interface/static/interface/css/polyphonic.css index 6dc44ce..6df8f6f 100644 --- a/interface/static/interface/css/polyphonic.css +++ b/interface/static/interface/css/polyphonic.css @@ -5,11 +5,6 @@ --light-blue: #c5eff7; } -@font-face { - font-family: 'DreamOrphans'; - src: url('../../fonts/dream orphans.ttf') format('truetype'); -} - @font-face { font-family: 'Quicksand'; src: url('../../fonts/Quicksand_Book.otf'); @@ -102,7 +97,7 @@ UL.nav-buttons > LI { /* FORMS */ -FORM { +FORM.vertical { display: flex; flex-direction: column; max-width: 400px; @@ -221,4 +216,8 @@ TABLE.horizontal TH { .resource-player { width: 100%; border-radius: 10px; +} + +.dz-clickable { + text-align: center; } \ No newline at end of file diff --git a/interface/templates/interface/project_form.html b/interface/templates/interface/project_form.html index 3fb6ecd..f9b7926 100644 --- a/interface/templates/interface/project_form.html +++ b/interface/templates/interface/project_form.html @@ -4,7 +4,7 @@

{{ title }}

{{ instructions }}

-
+ {% csrf_token %} {{ form }}
diff --git a/interface/templates/interface/resource_list.html b/interface/templates/interface/resource_list.html index 18ebe74..800d023 100644 --- a/interface/templates/interface/resource_list.html +++ b/interface/templates/interface/resource_list.html @@ -11,12 +11,12 @@ {{ resource.name }} {% if download %} - + Download {% endif %} {% if request.user.is_authenticated %} - + Upload {% endif %} diff --git a/interface/templates/interface/s3_upload.html b/interface/templates/interface/s3_upload.html new file mode 100644 index 0000000..51b55ba --- /dev/null +++ b/interface/templates/interface/s3_upload.html @@ -0,0 +1,82 @@ +{% extends "base.html" %} +{% load static %} + +{% block content %} + + +
+

Select a file for upload

+ +
+ {% for field, value in upload.fields.items %} + + {% endfor %} + + + +
+ +
+ Cancel +   + +
+
+ +{% endblock %} + +{% block scripts %} + + +{{ ajax_upload|json_script:"dropzone-data" }} + +{% endblock %} diff --git a/interface/templates/interface/submission_create.html b/interface/templates/interface/submission_create.html index 5cee68d..65c6e6d 100644 --- a/interface/templates/interface/submission_create.html +++ b/interface/templates/interface/submission_create.html @@ -9,7 +9,7 @@

-
+ {% csrf_token %} {{ form }}
diff --git a/interface/templates/interface/submission_upload.html b/interface/templates/interface/submission_upload.html deleted file mode 100644 index 9f85619..0000000 --- a/interface/templates/interface/submission_upload.html +++ /dev/null @@ -1,99 +0,0 @@ -{% extends "base.html" %} -{% load static %} - -{% block content %} - - -
-

Ready to upload file

- - {% for field, value in upload.fields.items %} - - {% endfor %} - - - -
-
-
- -
- Cancel -   - -
-
Select a file to upload
- -
- -
- -{% endblock %} - -{% block scripts %} - - - -{% endblock %} diff --git a/interface/views.py b/interface/views.py index f3d3d7d..a437923 100644 --- a/interface/views.py +++ b/interface/views.py @@ -46,6 +46,10 @@ class ProjectMixin(EnsembleMixin): return context class S3UploadMixin(ProjectMixin): + media_type = '' + + def get_media_type(self): + return self.media_type def get_cancel_url(self): return self.cancel_url @@ -64,6 +68,7 @@ class S3UploadMixin(ProjectMixin): context['ajax_upload'] = project.presigned_post(key_template) context['success_url'] = success_url context['cancel_url'] = self.get_cancel_url() + context['media_type'] = self.media_type return context class S3CompleteMixin(View): @@ -176,6 +181,7 @@ class SubmissionDetailView(ProjectMixin, S3CompleteMixin, DetailView): class SubmissionUploadView(S3UploadMixin, DetailView): template_name = 'interface/s3_upload.html' model = models.Submission + media_type = "video" def get_success_url(self): return resolve_url('submission_detail', **self.kwargs) @@ -209,7 +215,10 @@ class ResourceCreateView(ProjectMixin, CreateView): class ResourceUploadView(S3UploadMixin, DetailView): model = models.Resource - template_name = 'interface/submission_upload.html' + template_name = 'interface/s3_upload.html' + + def get_media_type(self): + return self.object.accept() def get_success_url(self): return resolve_url('resource_complete', **self.kwargs)