petities/petitions.eu

View on GitHub
app/views/petitions/_list_item.html.slim

Summary

Maintainability
Test Coverage

- id = petition.id

= link_to petition_path(petition), class: 'petition-overview-image-container' do
  - if petition.image
    = image_tag petition.image.upload.url(:listing), class: 'petition-overview-image'
  - else
    canvas id="chartContainer#{id}" data={chartid: id, chartdata: "chartData#{id}", chartlabels: "chartLabels#{id}"} class='petition-overview-image chart-canvas' style="background-color: #bcf9c7; height: 200px;"
    - data, labels = petition.redis_history_chart_json 35
    javascript:
      window.chartData#{id} = #{raw data},
      window.chartLabels#{id} = #{raw labels};

div.petition-overview-info-container
  h2.petition-overview-info-title
    = link_to petition_path(petition) do
    = petition.name
  div.petitions-counter class=(petition.is_hot? ? 'hot-item' : '')
    - unless petition.get_count.zero?
      = number_with_delimiter(petition.get_count)

  - if petition.last_sig_update
    div.petition-overview-info-time= distance_of_time_in_words(petition.last_sig_update, Time.now)