Skip to content

Commit 28acdfd

Browse files
authored
Merge pull request #4452 from betagouv/dev
2019-10-29-01
2 parents 83900b4 + c8da5a2 commit 28acdfd

25 files changed

Lines changed: 205 additions & 103 deletions

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ gem 'aasm'
44
gem 'actiontext', git: 'https://github.com/kobaltz/actiontext.git', branch: 'archive', require: 'action_text' # Port of ActionText to Rails 5
55
gem 'active_link_to' # Automatically set a class on active links
66
gem 'active_model_serializers'
7-
gem 'activestorage-openstack'
7+
gem 'activestorage-openstack', git: 'https://github.com/fredZen/activestorage-openstack.git', branch: 'frederic/fix_upload_signature'
88
gem 'administrate'
99
gem 'after_party'
1010
gem 'anchored'

Gemfile.lock

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
GIT
2+
remote: https://github.com/fredZen/activestorage-openstack.git
3+
revision: c71d5107a51701eab9d9267dd0000e6c1cf3e39a
4+
branch: frederic/fix_upload_signature
5+
specs:
6+
activestorage-openstack (0.5.0)
7+
fog-openstack (~> 1.0)
8+
marcel
9+
mime-types
10+
rails (~> 5.2.0)
11+
112
GIT
213
remote: https://github.com/kobaltz/actiontext.git
314
revision: ef59c4ba99d1b7614dd47f5a294eef553224db88
@@ -64,11 +75,6 @@ GEM
6475
actionpack (= 5.2.2.1)
6576
activerecord (= 5.2.2.1)
6677
marcel (~> 0.3.1)
67-
activestorage-openstack (1.0.0)
68-
fog-openstack (~> 1.0)
69-
marcel
70-
mime-types
71-
rails (<= 6)
7278
activesupport (5.2.2.1)
7379
concurrent-ruby (~> 1.0, >= 1.0.2)
7480
i18n (>= 0.7, < 2)
@@ -711,7 +717,7 @@ DEPENDENCIES
711717
actiontext!
712718
active_link_to
713719
active_model_serializers
714-
activestorage-openstack
720+
activestorage-openstack!
715721
administrate
716722
after_party
717723
anchored

app/assets/images/icons/add.svg

Lines changed: 1 addition & 0 deletions
Loading

app/assets/stylesheets/new_design/icons.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,16 @@
7979
background-image: image-url("icons/lock.svg");
8080
}
8181

82+
&.add {
83+
background-image: image-url("icons/add.svg");
84+
margin-left: -5px;
85+
margin-right: 0px;
86+
}
87+
8288
&.justificatif {
8389
background-image: image-url("icons/justificatif.svg");
8490
}
8591

86-
8792
&.printer {
8893
background-image: image-url("icons/printer.svg");
8994
}

app/controllers/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def sendinblue_config
250250
payload: {
251251
DS_SIGN_IN_COUNT: current_user&.sign_in_count,
252252
DS_CREATED_AT: current_administrateur&.created_at,
253-
DS_ACTIVE: current_administrateur&.active,
253+
DS_ACTIVE: current_administrateur&.active?,
254254
DS_ID: current_administrateur&.id,
255255
DS_GESTIONNAIRE_ID: current_instructeur&.id,
256256
DS_ROLES: current_user_roles

app/controllers/instructeurs/dossiers_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def personnes_impliquees
4949
@previous_following_instructeurs_emails = previous_followers.pluck(:email)
5050
@avis_emails = dossier.avis.includes(:instructeur).map(&:email_to_display)
5151
@invites_emails = dossier.invites.map(&:email)
52-
@potential_recipients = procedure.defaut_groupe_instructeur.instructeurs.reject { |g| g == current_instructeur }
52+
@potential_recipients = dossier.groupe_instructeur.instructeurs.reject { |g| g == current_instructeur }
5353
end
5454

5555
def send_to_instructeurs

app/controllers/root_controller.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ def administration
1717
end
1818

1919
def patron
20-
description = 'aller voir le super site : https://demarches-simplifiees.fr'
20+
description = 'Aller voir le super site : https://demarches-simplifiees.fr'
2121

2222
all_champs = TypeDeChamp.type_champs
23-
.map { |name, _| TypeDeChamp.new(type_champ: name, private: false, libelle: name, description: description, mandatory: true) }
23+
.map { |name, _| TypeDeChamp.new(type_champ: name, private: false, libelle: name.humanize, description: description, mandatory: true) }
2424
.map.with_index { |type_de_champ, i| type_de_champ.champ.build(id: i) }
2525

2626
all_champs
2727
.filter { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:header_section) }
28-
.each { |champ| champ.type_de_champ.libelle = 'un super titre de section' }
28+
.each { |champ| champ.type_de_champ.libelle = 'Un super titre de section' }
2929

