openaustralia/publicwhip

View on GitHub
app/views/users/subscriptions.html.haml

Summary

Maintainability
Test Coverage
- content_for :title, "Your subscriptions"
- set_meta_tags description: "Keep an eye on the policies that matter to you"

- content_for :header do
  .section-header.clearfix
    .page-header.container
      %h1= yield :title
      %p.lead Keep an eye on the policies that matter to you

.row
  .col-md-8
    - if @user.watched_policies.any?
      %p
        You have subscribed to receive emails whenever the following
        = pluralize(@user.watched_policies.size, "policy")
        or
        = @user.watched_policies.size == 1 ? "its" : "their"
        related divisions are updated:
      %ul.subscriptions-list.subscriptions-list-removals.object-list-compact.list-unstyled
        - @user.watched_policies.each do |policy|
          %li.object-item{id: "policy" + policy.id.to_s}
            = link_to capitalise_initial_character(policy.name_with_for), policy
            = button_to watch_policy_path(policy), class: "btn btn-link btn-sm btn-unsubscribe", form_class: "object-secondary-inline" do
              %i.fi-x
              %span.hidden-xs
                unsubscribe
    - else
      %p Get email alerts whenever the policies that interest you are updated or voted on. Subscribe on the policy’s page.

    =link_to "View all policies", policies_path, class: 'btn btn-default btn-sm'