diff --git a/app/controllers/admin/contact_congress_controller.rb b/app/controllers/admin/contact_congress_controller.rb index 22657427..13e973d8 100644 --- a/app/controllers/admin/contact_congress_controller.rb +++ b/app/controllers/admin/contact_congress_controller.rb @@ -2,6 +2,12 @@ class Admin::ContactCongressController < Admin::IndexController before_filter :admin_login_required def index + @page_title = 'Contact Congress Configuration' @people = Person.where("title IS NOT NULL").order("title ASC, page_views_count DESC").all end + + def letters + @page_title = 'Contact Congress Letters' + @letters = ContactCongressLetter.order('created_at DESC').all.paginate(:per_page => 4, :page => params[:page]) + end end \ No newline at end of file diff --git a/app/models/viewable_object.rb b/app/models/viewable_object.rb index e1827bf6..6955e339 100644 --- a/app/models/viewable_object.rb +++ b/app/models/viewable_object.rb @@ -1,5 +1,4 @@ module ViewableObject -#class ViewableObject < ActiveRecord::Base def self.included(includer) includer.class_eval do has_many :object_aggregates, :as => :aggregatable @@ -20,7 +19,7 @@ def views(seconds = 0) return @attributes['view_count'] if @attributes['view_count'] if seconds <= 0 - page_views_count + @attributes['page_views_count'].nil? ? object_aggregates.sum(:page_views_count) : @attributes['page_views_count'].to_i else object_aggregates.sum(:page_views_count, :conditions => ["date >= ?", seconds.ago]) end diff --git a/app/views/admin/contact_congress/letters.html.haml b/app/views/admin/contact_congress/letters.html.haml new file mode 100644 index 00000000..21537d41 --- /dev/null +++ b/app/views/admin/contact_congress/letters.html.haml @@ -0,0 +1,34 @@ +.padding + %h2 Contact Congress Letters + + %table + %tr + %th Date + %th User + %th Privacy + %th District + %th To/Responses + %th Bill/Position + %th # comments + %th # page views + - @letters.each do |l| + %tr + %td= link_to l.created_at.strftime("%b %d, %Y"), contact_congress_letter_path(l) + %td= l.user.nil? ? 'No User' : link_to(l.user.login, user_profile_path(l.user.login)) + %td= l.privacy + %td= l.user.nil? ? "?" : l.user.my_district + %td + - l.formageddon_threads.each do |t| + = t.formageddon_recipient.name + ( + = (t.formageddon_letters.size - 1) + ) + %br + %td + = link_to l.bill.typenumber, bill_path(l.bill) + \: + = l.disposition + %td= l.comments.size + %td= l.views + + = will_paginate @letters \ No newline at end of file diff --git a/app/views/admin/index/index.html.erb b/app/views/admin/index/index.html.erb index 956c8394..b358d168 100644 --- a/app/views/admin/index/index.html.erb +++ b/app/views/admin/index/index.html.erb @@ -51,7 +51,10 @@
  • <%= link_to 'Data Stats', '/admin/stats/data' %>

  • <%= link_to 'Partner Email Signups', '/admin/stats/partner_email' %>
  • - +
    +

    Contact Congress

    +
  • <%= link_to 'Manage Recipient Configuration', '/admin/contact_congress' %> +
  • <%= link_to 'View Sent Letters', '/admin/contact_congress/letters' %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index 3b2a2e76..3425dc26 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -113,6 +113,7 @@ end match 'contact_congress' => 'contact_congress#index' + match 'contact_congress/letters' => 'contact_congress#letters' end match '/:controller(/:action(/:id))', :controller => /admin\/[^\/]+/