Skip to content

Commit

Permalink
Merge branch 'jls/drop-MediaUploader' into autostaging
Browse files Browse the repository at this point in the history
  • Loading branch information
orangejenny committed Oct 17, 2024
2 parents 8112c00 + e4a8e77 commit 745ee5a
Show file tree
Hide file tree
Showing 24 changed files with 203 additions and 145 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "corehq/apps/hqmedia/static/hqmedia/MediaUploader"]
path = corehq/apps/hqmedia/static/hqmedia/MediaUploader
url = https://github.com/dimagi/MediaUploader.git
[submodule "submodules/commcare-translations"]
path = submodules/commcare-translations
url = https://github.com/dimagi/commcare-translations.git
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ hqDefine('app_manager/js/app_manager_media', function () {
};

self.passToUploadController = function () {
self.uploadController.resetUploader();
self.uploadController.currentReference = self.getControllerRef();
self.uploadController.uploadParams = self.getUploadParams();
self.uploadController.updateUploadFormUI();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
"use strict";
/* globals HQMediaFileUploadController */
hqDefine("app_manager/js/details/case_detail_print", function () {
var printRef, printTemplateUploader;
var initialPageData = hqImport("hqwebapp/js/initial_page_data"),
printUploader = initialPageData.get("print_uploader_js");
printUploader = initialPageData.get("print_uploader_js"),
uploaders = hqImport("hqmedia/js/uploaders");
if (printUploader) {
printTemplateUploader = new HQMediaFileUploadController(
printTemplateUploader = uploaders.uploader(
printUploader.slug,
printUploader.media_type,
printUploader.options
);
printTemplateUploader.init();
printRef = hqImport('hqmedia/js/media_reference_models').BaseMediaReference(initialPageData.get('print_ref'));
printRef.upload_controller = printTemplateUploader;
printRef.setObjReference(initialPageData.get('print_media_info'));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
/* globals HQMediaFileUploadController */
hqDefine("app_manager/js/nav_menu_media_common", function () {
var initialPageData = hqImport("hqwebapp/js/initial_page_data"),
uploaders = {};
const initialPageData = hqImport("hqwebapp/js/initial_page_data"),
uploadersModule = hqImport("hqmedia/js/uploaders");
let uploaders = {};

_.each(initialPageData.get("multimedia_upload_managers"), function (uploader, type) {
uploaders[type] = new HQMediaFileUploadController(
uploaders[type] = uploadersModule.uploader(
uploader.slug,
uploader.media_type,
uploader.options
);
uploaders[type].init();
});

return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
hqDefine("app_manager/js/settings/app_logos", function () {
var self = {};
var HQMediaUploaders = hqImport("hqmedia/js/hqmediauploaders").get(),
initialPageData = hqImport("hqwebapp/js/initial_page_data");
var refs = initialPageData.get('media_refs');
var mediaInfo = initialPageData.get('media_info');
let self = {};
const initialPageData = hqImport("hqwebapp/js/initial_page_data"),
refs = initialPageData.get('media_refs'),
mediaInfo = initialPageData.get('media_info');

var imageRefs = {};
for (var slug in refs) {
imageRefs[slug] = hqImport('hqmedia/js/media_reference_models').ImageReference(refs[slug]);
imageRefs[slug].upload_controller = HQMediaUploaders[slug];
imageRefs[slug] = hqImport('hqmedia/js/media_reference_models').ImageReference(refs[slug], slug);
imageRefs[slug].setObjReference(mediaInfo[slug]);
}

Expand Down
4 changes: 2 additions & 2 deletions corehq/apps/app_manager/templates/app_manager/app_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
<script src="{% static 'app_manager/js/download_async_modal.js' %}"></script>
<script src="{% static 'app_manager/js/releases/releases.js' %}"></script>
<script src="{% static 'app_manager/js/releases/language_profiles.js' %}"></script>
<script src="{% static "jsdiff/diff.js" %}"></script>
<script src="{% static 'jsdiff/diff.js' %}"></script>
<script src="{% static 'app_manager/js/releases/app_diff.js' %}"></script>
<script src="{% static 'app_manager/js/releases/update_prompt.js' %}"></script>
<script src="{% static 'hqwebapp/js/bootstrap3/widgets.js' %}"></script>
<script src="{% static 'app_manager/js/supported_languages.js' %}"></script>
<script src="{% static 'app_manager/js/settings/translations.js' %}"></script>
<script src="{% static "hqmedia/js/hqmediauploaders.js" %}"></script>
<script src="{% static 'hqmedia/js/uploaders.js' %}"></script>
<script src="{% static 'hqmedia/js/media_reference_models.js' %}"></script>
<script src="{% static 'app_manager/js/app_view.js' %}"></script>
<script src="{% static 'app_manager/js/app_view_application.js' %}"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
{% endcompress %}

{% include "app_manager/partials/xpathValidator.html" %}
{% include 'hqmedia/partials/multimedia_js.html' %}
{% compress js %}
<script src="{% static 'hqmedia/js/uploaders.js' %}"></script>
<script src="{% static 'app_manager/js/nav_menu_media_common.js' %}"></script>
<script src="{% static 'app_manager/js/app_manager_media.js' %}"></script>
<script src="{% static 'app_manager/js/nav_menu_media.js' %}"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,16 @@
<script src="{% static 'app_manager/js/details/detail_tab_nodeset.js' %}"></script>
<script src="{% static 'app_manager/js/details/graph_config.js' %}"></script>
{% endcompress %}
{% if request|toggle_enabled:"CASE_DETAIL_PRINT" %}
{% compress js %}
<script src="{% static "hqmedia/js/hqmediauploaders.js" %}"></script>
<script src="{% static 'hqmedia/js/media_reference_models.js' %}"></script>
{% endcompress %}
{% endif %}
{% compress js %}
<script src="{% static 'app_manager/js/modules/module_view.js' %}"></script>
<script src="{% static 'app_manager/js/modules/case_list_setting.js' %}"></script>
{% endcompress %}
{% include "app_manager/partials/xpathValidator.html" %}
{% endblock %}
{% block js-inline %}{{ block.super }}
{% include 'hqmedia/partials/multimedia_js.html' %}
{% compress js %}
<script src="{% static 'hqmedia/js/uploaders.js' %}"></script>
<script src="{% static 'hqmedia/js/media_reference_models.js' %}"></script>
<script src="{% static 'app_manager/js/nav_menu_media_common.js' %}"></script>
<script src="{% static 'app_manager/js/app_manager_media.js' %}"></script>
<script src="{% static 'app_manager/js/nav_menu_media.js' %}"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
{% include "app_manager/partials/xpathValidator.html" %}
{% endblock %}
{% block js-inline %}{{ block.super }}
{% include 'hqmedia/partials/multimedia_js.html' %}
{% compress js %}
<script src="{% static 'hqmedia/js/uploaders.js' %}"></script>
<script src="{% static 'app_manager/js/nav_menu_media_common.js' %}"></script>
<script src="{% static 'app_manager/js/app_manager_media.js' %}"></script>
<script src="{% static 'app_manager/js/modules/module_view_report.js' %}"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@
'data-hqmediapath': path,
href: href
},
click: triggerUpload,
event: {
click: triggerUpload,
mediaUploadComplete: uploadComplete
}
">
Expand All @@ -129,8 +129,6 @@
</a>
</script>

{% include 'hqmedia/partials/multimedia_js.html' %}

<script type="text/html" id="CommcareSettings.widgets.text">
<span>
<input type="text" class="col-sm-6 form-control" autocomplete="off" data-bind="
Expand Down
2 changes: 1 addition & 1 deletion corehq/apps/hqadmin/views/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def _get_branches_merged_into_autostaging(cwd=None):
def _get_submodules():
"""
returns something like
['corehq/apps/hqmedia/static/hqmedia/MediaUploader', ...]
['submodules/commcare-translations', 'submodules/django-digest-src', ...]
"""
import sh
git = sh.git.bake(_tty_out=False)
Expand Down
7 changes: 0 additions & 7 deletions corehq/apps/hqmedia/controller.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.template.loader import render_to_string
from django.urls import reverse
from django.utils.translation import gettext_noop


Expand Down Expand Up @@ -35,18 +34,12 @@ def supported_files(self):
"""
raise NotImplementedError("You must specify a list of supported files for this uploader.")

@property
def processing_url(self):
from corehq.apps.hqmedia.views import MultimediaUploadStatusView
return reverse(MultimediaUploadStatusView.urlname)

@property
def js_options(self):
options = {
'allowCloseDuringUpload': True,
'fileFilters': self.supported_files,
'uploadURL': self.destination,
'processingURL': self.processing_url,
'uploadParams': self.upload_params,
'licensingParams': self.licensing_params,
}
Expand Down
1 change: 0 additions & 1 deletion corehq/apps/hqmedia/static/hqmedia/MediaUploader
Submodule MediaUploader deleted from 1038b4
21 changes: 0 additions & 21 deletions corehq/apps/hqmedia/static/hqmedia/js/hqmediauploaders.js

This file was deleted.

29 changes: 14 additions & 15 deletions corehq/apps/hqmedia/static/hqmedia/js/media_reference_models.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ hqDefine("hqmedia/js/media_reference_models", [
'knockout',
'underscore',
'hqwebapp/js/assert_properties',
'hqmedia/js/hqmediauploaders',
'hqmedia/js/uploaders',
'hqwebapp/js/initial_page_data',
], function (
$,
Expand All @@ -13,9 +13,7 @@ hqDefine("hqmedia/js/media_reference_models", [
mediaUploaders,
initialPageData
) {
var HQMediaUploaders = mediaUploaders.get();

function BaseMediaReference(ref) {
function BaseMediaReference(ref, uploader_slug) {
'use strict';
var self = {};

Expand All @@ -27,7 +25,11 @@ hqDefine("hqmedia/js/media_reference_models", [
self.path = ref.path;
self.type_icon = ref.icon_class;

self.upload_controller = null; // override
self.slug = uploader_slug;
self.upload_controller = null;
if (self.slug) {
self.upload_controller = mediaUploaders.uploaderPreset(self.slug);
}

// for matching
self.is_matched = ko.observable(false);
Expand Down Expand Up @@ -74,7 +76,6 @@ hqDefine("hqmedia/js/media_reference_models", [
};

self.triggerUpload = function () {
self.upload_controller.resetUploader();
self.upload_controller.currentReference = self;
if (self.upload_controller) {
self.upload_controller.uploadParams = {
Expand Down Expand Up @@ -103,17 +104,17 @@ hqDefine("hqmedia/js/media_reference_models", [
self.uploadComplete = function (trigger, event, data) {
if (data && !data.errors.length) {
self.setObjReference(data.ref);
self.upload_controller.updateUploadFormUI();
}
};

return self;
}

function ImageReference(ref) {
function ImageReference(ref, uploader_slug) {
'use strict';
var self = {};
self = BaseMediaReference(ref);
self.upload_controller = HQMediaUploaders['hqimage'];
self = BaseMediaReference(ref, uploader_slug || "hqimage");
self.preview_template = "image-preview-template";
self.thumb_url = ko.computed(function () {
return (self.url()) ? self.url() + "?thumb=50" : "";
Expand All @@ -125,23 +126,21 @@ hqDefine("hqmedia/js/media_reference_models", [
ImageReference.prototype = Object.create(BaseMediaReference.prototype);
ImageReference.prototype.constructor = ImageReference;

function AudioReference(ref) {
function AudioReference(ref, uploader_slug) {
'use strict';
var self = {};
self = BaseMediaReference(ref);
self.upload_controller = HQMediaUploaders['hqaudio'];
self = BaseMediaReference(ref, uploader_slug || "hqaudio");
self.preview_template = "audio-preview-template";
return self;
}

AudioReference.prototype = Object.create(BaseMediaReference.prototype);
AudioReference.prototype.constructor = AudioReference;

function VideoReference(ref) {
function VideoReference(ref, uploader_slug) {
'use strict';
var self = {};
self = BaseMediaReference(ref);
self.upload_controller = HQMediaUploaders['hqvideo'];
self = BaseMediaReference(ref, uploader_slug || "hqvideo");
self.preview_template = "video-preview-template";
return self;
}
Expand Down
Loading

0 comments on commit 745ee5a

Please sign in to comment.