Commit a8715f59
Changed files (6)
app
controllers
admin
models
views
admin
photos
users
my
shared
app/controllers/admin/users_controller.rb
@@ -5,7 +5,7 @@ module Admin
end
def show
- @user = User.find(params[:id])
+ @user = User.includes(creations: :photos).find(params[:id])
end
end
end
app/models/user.rb
@@ -11,6 +11,7 @@ class User < ActiveRecord::Base
has_many :tutorials, :dependent => :destroy
has_many :activities, dependent: :destroy
has_many :comments, dependent: :destroy
+ has_many :user_sessions, dependent: :destroy
has_and_belongs_to_many :interests, :join_table => 'users_interests', :autosave => true
has_one :avatar
acts_as_tagger
app/views/admin/photos/index.html.erb
@@ -10,10 +10,8 @@
<th>id</th>
<th>processing</th>
<th>filename</th>
- <th>original</th>
<th>content type</th>
<th>geolocation</th>
- <th>sha256</th>
<th>created</th>
<th>updated</th>
</tr>
@@ -24,10 +22,8 @@
<td><%= link_to photo.id, admin_photo_path(photo.id) %></td>
<td><%= photo.image_processing %></td>
<td><%= photo.image %></td>
- <td><%= photo.original_filename %></td>
<td><%= photo.content_type %></td>
<td><%= photo.latitude %> <%= photo.longitude %></td>
- <td><%= photo.sha256 %></td>
<td><%= time_ago_in_words(photo.created_at) %> ago</td>
<td><%= time_ago_in_words(photo.updated_at) %> ago</td>
</tr>
app/views/admin/users/_index.html.erb
@@ -1,7 +1,6 @@
<table class="table table-striped table-condensed">
<thead>
<tr>
- <td>signins</td>
<td>cakes</td>
<td>name</td>
<td>email</td>
@@ -14,7 +13,6 @@
<tbody>
<%- @users.each do |user| %>
<tr>
- <td><%= user.sign_in_count %></td>
<td><%= user.creations_count %></td>
<td><%= link_to user.name, admin_user_path(user) %></td>
<td><%= mail_to user.email %></td>
app/views/admin/users/show.html.erb
@@ -17,15 +17,85 @@
<%= render partial: "my/shared/my_nav" %>
</div>
<div class="span10">
- <h1><%= @user.name %></h1>
- <%= debug @user %>
- </div>
-</div>
-<!--
-<div class="row-fluid">
- <div style="overflow:hidden;height:500px;width:600px;">
- <div id="map-canvas" style="height:500px;width:600px;"></div>
- <style> img{max-width:none!important;background:none!important} </style>
+ <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>city</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><%= @user.city %></td>
+ <td><%= link_to @user.website %></td>
+ <td><%= @user.twitter %></td>
+ <td><%= link_to @user.facebook %></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <h2>sessions</h2>
+ <table class="table table-striped table-condensed">
+ <thead>
+ <tr>
+ <th>ip</th>
+ <th>user agent</th>
+ <th>accessed at</th>
+ <th>revoked at</th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ <%- @user.user_sessions.each do |user_session| %>
+ <tr>
+ <td><%= link_to user_session.user.name, admin_user_path(user_session.user) %></td>
+ <td><%= user_session.ip %></td>
+ <td><%= user_session.user_agent %></td>
+ <td><%= time_ago_in_words(user_session.accessed_at) %></td>
+ <td><%= time_ago_in_words(user_session.revoked_at) if user_session.revoked_at %></td>
+ <td><%= link_to "Revoke", admin_session_path(user_session), method: :delete, class: 'btn btn-danger' %></td>
+ </tr>
+ <% end %>
+ </tbody>
+ </table>
+
+ <h2>cakes</h2>
+ <table class="table table-striped">
+ <thead>
+ <th></th>
+ <th>Name</th>
+ <th>Description</th>
+ </thead>
+ <tbody>
+ <% @user.creations.each_with_index do |creation, index| %>
+ <% cache creation do %>
+ <tr>
+ <td>
+ <%= link_to creation_path(creation) do %>
+ <%= image_tag creation.primary_image.url_for(:thumb), class: 'thumbnail', style: "width:65px;" %>
+ <% end %>
+ </td>
+ <td><%= creation.name %></td>
+ <td>
+ <%= creation.story %>
+ <%= creation.tags.map(&:name) if creation.tags.any? %>
+ </td>
+ </tr>
+ <% end %>
+ <% end %>
+ </tbody>
+ </table>
+
+ <div style="overflow:hidden;height:500px;width:600px;">
+ <div id="map-canvas" style="height:500px;width:600px;"></div>
+ <style> img{max-width:none!important;background:none!important} </style>
+ </div>
</div>
</div>
--->