Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSJ-852] divestment history in convict #735

Closed
wants to merge 46 commits into from

Conversation

Arahir
Copy link
Collaborator

@Arahir Arahir commented Apr 10, 2024

No description provided.

cmarcoin and others added 12 commits April 2, 2024 13:57
Evolution poste réu des ambassadeurs: pour un probationnaire donné, s’il
est lié à un ou des TJ, ce sont seulement eux qui peuvent valider le
dessaisissement. S’il n’est pas lié à des TJ c’est son ou ses SPIPs qui
doivent le faire. Même si le le SPIP n’a pas son mot a dire, il est
quand même prévenu.
—> Proposition : Le SPIP est passé en automatiquement validé s’il n’a
pas de réponse à donner.
@Arahir Arahir changed the base branch from develop to feature/divestment April 10, 2024 16:51
app/models/organization_divestment.rb Show resolved Hide resolved
app/controllers/organization_divestments_controller.rb Outdated Show resolved Hide resolved

@organization_divestment.accept
handle_divestment_state
end

def refuse
def refuse(comment = nil)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ca vaudrait sans doute le coup au minimum de séparer en plusieurs services : OrganizationDivestmentAcceptationService et même chose pour le refus.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Et peut être qu'ensuite on pourrait les clarifier un peu avec des sous méthodes systématiques pour chaque étape. Ex:

return_unless_pending
update_if_comment
refuse_divestment
etc.

app/services/divestment_state_service.rb Outdated Show resolved Hide resolved
# resource_class.with_less_stuff
# end
# end
def scoped_resource
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il y a besoin de ça pourquoi par curiosité ? Pour la state_machine ? C'est pas géré nativement ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Et aussi, il n'y a pas tous ces statuts sur les divestments

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pour voir les states accesibles, state_machine a vehicle.state_paths.to_states aussi

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c'est pour gerer l'ordre d'affichage des resources

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

j'ai rien trouvé d'autre dans administrate

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Et pour les autres commentaires sur le filtrage par state dispo et le fait qu'il y ait moins de states que ça dans divestment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

si tu envisage de ne pas hardcodé les values, je peux essayer mais c'est pas trivial

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sisi, je t'ai mis la méthode mise à dispo par la gem state machines :) vehicle.state_paths.to_states

app/mailers/user_mailer.rb Outdated Show resolved Hide resolved
app/mailers/user_mailer.rb Show resolved Hide resolved
@@ -27,7 +37,7 @@ def divestment_refused
@organization_divestment = params[:organization_divestment]
@comment = @organization_divestment.comment
@current_user = params[:current_user]
@convict = divestment.convict
@convict = @divestment.convict
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a besoin de variables pour tout ça (@comment, @convict, @user) ? Peut être qu'on peut seulement setté les ressources principales ici

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je sais pas je check dans le html correspondant

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bin même si elles sont dans le html tu peux faire @divestment.convict dans le html aussi :) C'est plutôt une bonne pratique de ne pas multiplier les variables d'instance :)

@@ -12,25 +12,31 @@ class OrganizationDivestment < ApplicationRecord
.where(organization_divestments: { state: 'pending' }, divestments: { state: 'pending' })
}

scope :reminders_due, lambda {
where(state: 'pending')
.where('last_reminder_email_at IS NULL OR last_reminder_email_at <= ?', 5.days.ago)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pour le 5.days.ago peut être mettre le delai dans une constance ?!

return false unless @organization_divestment.pending? && @divestment.pending?
def accept(comment = nil)
ActiveRecord::Base.transaction do
return false unless @organization_divestment.unanswered? && @divestment.pending?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pas possible de gérer ça via des validations?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

j'y reflechi

# rubocop:disable Metrics/CyclomaticComplexity
def refuse(comment = nil)
ActiveRecord::Base.transaction do
return false unless @organization_divestment.unanswered? && @divestment.pending?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cf commentaires de l'accept

app/services/divestment_state_service.rb Show resolved Hide resolved
@@ -46,17 +56,17 @@ def handle_undecided_divestment
return unless @divestment.refused?

@divestment.organization_divestments.where(state: :pending).each do |organization_divestment|
organization_divestment.ignore
organization_divestment.update(comment: 'orga divestment ignored because divestment was refused')
organization_divestment.ignore! # Assuming ignore! is a method you implement that can raise exceptions on failure
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi ce commentaire ?

@@ -25,6 +25,12 @@
subject(:service) { DivestmentStateService.new(tj_organization_divestment, admin) }

describe 'accept divestment' do
it 'handle comment' do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On est un peu light en tests non ?! 😇

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tu rajouterai quoi comme test parce que j'ai l'impression d'avoir fait le tour des cas interessants

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ce serait cool qu'on ait des tests de features sur tout le processus, pas simplement sur la creation d'un dessaisissement par exemple :)

Et sinon je dirai qu'une bonne première approche serait de tester ce que j'ai repéré comme petits bugs lors de ma review produit :) On peut déjà commencer comme ça si ça te dit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants