Commit 72eae761

mo khan <mo@mokhan.ca>
2014-05-16 22:33:32
add subscriptions controller to list all subscribed users.
1 parent 6ebea56
Changed files (4)
app
controllers
views
admin
config
app/controllers/admin/subscriptions_controller.rb
@@ -0,0 +1,9 @@
+module Admin
+  class SubscriptionsController < AdminController
+    def index
+      members =  Gibbon::API.lists.members({ id: '6ea750df21', status: 'subscribed', opts: { start: 0, limit: 100}})
+      @subscriptions = members["data"]
+      @total = members["total"]
+    end
+  end
+end
app/views/admin/shared/_admin_nav.html.erb
@@ -2,4 +2,5 @@
   <li><%= link_to "Users", admin_users_path %></li>
   <li><%= link_to "Jobs", admin_jobs_path %></li>
   <li><%= link_to "Activity", admin_activities_path %></li>
+  <li><%= link_to "Subscriptions", admin_subscriptions_path %></li>
 </ul>
app/views/admin/subscriptions/index.html.erb
@@ -0,0 +1,24 @@
+<div class="row-fluid">
+  <div class="span12">
+    <%= render :partial => 'admin/shared/admin_nav' %>
+    <h1>Subscriptions <small>(<%= @total %>)</small></h1>
+    <table class="table table-condensed">
+      <thead>
+        <tr>
+          <th></th>
+          <th>Email</th>
+          <th>Timestamp</th>
+        </tr>
+      </thead>
+      <tbody>
+      <% @subscriptions.each_with_index do |subscription, index| %>
+        <tr>
+        <td><%= index+1 %></td>
+        <td><%= subscription["email"] %></td>
+        <td><%= subscription["timestamp_signup"] %></td>
+      </tr>
+      </tbody>
+    <% end %>
+    </table>
+  </div>
+</div>
config/routes.rb
@@ -65,5 +65,6 @@ Cake::Application.routes.draw do
     resources :users, only: [:index]
     resources :jobs, only: [:index, :show]
     resources :activities, only: [:index]
+    resources :subscriptions, only: [:index]
   end
 end