diff --git a/app/controllers/champs/carte_controller.rb b/app/controllers/champs/carte_controller.rb index b94d8db57..0d5f58024 100644 --- a/app/controllers/champs/carte_controller.rb +++ b/app/controllers/champs/carte_controller.rb @@ -15,18 +15,26 @@ class Champs::CarteController < ApplicationController if geo_area.nil? geo_area = champ.geo_areas.build(source: params_source, properties: {}) - save_feature!(geo_area, create_params_feature) - end - render json: { feature: geo_area.to_feature }, status: :created + if save_feature(geo_area, create_params_feature) + render json: { feature: geo_area.to_feature }, status: :created + else + render json: { errors: geo_area.errors.full_messages }, status: :unprocessable_entity + end + else + render json: { feature: geo_area.to_feature }, status: :ok + end end def update champ = policy_scope(Champ).find(params[:champ_id]) geo_area = champ.geo_areas.find(params[:id]) - save_feature!(geo_area, update_params_feature) - head :no_content + if save_feature(geo_area, update_params_feature) + head :no_content + else + render json: { errors: geo_area.errors.full_messages }, status: :unprocessable_entity + end end def destroy @@ -66,13 +74,13 @@ class Champs::CarteController < ApplicationController end end - def save_feature!(geo_area, feature) + def save_feature(geo_area, feature) if feature[:geometry] geo_area.geometry = feature[:geometry] end if feature[:properties] geo_area.properties.merge!(feature[:properties]) end - geo_area.save! + geo_area.save end end diff --git a/app/graphql/schema.graphql b/app/graphql/schema.graphql index da40645a5..827e3ac83 100644 --- a/app/graphql/schema.graphql +++ b/app/graphql/schema.graphql @@ -374,7 +374,7 @@ type Demarche { """ Date de la publication. """ - datePublication: ISO8601DateTime! + datePublication: ISO8601DateTime """ L’état de dossier pour une démarche déclarative @@ -1131,7 +1131,8 @@ type Entreprise { } type File { - byteSize: Int! + byteSize: Int! @deprecated(reason: "Utilisez le champ `byteSizeBigInt` à la place.") + byteSizeBigInt: BigInt! checksum: String! contentType: String! filename: String! @@ -1588,6 +1589,11 @@ type Revision { Date de la création. """ dateCreation: ISO8601DateTime! + + """ + Date de la publication. + """ + datePublication: ISO8601DateTime id: ID! } diff --git a/app/graphql/types/demarche_type.rb b/app/graphql/types/demarche_type.rb index 9cf7b8e98..42aae2d43 100644 --- a/app/graphql/types/demarche_type.rb +++ b/app/graphql/types/demarche_type.rb @@ -24,7 +24,7 @@ module Types field :declarative, DossierDeclarativeState, "L’état de dossier pour une démarche déclarative", null: true, method: :declarative_with_state field :date_creation, GraphQL::Types::ISO8601DateTime, "Date de la création.", null: false, method: :created_at - field :date_publication, GraphQL::Types::ISO8601DateTime, "Date de la publication.", null: false, method: :published_at + field :date_publication, GraphQL::Types::ISO8601DateTime, "Date de la publication.", null: true, method: :published_at field :date_derniere_modification, GraphQL::Types::ISO8601DateTime, "Date de la dernière modification.", null: false, method: :updated_at field :date_depublication, GraphQL::Types::ISO8601DateTime, "Date de la dépublication.", null: true, method: :unpublished_at field :date_fermeture, GraphQL::Types::ISO8601DateTime, "Date de la fermeture.", null: true, method: :closed_at diff --git a/app/graphql/types/file.rb b/app/graphql/types/file.rb index 0fc4cf1bd..22a8e1afd 100644 --- a/app/graphql/types/file.rb +++ b/app/graphql/types/file.rb @@ -2,7 +2,8 @@ module Types class File < Types::BaseObject field :url, Types::URL, null: false field :filename, String, null: false - field :byte_size, Int, null: false + field :byte_size, Int, null: false, deprecation_reason: "Utilisez le champ `byteSizeBigInt` à la place." + field :byte_size_big_int, GraphQL::Types::BigInt, null: false, method: :byte_size field :checksum, String, null: false field :content_type, String, null: false diff --git a/app/graphql/types/revision_type.rb b/app/graphql/types/revision_type.rb index 3f1ef0847..372dbebb2 100644 --- a/app/graphql/types/revision_type.rb +++ b/app/graphql/types/revision_type.rb @@ -2,6 +2,7 @@ module Types class RevisionType < Types::BaseObject global_id_field :id field :date_creation, GraphQL::Types::ISO8601DateTime, "Date de la création.", null: false, method: :created_at + field :date_publication, GraphQL::Types::ISO8601DateTime, "Date de la publication.", null: true, method: :published_at field :champ_descriptors, [Types::ChampDescriptorType], null: false field :annotation_descriptors, [Types::ChampDescriptorType], null: false diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 27ceb25c5..0aa534ad3 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -248,10 +248,10 @@ class Procedure < ApplicationRecord state :close state :depubliee - event :publish, before: :before_publish, after: :after_publish do - transitions from: :brouillon, to: :publiee - transitions from: :close, to: :publiee - transitions from: :depubliee, to: :publiee + event :publish, before: :before_publish do + transitions from: :brouillon, to: :publiee, after: :after_publish + transitions from: :close, to: :publiee, after: :after_republish + transitions from: :depubliee, to: :publiee, after: :after_republish end event :close, after: :after_close do @@ -550,7 +550,7 @@ class Procedure < ApplicationRecord end def whitelist! - update_attribute('whitelisted_at', Time.zone.now) + touch(:whitelisted_at) end def closed_mail_template_attestation_inconsistency_state @@ -693,15 +693,21 @@ class Procedure < ApplicationRecord end def after_publish(canonical_procedure = nil) - update!(published_at: Time.zone.now, canonical_procedure: canonical_procedure, draft_revision: create_new_revision, published_revision: draft_revision) + update!(canonical_procedure: canonical_procedure, draft_revision: create_new_revision, published_revision: draft_revision) + touch(:published_at) + published_revision.touch(:published_at) + end + + def after_republish(canonical_procedure = nil) + touch(:published_at) end def after_close - update!(closed_at: Time.zone.now) + touch(:closed_at) end def after_unpublish - update!(unpublished_at: Time.zone.now) + touch(:unpublished_at) end def update_juridique_required diff --git a/app/models/procedure_revision.rb b/app/models/procedure_revision.rb index e4da229c8..42c646ee2 100644 --- a/app/models/procedure_revision.rb +++ b/app/models/procedure_revision.rb @@ -3,6 +3,7 @@ # Table name: procedure_revisions # # id :bigint not null, primary key +# published_at :datetime # created_at :datetime not null # updated_at :datetime not null # procedure_id :bigint not null diff --git a/app/services/serializer_service.rb b/app/services/serializer_service.rb index 04d816f3c..3ded29254 100644 --- a/app/services/serializer_service.rb +++ b/app/services/serializer_service.rb @@ -232,7 +232,7 @@ class SerializerService fragment FileFragment on File { filename checksum - byteSize + byteSize: byteSizeBigInt contentType } GRAPHQL diff --git a/app/views/manager/users/emails.html.erb b/app/views/manager/users/emails.html.erb index b6ef69f21..1b9991d72 100644 --- a/app/views/manager/users/emails.html.erb +++ b/app/views/manager/users/emails.html.erb @@ -93,7 +93,7 @@ https://www.demarches-simplifiees.fr/users/password/new Bien cordialement <% else %> -

Ce compte n’est pas activé. Vous pouvez lui <%= link_to('renvoyer l’email de confirmation', [:resend_confirmation_instructions, namespace, 'user'], method: :post, class: 'button') %>, puis un email.

+

Ce compte n’est pas activé. Vous pouvez lui <%= link_to('renvoyer l’email de confirmation', [:resend_confirmation_instructions, namespace, :user], method: :post, class: 'button') %>, puis un email.