Skip to content
This repository was archived by the owner on Jul 24, 2020. It is now read-only.

836 refactor reservations controller #882

Merged
merged 33 commits into from
Oct 12, 2014

Conversation

squidgetx
Copy link
Contributor

Resolves #836

Actually, I'm going to go and write tests for this so don't merge until then

@orenyk
Copy link
Contributor

orenyk commented Aug 5, 2014

Caught a small typo. I also think that it's somehow not putting a newline before the checkin / checkout notes headings, not sure why that is:

selection_018

# new_notes (from the form), procedure_kind (:checkin or :checkout) and array
# of string steps of procedures that were not followed for procedure_kind.
def make_notes(old_notes, new_notes, procedure_kind, procedures)
notes = old_notes ? old_notes + "\n\n" : ''
Copy link
Contributor

Choose a reason for hiding this comment

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

got it, it was this line. We need to add this back in down below.

@squidgetx
Copy link
Contributor Author

Fixed the whitespace issue just by prefixing the note header with a \n, and also converted the heading to markdown syntax

@squidgetx
Copy link
Contributor Author

Also, improved test coverage to actually test for the situations and urls where the checkout/checkin actions should trigger a redirect

@orenyk
Copy link
Contributor

orenyk commented Aug 5, 2014

It looks like every time you edit a reservation then it adds a header to the notes, even if no notes were entered. We should do one of two things:

  1. check to see if anything has been entered in the notes field and only append if it isn't empty
  2. add a summary of what was changed during the edit after the notes so that empty notes for an edit will still log what changed (I understand that this might be duplicating some of our logging functionality as in Auditing Actions #319, but it seems like our users are more likely to look at reservation notes than our auditing log for specific cases).

What do you think?

@squidgetx
Copy link
Contributor Author

Hard to say, at this point it seems notes has really grown into a powerful recordkeeper. Adjusting the logic to add notes only when new notes were added was trivial, but I do like the idea of also logging edit changes.

@orenyk
Copy link
Contributor

orenyk commented Aug 5, 2014

I think we should log edit changes; [nominally] immutable records of history seems really really useful. I think it falls under this issue, once we get that implemented and tested we can pull the whole thing in.

@orenyk
Copy link
Contributor

orenyk commented Aug 6, 2014

Ok, this now logs all edited parameters to the notes, along with any notes that were added. Let me know if this looks ok, then I think we're good to go!

@orenyk
Copy link
Contributor

orenyk commented Aug 6, 2014

Fixed some tests failing due to old nil values; let's get the fix for #906 in here (toggle :notes_unsent when appropriate and cherry-pick fixes to mailer views and rake messages) and confirm before merging.

@orenyk
Copy link
Contributor

orenyk commented Sep 29, 2014

Ok, I think this is finally ready to go. Once this is merged we can close #906 and #948 as well.

@orenyk orenyk added the pri: 3 label Sep 29, 2014
@coollog
Copy link
Contributor

coollog commented Oct 3, 2014

Line 141 was taken out. Is that notes variable necessary?

@orenyk
Copy link
Contributor

orenyk commented Oct 3, 2014

@coollog in which file? In general, you can add a comment to a file by clicking the blue plus next to the relevant line in the "Files Changed" view (hover over the line to see the button).

@@ -136,12 +130,8 @@ def update # for editing reservations; not for checkout or check-in
end

# save changes to database
@reservation.update_attributes(res)
if params[:new_notes]
@reservation.notes = @reservation.notes.to_s + "\n#### New notes added at #{Time.current.to_s(:long)} by #{current_user.name}\n" + params[:new_notes]
Copy link
Contributor

Choose a reason for hiding this comment

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

@orenyk I believe this is the L141 @coollog was referring to. I haven't reviewed the rest of the code so can't comment on its necessity, but wanted to note this lest I forget.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the late response, but yep! That's the file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea I figured it out afterwards and meant to update my comment. Do you mind
clarifying what you were asking?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was just wondering since this was completely taken out, if this notes was needed anywhere else.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. That functionality should be essentially replicated in the
replacement model method (i.e. we make note of when someone added notes to
a reservation with a header of some kind). I believe this falls under the
update method). Does that make sense?

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, sounds good.

Conflicts:
	app/views/admin_mailer/_reservation_note.html.erb
	db/schema.rb
	lib/tasks/mailman.rake
orenyk added a commit that referenced this pull request Oct 12, 2014
@orenyk orenyk merged commit a41213c into master Oct 12, 2014
@orenyk orenyk deleted the 836_refactor_reservations_controller branch October 27, 2014 15:29
@orenyk orenyk mentioned this pull request Nov 5, 2014
@orenyk orenyk mentioned this pull request Nov 13, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ReRefactor reservations controller
4 participants