Skip to content

Commit

Permalink
refacto : suppression de tout le mailing, les invites et modification…
Browse files Browse the repository at this point in the history
… de la création de user via account_requests (#81)
  • Loading branch information
Lelievre-david authored Dec 9, 2024
1 parent 543f805 commit ab98f1c
Show file tree
Hide file tree
Showing 57 changed files with 244 additions and 2,434 deletions.
3 changes: 0 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ gem 'blueprinter'
# Soft deletes for ActiveRecord
gem 'discard'

# Mailjet Ruby wrapper
gem 'mailjet', '~> 1.5', '>= 1.5.4'

# Simple, efficient background processing for Ruby
gem 'sidekiq', '~> 6.2'

Expand Down
30 changes: 5 additions & 25 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ GEM
discard (1.3.0)
activerecord (>= 4.2, < 8)
docile (1.4.1)
domain_name (0.6.20240107)
doorkeeper (5.7.1)
railties (>= 5)
doorkeeper-i18n (5.2.7)
Expand Down Expand Up @@ -185,9 +184,6 @@ GEM
rake
globalid (1.2.1)
activesupport (>= 6.1)
http-accept (1.7.0)
http-cookie (1.0.7)
domain_name (~> 0.5)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
io-console (0.7.2)
Expand All @@ -200,26 +196,18 @@ GEM
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.1)
loofah (2.22.0)
loofah (2.23.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
mailjet (1.7.11)
activesupport (>= 5.0.0)
rack (>= 1.4.0)
rest-client (>= 2.1.0)
yajl-ruby
marcel (1.0.4)
method_source (1.1.0)
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0903)
mini_mime (1.1.5)
mini_portile2 (2.8.7)
mini_portile2 (2.8.8)
minitest (5.25.1)
msgpack (1.7.2)
mustache (1.1.1)
Expand All @@ -232,9 +220,8 @@ GEM
timeout
net-smtp (0.5.0)
net-protocol
netrc (0.11.0)
nio4r (2.7.3)
nokogiri (1.16.7)
nokogiri (1.17.0)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
oj (3.16.6)
Expand Down Expand Up @@ -291,9 +278,9 @@ GEM
activesupport (>= 4.2)
choice (~> 0.2.0)
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.6.0)
rails-html-sanitizer (1.6.1)
loofah (~> 2.21)
nokogiri (~> 1.14)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
railties (7.2.1.2)
actionpack (= 7.2.1.2)
activesupport (= 7.2.1.2)
Expand All @@ -313,11 +300,6 @@ GEM
regexp_parser (2.9.2)
reline (0.5.10)
io-console (~> 0.5)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.3.9)
rspec (3.13.0)
rspec-core (~> 3.13.0)
Expand Down Expand Up @@ -408,7 +390,6 @@ GEM
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
yajl-ruby (1.4.3)
zeitwerk (2.6.18)

PLATFORMS
Expand All @@ -433,7 +414,6 @@ DEPENDENCIES
faker (~> 2.7)
fetcheable_on_api (~> 0.4.1)
listen
mailjet (~> 1.5, >= 1.5.4)
oj (~> 3.10)
pg (~> 1.1)
pry-rails (~> 0.3.9)
Expand Down
6 changes: 0 additions & 6 deletions app/blueprinter/account_request_blueprint.rb

This file was deleted.

6 changes: 0 additions & 6 deletions app/blueprinter/invite_blueprint.rb

This file was deleted.

5 changes: 3 additions & 2 deletions app/blueprinter/request_blueprint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

class RequestBlueprint < Base
# Fields
fields :author_id, :handler_id, :plant_stage_id,
fields :handler_id, :plant_stage_id,
:name, :plant_name, :plant_stage_name, :status, :quantity, :due_date,
:comment, :temperature, :photoperiod
:comment, :temperature, :photoperiod,
:requester_first_name, :requester_last_name, :requester_email, :laboratory

field :plant_id do |request|
request.plant&.id
Expand Down
9 changes: 0 additions & 9 deletions app/blueprinter/token_blueprint.rb

This file was deleted.

9 changes: 0 additions & 9 deletions app/blueprinter/user_blueprint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,4 @@
class UserBlueprint < Base
# Fields
fields :email, :role, :first_name, :last_name, :laboratory

# Views
view :with_token do
association :access_tokens,
name: :token,
blueprint: TokenBlueprint do |user, _options|
user.access_tokens.last
end
end
end
61 changes: 0 additions & 61 deletions app/controllers/api/v1/account_requests_controller.rb

This file was deleted.

60 changes: 0 additions & 60 deletions app/controllers/api/v1/invites_controller.rb

This file was deleted.

21 changes: 0 additions & 21 deletions app/controllers/api/v1/passwords_controller.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,9 @@
# frozen_string_literal: true

class Api::V1::PasswordsController < ApiController
skip_before_action :doorkeeper_authorize!, only: %i[forgot reset]
skip_after_action :verify_authorized
skip_after_action :verify_policy_scoped

def forgot
user = User.find_by!(email: params[:email])

if user.forgot_password!
PasswordMailer.reset_password(user.id).deliver_later
head :no_content
else
render_error('an unknown error occured', code: 422)
end
end

def reset
user = User.find_by!(confirmation_token: params[:confirmation_token])

render_interactor_result(
Passwords::Reset.call(password_params: password_params.to_h, user:),
opts: { view: :with_token }
)
end

def update
unless current_user.authenticated?(params[:current_password])
return render_error('invalid current password', code: 403)
Expand Down
28 changes: 5 additions & 23 deletions app/controllers/api/v1/requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ def show

def create
authorize Request

request = Request.new(request_params.merge(author: current_user))
request = Request.new(request_params)

plant_attributes_from_params(request)

Expand All @@ -49,18 +48,6 @@ def create
end
end

def update
@request.assign_attributes(request_params)

plant_attributes_from_params(@request)

if @request.save
render json: @request.to_blueprint
else
render_validation_error(@request)
end
end

def accept
if @request.fire_state_event(:accept)
render json: @request.to_blueprint
Expand All @@ -78,16 +65,10 @@ def refuse
end

def cancel
if @request.accepted? && current_user.requester?
@request.fire_state_event(:cancel_request)
if @request.fire_state_event(:cancel)
render json: @request.to_blueprint
else
@request.fire_state_event(:cancel)
end

if @request.errors.present?
render_validation_error(@request)
else
render json: @request.to_blueprint
end
end

Expand Down Expand Up @@ -117,7 +98,8 @@ def set_request
def request_params
params.permit(
:plant_stage_id, :name, :plant_name, :plant_stage_name, :quantity, :due_date,
:comment, :temperature, :photoperiod
:comment, :temperature, :photoperiod, :requester_first_name, :requester_last_name,
:requester_email, :laboratory
)
end

Expand Down
Loading

0 comments on commit ab98f1c

Please sign in to comment.