From a1d10ea30afaa6a1582baa48cd5e58786b71b71e Mon Sep 17 00:00:00 2001 From: Tris Forster Date: Sun, 6 Sep 2020 09:08:37 +1000 Subject: [PATCH] S3 Upload working --- Makefile | 7 +++ interface/models.py | 5 +- interface/static/interface/css/polyphonic.css | 4 ++ interface/templates/base.html | 5 +- interface/templates/interface/submission.html | 18 ++++--- interface/templates/interface/upload.html | 48 +++++++++++++++---- interface/views.py | 4 +- 7 files changed, 69 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index e6cfd7f..82928ef 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,12 @@ +DROPZONE=https://github.com/enyo/dropzone/archive/v5.7.0.zip + + dev-setup: pip install -r requirements.txt pip install -r dev-requirements.txt ./manage.py migrate ./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 diff --git a/interface/models.py b/interface/models.py index 8ba4580..2ca8b33 100644 --- a/interface/models.py +++ b/interface/models.py @@ -27,6 +27,9 @@ class Project(models.Model): deadline =models.DateField(null=True, blank=True) bucket = models.CharField(max_length=100) + def submissions(self): + return self.all_submissions.filter(complete=True) + def presigned_post(self, object_name, fields={}, conditions=[], expires=3600): key = os.path.join(slugify(self.name), object_name) return s3client.generate_presigned_post(self.bucket, key, Fields=fields, Conditions=conditions, ExpiresIn=expires) @@ -48,7 +51,7 @@ class WikiPage(models.Model): return self.title class Submission(models.Model): - project = models.ForeignKey(Project, related_name='submissions', on_delete=models.CASCADE) + project = models.ForeignKey(Project, related_name='all_submissions', on_delete=models.CASCADE) date = models.DateField(auto_now_add=True) name = models.CharField(max_length=255) instrument = models.CharField(max_length=100) diff --git a/interface/static/interface/css/polyphonic.css b/interface/static/interface/css/polyphonic.css index 448c10d..2d6910b 100644 --- a/interface/static/interface/css/polyphonic.css +++ b/interface/static/interface/css/polyphonic.css @@ -3,6 +3,10 @@ background-color: #69C; } +.form-actions { + margin-top: 20px; +} + #project H1 { text-align: center; } \ No newline at end of file diff --git a/interface/templates/base.html b/interface/templates/base.html index 2fa750a..32530c2 100644 --- a/interface/templates/base.html +++ b/interface/templates/base.html @@ -39,14 +39,15 @@ {% endblock %} - + + + {% block content %}

No content!

{% endblock %} - diff --git a/interface/templates/interface/submission.html b/interface/templates/interface/submission.html index 028cbca..d9e1c8e 100644 --- a/interface/templates/interface/submission.html +++ b/interface/templates/interface/submission.html @@ -1,13 +1,17 @@ {% extends "interface/project.html" %} {% block page %} -

- Some instructions about how to submit the file - {{ url }} -

+
+
Make a submission
+
+

+ Some instructions about how to submit the file + {{ url }} +

-
- {% include "interface/bootstrap-form.html" %} +
+ {% include "interface/bootstrap-form.html" %} +
+
- {% endblock %} \ No newline at end of file diff --git a/interface/templates/interface/upload.html b/interface/templates/interface/upload.html index 67976f8..a560fcb 100644 --- a/interface/templates/interface/upload.html +++ b/interface/templates/interface/upload.html @@ -1,19 +1,47 @@ {% extends "base.html" %} +{% load static %} {% block content %} + +
-
- {% for field, value in upload.fields.items %} - - {% endfor %} - File: - -
- Cancel - +
+
Ready to upload file
+
+ + {% for field, value in upload.fields.items %} + + {% endfor %} + + + +
+ Cancel + +
+
- + +
+ + + {% endblock %} \ No newline at end of file diff --git a/interface/views.py b/interface/views.py index edefb73..1f43184 100644 --- a/interface/views.py +++ b/interface/views.py @@ -72,7 +72,7 @@ def submission(request, project_id): form = forms.SubmissionForm() context = {'project': project, 'form': form} - return render(request, 'interface/submission.html', context) + return render(request, 'interface/submission.html', context) @check_allowed def cancel_submission(request, project_id, submission_id): @@ -84,7 +84,7 @@ def cancel_submission(request, project_id, submission_id): @check_allowed def complete_submission(request, project_id, submission_id): project = get_object_or_404(models.Project, pk=project_id, ensemble=request.ensemble_id) - s = project.submissions.get(pk=submission_id) + s = project.all_submissions.get(pk=submission_id) s.complete = True s.key = request.GET['key'] s.save()