diff --git a/hypha/apply/funds/files.py b/hypha/apply/funds/files.py index b5ee6c23ea36005f9d54691068f70c10d2500d62..1862c800f3b13e2da23f1d6c61f120a6541f3089 100644 --- a/hypha/apply/funds/files.py +++ b/hypha/apply/funds/files.py @@ -14,20 +14,23 @@ def generate_submission_file_path(submission_id, field_id, file_name): class SubmissionStreamFieldFile(StreamFieldFile): - def generate_filename(self): + + def get_submission_id(self): from hypha.apply.funds.models.submissions import ApplicationRevision submission_id = self.instance.pk if isinstance(self.instance, ApplicationRevision): submission_id = self.instance.submission.pk + return submission_id - return generate_submission_file_path(submission_id, self.field.id, self.name) + def generate_filename(self): + return generate_submission_file_path(self.get_submission_id(), self.field.id, self.name) @property def url(self): return reverse( 'apply:submissions:serve_private_media', kwargs={ - 'pk': self.instance.pk, + 'pk': self.get_submission_id(), 'field_id': self.field.id, 'file_name': self.basename, } diff --git a/hypha/apply/funds/templates/funds/applicationsubmission_form.html b/hypha/apply/funds/templates/funds/applicationsubmission_form.html index 8520b225d9c2a2e2a4d861e873aac9898ee9c2d4..7f41d66c57c5b4523daeecd67c879d425415940b 100644 --- a/hypha/apply/funds/templates/funds/applicationsubmission_form.html +++ b/hypha/apply/funds/templates/funds/applicationsubmission_form.html @@ -44,7 +44,6 @@ {% endblock %} {% block extra_js %} - <script src="{% static 'js/apply/list-input-files.js' %}"></script> <script src="{% static 'js/apply/tinymce-word-count.js' %}"></script> <script src="{% static 'js/apply/multi-input-fields.js' %}"></script> <script src="{% static 'js/apply/submission-form-copy.js' %}"></script> diff --git a/hypha/apply/projects/templates/application_projects/invoice_form.html b/hypha/apply/projects/templates/application_projects/invoice_form.html index abab3377be16270f7731535426e359220ab9725e..d790ff7445339bdc8d683dfccf04e833ab11b698 100644 --- a/hypha/apply/projects/templates/application_projects/invoice_form.html +++ b/hypha/apply/projects/templates/application_projects/invoice_form.html @@ -30,7 +30,3 @@ </div> </div> {% endblock %} - -{% block extra_js %} -<script src="{% static 'js/apply/list-input-files.js' %}"></script> -{% endblock %} diff --git a/hypha/apply/projects/templates/application_projects/project_approval_form.html b/hypha/apply/projects/templates/application_projects/project_approval_form.html index 8520b225d9c2a2e2a4d861e873aac9898ee9c2d4..7f41d66c57c5b4523daeecd67c879d425415940b 100644 --- a/hypha/apply/projects/templates/application_projects/project_approval_form.html +++ b/hypha/apply/projects/templates/application_projects/project_approval_form.html @@ -44,7 +44,6 @@ {% endblock %} {% block extra_js %} - <script src="{% static 'js/apply/list-input-files.js' %}"></script> <script src="{% static 'js/apply/tinymce-word-count.js' %}"></script> <script src="{% static 'js/apply/multi-input-fields.js' %}"></script> <script src="{% static 'js/apply/submission-form-copy.js' %}"></script> diff --git a/hypha/apply/projects/templates/application_projects/report_form.html b/hypha/apply/projects/templates/application_projects/report_form.html index f43bac4b2a4d9b680005ea2f27208f02ec661df8..b6a3cbc54d132bfa59fe1ca0e651a2c5114cf0d8 100644 --- a/hypha/apply/projects/templates/application_projects/report_form.html +++ b/hypha/apply/projects/templates/application_projects/report_form.html @@ -73,6 +73,5 @@ {% block extra_js %} <script src="{% static 'js/apply/jquery.fancybox.min.js' %}"></script> -<script src="{% static 'js/apply/list-input-files.js' %}"></script> <script src="{% static 'js/apply/fancybox-global.js' %}"></script> {% endblock %} diff --git a/hypha/apply/projects/templates/application_projects/vendor_form.html b/hypha/apply/projects/templates/application_projects/vendor_form.html index 6fcdd52daf36828dc1dcb0ebcede75214784725e..e6079e0c85850cec480c84985c7d8fe2545ee9a8 100644 --- a/hypha/apply/projects/templates/application_projects/vendor_form.html +++ b/hypha/apply/projects/templates/application_projects/vendor_form.html @@ -36,5 +36,4 @@ {% block extra_js %} {{ form.media.js }} - <script src="{% static 'js/apply/list-input-files.js' %}"></script> {% endblock %} diff --git a/hypha/apply/projects/templates/application_projects/vendor_success.html b/hypha/apply/projects/templates/application_projects/vendor_success.html index c74ffd41bce33e6a75bfaba296cbfece1a51803e..297b4a6f0d560f139427971846e5d57de1495ca2 100644 --- a/hypha/apply/projects/templates/application_projects/vendor_success.html +++ b/hypha/apply/projects/templates/application_projects/vendor_success.html @@ -18,7 +18,3 @@ <a href="{% url 'apply:projects:detail' pk=project.pk %}">{% trans "Visit Project Detail Page" %}</a> </div> {% endblock %} - -{% block extra_js %} -<script src="{% static 'js/apply/list-input-files.js' %}"></script> -{% endblock %} diff --git a/hypha/static_src/src/javascript/apply/list-input-files.js b/hypha/static_src/src/javascript/apply/list-input-files.js deleted file mode 100644 index 4ac805e779cd581d1d8cb1d4bcb8552dcebbde75..0000000000000000000000000000000000000000 --- a/hypha/static_src/src/javascript/apply/list-input-files.js +++ /dev/null @@ -1,20 +0,0 @@ -(function ($) { - - 'use strict'; - - function listInputFiles() { - $('input[type=file]').change(function () { - // remove any existing files first - $(this).siblings('.form__file').remove(); - for (let i = 0; i < $(this)[0].files.length; ++i) { - $(this).parents('.form__item').prepend(` - <p class="form__file">${$(this)[0].files[i].name}</p> - `); - } - }); - } - - // Show list of selected files for upload on input[type=file] - listInputFiles(); - -})(jQuery); diff --git a/requirements.txt b/requirements.txt index a51a87d53db5a43f96066e60018e143200adf740..6f4c49bb3e8bba3bf233f25584cffc373bd37ce5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,8 @@ django-basic-auth-ip-whitelist==0.3.4 django-bleach==3.0.0 django-countries==7.2.1 django-extensions==3.1.5 -django-file-form==3.3.0 +# django-file-form==3.3.0 +git+https://github.com/theskumar/django-file-form.git@feature/error-message-invalid-files django-filter==2.4.0 django-fsm==2.8.0 django-heroku==0.3.1