oneclickorgs/one-click-orgs

View on GitHub
app/views/directors/coop/index.html.haml

Summary

Maintainability
Test Coverage
%h2 Directors

- if @tasks.present?
  %h3 Notifications
  .section
    %ul.tasks
      - @tasks.each do |task|
        = content_tag_for(:li, task) do
          = render :partial => 'tasks/task', :locals => {:task => task}

- if can?(:create, Directorship) || can?(:create, Officership)
  .section
    - if can?(:create, Directorship)
      = link_button("Appoint new Director", :url => new_directorship_path)
    - if can?(:create, Officership)
      = link_button("Appoint new Officer", :url => new_officership_path)
    .clear

- if @directors.present?
  %p#download
    Download:
    %span.pdf.download
      = link_to 'PDF', directors_path(:format => 'pdf')

  .section.directors
    %ul.directors
      - @directors.each do |director|
        = content_tag_for(:li, director) do
          .directorship
            %p.name
              = image_tag("#{director.gravatar_url(24)}", :class => 'gravatar', :alt => "#{director.name}", :width => '24', :height => '24')
              = director.name
            - if director.directorship.elected_on
              %p.elected_on
                Appointed:
                = director.directorship.elected_on.to_s(:long)
            - if can?(:edit, director.directorship)
              .action
                = link_button("Retire", :url => edit_directorship_path(director.directorship))
            .clear
          .officership
            - if director.officership
              %p.title= director.officership.office_title
              - if can?(:edit, director.officership)
                .action
                  = link_button("Step down", :url => edit_officership_path(director.officership))
            - else
              %p.title No office
              - if can?(:create, Officership)
                .action
                  = form_tag(new_officership_path, {:method => :get, :class => 'button_to'}) do
                    = hidden_field_tag('officer_id', director.id)
                    = submit_tag('Appoint')
            .clear
          .clear

- if @unoccupied_offices.present?
  .section
    %h3 Unoccupied offices
    %ul.offices
      - @unoccupied_offices.each do |office|
        = content_tag_for(:li, office) do
          = office.title
          - if can?(:create, Officership)
            = link_button("Appoint", :url => new_officership_path(:office_id => office.id))
          .clear

- if can?(:create, Office)
  .section
    %h3 Create a new office
    = form_for(:office, :url => offices_path) do |form|
      %p
        = form.text_field(:title)
      %p
        = form.submit("Create")