oneclickorgs/one-click-orgs

View on GitHub
app/views/one_click/coop/dashboard.html.haml

Summary

Maintainability
Test Coverage
%h2 Your Dashboard

- @elections = co.elections.where(:state => :open)
- if @elections.present?
  .section
    - @elections.each do |election|
      %p An online election for new Directors is currently open.
      - if election.ballots.where(:member_id => current_user.id).present?
        %p You have already cast your vote in this election.
      - else
        %p= link_to("View the election and cast your vote.", new_election_ballot_path(:election_id => election))

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

.left.dashboard
  .section.meetings
    %h3 Meetings

    - if @upcoming_meeting.present?
      %h4 Next meeting:
      = content_tag_for(:div, @upcoming_meeting) do
        %p.datetime
          = @upcoming_meeting.happened_on.to_s(:short)
          %br
          = @upcoming_meeting.start_time
        %p.details
          %strong= @upcoming_meeting.class.name.underscore.humanize.titlecase
          %br
          = @upcoming_meeting.venue
          %br
          = link_to("See agenda & details", @upcoming_meeting)
      - if @upcoming_meetings_count
        %p.auxiliary
          = link_to("#{@upcoming_meetings_count} more upcoming", meetings_path)
    -else
      %p No upcoming meetings.

    - if @last_meeting.present?
      %h4 Last meeting:
      = content_tag_for(:div, @last_meeting) do
        %p.datetime
          = @last_meeting.happened_on.to_s(:short)
          %br
          = @last_meeting.start_time
        %p.details
          %strong= @last_meeting.class.name.underscore.humanize.titlecase
          %br
          = link_to("See minutes", meeting_path(@last_meeting))
    - if can?(:create, GeneralMeeting)
      .left= link_button("Create new", :url => new_general_meeting_path)
    %p.right= link_to("See all meetings", meetings_path)
    %br.clear

  .section.membership_and_shares
    %h3 Membership and shares
    - if @members_and_shares_tasks.present?
      %ul.tasks
        - @members_and_shares_tasks.each do |task|
          = content_tag_for(:li, task) do
            = render :partial => 'tasks/task', :locals => {:task => task}
    - else
      %p No outstanding issues.
    %br.clear

.right.dashboard
  .section.proposals
    %h3 Proposals
    - if @open_proposals_without_vote.present?
      %ul.proposals
        - @open_proposals_without_vote.each do |proposal|
          = content_tag_for(:li, proposal) do
            %h4 New proposal
            %p.title.left= proposal.title
            - if proposal.is_a?(BoardResolution)
              .action.right= link_button("Vote", :url => board_resolution_path(proposal))
            - else
              .action.right= link_button("Vote", :url => resolution_path(proposal))
            %br.clear
    - else
      %p No proposals currently open for voting.
    - if can?(:create, Resolution)
      .left= link_button("Create new", :url => new_resolution_path)
    - elsif can?(:create, ResolutionProposal)
      .left= link_button("Suggest new", :url => new_resolution_proposal_path)
    %p.right= link_to("See all proposals", proposals_path)
    %br.clear