Merge pull request #5863 from betagouv/dev

2021-01-27-02
This commit is contained in:
Paul Chavard 2021-01-27 18:05:57 +01:00 committed by GitHub
commit cbb3b36e52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 18 deletions

View file

@ -71,7 +71,7 @@ class Champs::CarteController < ApplicationController
def cadastres_features_collection(feature_collection)
coordinates = feature_collection[:features].filter do |feature|
feature[:properties][:source] == GeoArea.sources.fetch(:selection_utilisateur) && feature[:geometry]['type'] == 'Polygon'
feature[:properties][:source] == GeoArea.sources.fetch(:selection_utilisateur) && feature[:geometry] && feature[:geometry]['type'] == 'Polygon'
end.map do |feature|
feature[:geometry]['coordinates'][0].map { |(lng, lat)| { 'lng' => lng, 'lat' => lat } }
end

View file

@ -346,6 +346,11 @@ module Users
if champs_params[:dossier]
@dossier.assign_attributes(champs_params[:dossier])
# FIXME in some cases a removed repetition bloc row is submitted.
# In this case it will be trated as a new records and action will fail.
@dossier.champs.filter(&:repetition?).each do |champ|
champ.champs = champ.champs.filter(&:persisted?)
end
if @dossier.champs.any?(&:changed?)
@dossier.last_champ_updated_at = Time.zone.now
end

View file

@ -6,11 +6,17 @@ class TitreIdentiteWatermarkJob < ApplicationJob
def perform(blob)
blob.open do |file|
watermark = resize_watermark(file)
if watermark.present?
processed = watermark_image(file, watermark)
blob.metadata[:watermark] = true
blob.upload(processed)
blob.save
else
blob.metadata[:watermark_invalid] = true
blob.save
end
end
end
@ -28,6 +34,7 @@ class TitreIdentiteWatermarkJob < ApplicationJob
def resize_watermark(file)
metadata = image_metadata(file)
if metadata[:width].present? && metadata[:height].present?
width = [metadata[:width], MAX_IMAGE_SIZE].min * SCALE
height = [metadata[:height], MAX_IMAGE_SIZE].min * SCALE
diagonal = Math.sqrt(height**2 + width**2)
@ -39,6 +46,7 @@ class TitreIdentiteWatermarkJob < ApplicationJob
.rotate(-angle, background: :transparent)
.call
end
end
def image_metadata(file)
read_image(file) do |image|

View file

@ -170,7 +170,6 @@
"type_contrat_prive",
"nom_commune",
"code_commune",
"siren_siret",
"libelle_academie",
"code_academie",
"libelle_nature",

View file

@ -9,6 +9,7 @@
%tr
%th.libelle Lidentifiant de letablissement :
%td= champ.data['identifiant_de_l_etablissement']
- if champ.data['siren_siret'].present?
%tr
%th.libelle SIREN/SIRET :
%td= champ.data['siren_siret']