Commit 832550cd

mo khan <mo@mokhan.ca>
2014-10-20 01:51:36
clean up the admin/users#show page.
1 parent fd6e72e
Changed files (3)
app/controllers/admin/users_controller.rb
@@ -10,7 +10,7 @@ module Admin
     end
 
     def show
-      @user = repository.includes(creations: :photos).find(params[:id])
+      @user = repository.includes(creations: [:photos, :tags]).find(params[:id])
     end
 
     def update
@@ -22,7 +22,7 @@ module Admin
     private
 
     def secure_params
-      params.require(:user).permit(:name, :email, :city, :website, :twitter, :facebook)
+      params.require(:user).permit(:name, :email, :city, :full_address, :website, :twitter, :facebook)
     end
 
     attr_reader :repository
app/views/admin/users/_edit_modal.html.erb
@@ -19,6 +19,13 @@
         <span class="help-inline"></span>
       </div>
     </div>
+    <div class="control-group">
+      <%= f.label :full_address, class: 'control-label' %>
+      <div class="controls">
+        <%= f.text_field :full_address %>
+        <span class="help-inline"></span>
+      </div>
+    </div>
     <div class="control-group">
       <%= f.label :city, class: 'control-label' %>
       <div class="controls">
app/views/admin/users/show.html.erb
@@ -1,29 +1,30 @@
+<%= provide(:search_path, admin_users_path) %>
+
 <div class="row-fluid">
   <div class="span2">
     <%= render partial: "my/shared/my_nav" %>
   </div>
   <div class="span10">
-    <h1> <%= avatar_for(@user, size: 24) %> <%= @user.name %></h1>
-    <table class="table table-striped table-condensed">
-      <thead>
-        <tr>
-          <th>name</th>
-          <th>email</th>
-          <th>website</th>
-          <th>twitter</th>
-          <th>facebook</th>
-        </tr>
-      </thead>
-      <tbody>
-        <tr>
-          <td><%= link_to @user.name, admin_user_path(@user) %></td>
-          <td><%= mail_to @user.email %></td>
-          <td><%= link_to @user.website %></td>
-          <td><%= @user.twitter %></td>
-          <td><%= link_to @user.facebook %></td>
-        </tr>
-      </tbody>
-    </table>
+    <h1><%= link_to @user.name, profile_path(@user) %> <small>(<a href="#edit-user-modal-<%= @user.id %>" role="button" data-toggle="modal">edit</a>)</small></h1>
+    <%= render partial: 'edit_modal', locals: { user: @user } %>
+    <div class="row">
+      <div class="span3">
+        <%= avatar_for(@user) %>
+      </div>
+      <div class="span8">
+        <p>name: <%= link_to @user.name, admin_user_path(@user) %></p>
+        <p>email: <%= mail_to @user.email %></p>
+        <p>address: <%= mail_to @user.full_address %></p>
+        <p>city: <%= mail_to @user.city %></p>
+        <p>website: <%= link_to @user.website, @user.website if @user.website %></p>
+        <p>twitter: <%= @user.twitter %></p>
+        <p>facebook: <%= link_to @user.facebook, @user.facebook if @user.facebook %></p>
+        <p>reset password token: <%= @user.reset_password_token %></p>
+        <p>reset password sent at: <%= @user.reset_password_sent_at %></p>
+        <p>created at: <%= @user.created_at %></p>
+        <p>updated at: <%= @user.updated_at %></p>
+      </div>
+    </div>
 
     <h2>sessions</h2>
     <table class="table table-striped table-condensed">
@@ -58,7 +59,7 @@
         <th>Description</th>
       </thead>
       <tbody>
-      <% @user.creations.each_with_index do |creation, index| %>
+      <%- @user.creations.each_with_index do |creation, index| %>
         <% cache creation do %>
         <tr>
           <td>
@@ -76,5 +77,21 @@
       <% end %>
       </tbody>
     </table>
+
+    <h2>tutorials</h2>
+    <table class="table table-striped">
+      <thead>
+        <th>Heading</th>
+        <th>Url</th>
+      </thead>
+      <tbody>
+      <%- @user.tutorials.each_with_index do |tutorial, index| %>
+        <tr>
+          <td><%= link_to tutorial.heading, tutorial_path(tutorial) %></td>
+          <td><%= tutorial.description %></td>
+        </tr>
+      <% end %>
+      </tbody>
+    </table>
   </div>
 </div>