Skip to content

Commit

Permalink
added contact congress admin page
Browse files Browse the repository at this point in the history
  • Loading branch information
opencongress committed Aug 15, 2011
1 parent 9422d57 commit c1e174f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
6 changes: 6 additions & 0 deletions app/controllers/admin/contact_congress_controller.rb
Expand Up @@ -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
3 changes: 1 addition & 2 deletions 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
Expand All @@ -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
Expand Down
34 changes: 34 additions & 0 deletions 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
5 changes: 4 additions & 1 deletion app/views/admin/index/index.html.erb
Expand Up @@ -51,7 +51,10 @@
<li><%= link_to 'Data Stats', '/admin/stats/data' %></li>
<br />
<li><%= link_to 'Partner Email Signups', '/admin/stats/partner_email' %></li>

<br />
<h3>Contact Congress</h3>
<li><%= link_to 'Manage Recipient Configuration', '/admin/contact_congress' %>
<li><%= link_to 'View Sent Letters', '/admin/contact_congress/letters' %>
<% end %>
</ul>
</div>
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -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\/[^\/]+/

Expand Down

0 comments on commit c1e174f

Please sign in to comment.