3030
all_champs
3131
.filter { |champ| [TypeDeChamp.type_champs.fetch(:drop_down_list), TypeDeChamp.type_champs.fetch(:multiple_drop_down_list)].include?(champ.type_champ) }
@@ -39,6 +39,16 @@ def patron
3939
champ.value = '["option B", "option C"]'
4040
end
4141

42+
all_champs
43+
.filter { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:repetition) }
44+
.each do |champ_repetition|
45+
libelles = ['Prénom', 'Nom'];
46+
champ_repetition.champs << libelles.map.with_index do |libelle, i|
47+
text_tdc = TypeDeChamp.new(type_champ: :text, private: false, libelle: libelle, description: description, mandatory: true)
48+
text_tdc.champ.build(id: all_champs.length + i)
49+
end
50+
end
51+
4252
type_champ_values = {
4353
TypeDeChamp.type_champs.fetch(:date) => '2016-07-26',
4454
TypeDeChamp.type_champs.fetch(:datetime) => '26/07/2016 07:35',
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
module ActiveStorage
2+
# Wraps an ActiveStorage::Service to route direct upload and direct download URLs through our proxy,
3+
# thus avoiding exposing the storage provider’s URL to our end-users.
4+
class Service::DsProxyService < SimpleDelegator
5+
attr_reader :wrapped
6+
7+
def self.build(wrapped:, configurator:, **options)
8+
new(wrapped: configurator.build(wrapped))
9+
end
10+
11+
def initialize(wrapped:)
12+
@wrapped = wrapped
13+
super(wrapped)
14+
end
15+
16+
def url(*args)
17+
url = wrapped.url(*args)
18+
publicize(url)
19+
end
20+
21+
def url_for_direct_upload(*args)
22+
url = wrapped.url_for_direct_upload(*args)
23+
publicize(url)
24+
end
25+
26+
private
27+
28+
def object_for(key, &block)
29+
blob_url = url(key)
30+
if block_given?
31+
request = Typhoeus::Request.new(blob_url)
32+
request.on_headers do |response|
33+
if response.code != 200
34+
raise Fog::OpenStack::Storage::NotFound.new
35+
end
36+
end
37+
request.on_body do |chunk|
38+
yield chunk
39+
end
40+
request.run
41+
else
42+
response = Typhoeus.get(blob_url)
43+
if response.success?
44+
response
45+
else
46+
raise Fog::OpenStack::Storage::NotFound.new
47+
end
48+
end
49+
end
50+
51+
def publicize(url)
52+
search = %r{^https://[^/]+/v1/AUTH_[a-f0-9]{32}}
53+
replace = 'https://static.demarches-simplifiees.fr'
54+
url.gsub(search, replace)
55+
end
56+
end
57+
end

app/models/administrateur.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def registration_state
5656
end
5757

5858
def invitation_expired?
59-
!active && !user.reset_password_period_valid?
59+
!active? && !user.reset_password_period_valid?
6060
end
6161

6262
def self.reset_password(reset_password_token, password)
@@ -66,10 +66,6 @@ def self.reset_password(reset_password_token, password)
6666
reset_password_token: reset_password_token
6767
})
6868

69-
if administrateur && administrateur.errors.empty?
70-
administrateur.update_column(:active, true)
71-
end
72-
7369
administrateur
7470
end
7571

@@ -84,4 +80,8 @@ def instructeur
8480
def can_be_deleted?
8581
dossiers.state_instruction_commencee.none? && procedures.none?
8682
end
83+
84+
def active?
85+
user.last_sign_in_at.present?
86+
end
8787
end

app/models/instructeur.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,10 @@ def notifications_for_dossier(dossier)
110110
end
111111

112112
def notifications_for_procedure(procedure, scope)
113-
procedure
114-
.defaut_groupe_instructeur.dossiers
113+
target_groupes = groupe_instructeurs.where(procedure: procedure)
114+
115+
Dossier
116+
.where(groupe_instructeur: target_groupes)
115117
.send(scope) # :en_cours or :termine or :not_archived (or any other Dossier scope)
116118
.merge(followed_dossiers)
117119
.with_notifications

0 commit comments

Comments
 (0)