kartoza / geonode

GeoNode is an open source platform that facilitates the creation, sharing, and collaborative use of geospatial data.
http://geonode.org/
GNU General Public License v3.0
8 stars 17 forks source link

Fix extension for file download in styles #541

Open boney-bun opened 5 years ago

boney-bun commented 5 years ago

fix #536

boney-bun commented 5 years ago

tested on safari, chrome and firefox.

the PR in action using safari: geonode-536-2

@lucernae i've tried the content_type of application/xml, but safari still automatically adding xml extention to the filename. so i define content_type of text/vnd.qt.qml for qml file. found this content type here: https://www.ietf.org/mail-archive/web/media-types/current/msg00465.html

@gubuntu @NyakudyaA can text/vnd.qt.qml be used to define qml file in content type?

gubuntu commented 5 years ago

afaik Qt-QML is a completely different animal.

though if it serves to add the .qml suffix maybe it is OK?

codecov[bot] commented 5 years ago

Codecov Report

Merging #541 into 2.8.x-qgis_server will decrease coverage by 7.95%. The diff coverage is n/a.

Impacted file tree graph

@@                  Coverage Diff                  @@
##           2.8.x-qgis_server     #541      +/-   ##
=====================================================
- Coverage              41.52%   33.56%   -7.96%     
=====================================================
  Files                    412      412              
  Lines                  29670    29670              
  Branches                3752     3752              
=====================================================
- Hits                   12319     9958    -2361     
- Misses                 16589    19083    +2494     
+ Partials                 762      629     -133
Impacted Files Coverage Δ
geonode/qgis_server/views.py 0% <ø> (-60.42%) :arrow_down:
geonode/qgis_server/context_processors.py 0% <0%> (-100%) :arrow_down:
geonode/qgis_server/urls.py 0% <0%> (-100%) :arrow_down:
...ent/commands/delete_orphaned_qgis_server_layers.py 0% <0%> (-100%) :arrow_down:
geonode/qgis_server/tests/test_qgis_settings.py 0% <0%> (-100%) :arrow_down:
geonode/qgis_server/tests/test_xml_utilities.py 0% <0%> (-100%) :arrow_down:
.../qgis_server/migrations/0003_auto_20170727_0509.py 0% <0%> (-100%) :arrow_down:
.../qgis_server/migrations/0005_auto_20170823_0341.py 0% <0%> (-100%) :arrow_down:
geonode/qgis_server/migrations/0001_initial.py 0% <0%> (-100%) :arrow_down:
geonode/qgis_server/admin/__init__.py 0% <0%> (-100%) :arrow_down:
... and 48 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ba48295...eff57a1. Read the comment docs.

codecov[bot] commented 5 years ago

Codecov Report

Merging #541 into 2.8.x-qgis_server will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@                Coverage Diff                 @@
##           2.8.x-qgis_server     #541   +/-   ##
==================================================
  Coverage              41.52%   41.52%           
==================================================
  Files                    412      412           
  Lines                  29670    29670           
  Branches                3752     3752           
==================================================
  Hits                   12319    12319           
  Misses                 16589    16589           
  Partials                 762      762
Impacted Files Coverage Δ
geonode/qgis_server/views.py 60.41% <ø> (ø) :arrow_up:
geonode/qgis_server/tests/test_views.py 99.28% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ba48295...eff57a1. Read the comment docs.

gubuntu commented 5 years ago

@boney-bun respond and fix

lucernae commented 5 years ago

For @gubuntu 's and @boney-bun 's comment:

@lucernae i've tried the content_type of application/xml, but safari still automatically adding xml extention to the filename. so i define content_type of text/vnd.qt.qml for qml file. found this content type here: https://www.ietf.org/mail-archive/web/media-types/current/msg00465.html

The original mime type follows from QGIS definition taken here: https://github.com/qgis/QGIS/blob/master/rpm/sources/qgis-mime.xml

There should be a way to force Safari to save the filename with QML extension (with mime type application/xml). This can be from Javascript file, communicated in the request header, or from download attribute.

afaik Qt-QML is a completely different animal. though if it serves to add the .qml suffix maybe it is OK?

Yes, I think this is last resort though. If above suggestion still not feasible :(.