[Presenter] Add a Suite Decorator
See: https://ieftimov.com/decorators-and-presenters for an explanation of what a presenter is and why we need one.
-
Create a SuiteDecorator and add it to /presenters
-
Move display methods from the suite model to the decorator
- name
- name_with_medical
- name_with_draws
- number_with_medical
- size_str (potentially? this may be a complex one to refactor since it's used in many different contexts)
-
Add the SuiteDecorator into GroupsController#show along with any other controllers that feed into views that will use these presenter methods (along with the following method you will be making)
-
add a helper method called "status_string" in the suites presenter that will replace the code block in
app/views/suites/show.rb
that deals with displaying the suite status. -- this code is currently in need of fixing so it will need slightly more complex logic than it currently has
<% if @suite.available? %>
Available
<% else %>
Unavailable
<% if !@suite.medical || policy(@suite).medical? %>
(Assigned to <%= link_to @group.name, group_path(@group) %>)
<% end %>
<% end %>
The new status_string
method should
- list available suites as available
- list unavailable suites as unavailable
- if the suite is not medical AND the group assigned to it is not drawless, show the group that it is assigned to and fix the link (group_path only works for drawless_groups- you need to use the link we have for groups with draws)
- if the suite IS medical OR the the group assigned to it is drawless, show just "Unavailable" if you are not an admin and the assigned group (with the relevant drawless group link) if you are an admin
Also add all relevant tests