NUBIC/ncs_navigator_core — pull request #266 by normalocity (2013-07-19 21:16:54+00:00)
Title: 3285 eventless contacts

I'll try to summarize this:

The goal is to allow the creation of contacts independent of events in the UI itself (eventless contacts stored from imported data was already supported). This is in contrast to the current functionality where all events created in the UI must be associated with an event, and therefore indirectly, to a participant.

#### Controller changes

* `app/controllers/contacts_controller.rb#create`
* only handles `@requires_consent` if an event is involved
* when creating a contact, it redirects to the **decision page** if **there is** an event
* when creating a contact, it redirects to the **person** view if **there is not** an event
* `#event_for_person` - change the two-outcome conditional (either the `Event` from the specified `params[:event_id]` into a three-outcome case statement in order to handle the eventless contact scenario

* `app/controllers/participants_controller.rb`
* rename `@events_and_contacts` to `@events_and_contact_links`

* `app/controllers/people_controller.rb`
* made an `#events_and_contact_links` method, similar to the one from the `participants_controller` so that the view can display contacts on a `Person` (new functionality) - previously you could only create a contact on an `Event`, and therefore it was always tied, indirectly, to a participant
* eager loads `Person => ContactLinks` and passes it to the view

#### View changes

* Partials
* Split `app/views/contacts/_form_fields.html.haml` into a `_form_fields_with_event` and `_form_fields_without_event` partial, which presents a slightly different view in each of those two cases
* the `_form_fields_without_event` partial also sets up an explicit `-1` value for `event_id` to indicate to the controller that this is a contact without an event
* other view changes...
* conditional logic to render the proper partials in the associated situations (a contact with an event vs. a contact without an event)
* `app/views/people/_events_and_contacts.html.haml` - added a "Create contact without event" link

#### Test changes

* `spec/controllers/contacts_controller_spec.rb` - coverage of how the setting of `@event` has changed
* `spec/controllers/participants_controller_spec.rb` - simple change to reflect the renaming of a variable