OSDN Git Service

add user and delete flip flags
authoryasushiito <yas@pen-chan.jp>
Thu, 8 Mar 2012 09:30:48 +0000 (18:30 +0900)
committeryasushiito <yas@pen-chan.jp>
Thu, 8 Mar 2012 09:30:48 +0000 (18:30 +0900)
26 files changed:
app/controllers/user_registrations_controller.rb [moved from app/controllers/author_registrations_controller.rb with 51% similarity]
app/models/author.rb
app/models/panel_picture.rb
app/models/user.rb [new file with mode: 0644]
app/views/panel_pictures/index.html.erb
app/views/panel_pictures/list.html.erb
app/views/users/browse.html.erb [new file with mode: 0644]
app/views/users/confirmations/new.html.erb [moved from app/views/authors/confirmations/new.html.erb with 100% similarity]
app/views/users/index.html.erb [new file with mode: 0644]
app/views/users/list.html.erb [new file with mode: 0644]
app/views/users/mailer/confirmation_instructions.html.erb [moved from app/views/authors/mailer/confirmation_instructions.html.erb with 100% similarity]
app/views/users/mailer/reset_password_instructions.html.erb [moved from app/views/authors/mailer/reset_password_instructions.html.erb with 100% similarity]
app/views/users/mailer/unlock_instructions.html.erb [moved from app/views/authors/mailer/unlock_instructions.html.erb with 100% similarity]
app/views/users/passwords/edit.html.erb [moved from app/views/authors/passwords/edit.html.erb with 100% similarity]
app/views/users/passwords/new.html.erb [moved from app/views/authors/passwords/new.html.erb with 100% similarity]
app/views/users/registrations/edit.html.erb [moved from app/views/authors/registrations/edit.html.erb with 100% similarity]
app/views/users/registrations/new.html.erb [moved from app/views/authors/registrations/new.html.erb with 100% similarity]
app/views/users/sessions/new.html.erb [moved from app/views/authors/sessions/new.html.erb with 100% similarity]
app/views/users/shared/_links.erb [moved from app/views/authors/shared/_links.erb with 100% similarity]
app/views/users/show.html.erb [new file with mode: 0644]
app/views/users/unlocks/new.html.erb [moved from app/views/authors/unlocks/new.html.erb with 100% similarity]
config/routes.rb
db/migrate/20111206091950_create_authors.rb [new file with mode: 0644]
db/migrate/20111206113803_create_panel_pictures.rb
db/migrate/20120306231650_devise_create_users.rb [moved from db/migrate/20111206091950_devise_create_authors.rb with 85% similarity]
spec/models/user_spec.rb [new file with mode: 0644]

@@ -1,4 +1,4 @@
-class AuthorRegistrationsController < Devise::RegistrationsController
+class UserRegistrationsController < Devise::RegistrationsController
   protected\r
 \r
   def after_sign_up_path_for(resource)\r
index 2341a9f..7148ef0 100644 (file)
@@ -1,14 +1,7 @@
 class Author < ActiveRecord::Base
   has_one :artist
+  belongs_to :user
   
-  # Include default devise modules. Others available are:
-  # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
-  devise :database_authenticatable, :registerable,
-         :recoverable, :rememberable, :trackable, :token_authenticatable, :validatable#, :confirmable
-
-  # Setup accessible (or protected) attributes for your model
-  attr_accessible :id, :name, :password, :password_confirmation, :remember_me #, :email
-
   before_save do |r|
     r.name = 'no name' if r.name.blank?
   end
@@ -17,16 +10,6 @@ class Author < ActiveRecord::Base
     Artist.find_by_author(self) != nil
   end
   
-  def create_token
-    self.ensure_authentication_token
-    self.save
-  end
-  
-  def delete_token
-    self.authentication_token = nil
-    self.save
-  end
-  
   def step2 n
     self.name = n
     self.save
index 0bc6734..eaff130 100644 (file)
@@ -3,7 +3,7 @@ class PanelPicture < ActiveRecord::Base
   belongs_to :resource_picture
   
   def flip
-    res = (self.flipv == 0 ? '' : 'v') + (self.fliph == 0 ? '' : 'h')
+    res = (self.height < 0 ? '' : 'v') + (self.width == 0 ? '' : 'h')
     res += '/' unless res.empty?
     res
   end
diff --git a/app/models/user.rb b/app/models/user.rb
new file mode 100644 (file)
index 0000000..90958af
--- /dev/null
@@ -0,0 +1,22 @@
+class User < ActiveRecord::Base
+  has_one :author
+  
+  # Include default devise modules. Others available are:
+  # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
+  devise :database_authenticatable, :registerable,
+         :recoverable, :rememberable, :trackable, :token_authenticatable, :validatable#, :confirmable
+
+  # Setup accessible (or protected) attributes for your model
+  attr_accessible :id, :name, :password, :password_confirmation, :remember_me , :email
+
+  def create_token
+    self.ensure_authentication_token
+    self.save
+  end
+  
+  def delete_token
+    self.authentication_token = nil
+    self.save
+  end
+  
+end
index 9f44380..49f866c 100644 (file)
@@ -12,7 +12,6 @@
     <th>y</th>
     <th>z</th>
     <th>t</th>
-    <th>flip</th>
     <th>updated_at</th>
   </tr>
 
@@ -28,7 +27,6 @@
     <td><%= panel_picture.t %></td>
     <td><%= panel_picture.width %></td>
     <td><%= panel_picture.height %></td>
-    <td><%= panel_picture.flip %></td>
     <td><%= panel_picture.updated_at %></td>
   </tr>
 <% end %>
index 1edf398..f87feff 100644 (file)
@@ -12,8 +12,6 @@
     <th>t</th>
     <th>Width</th>
     <th>Height</th>
-    <th>flipv</th>
-    <th>fliph</th>
     <th>created_at</th>
     <th>updated_at</th>
   </tr>
@@ -30,8 +28,6 @@
     <td><%= panel_picture.t %></td>
     <td><%= panel_picture.width %></td>
     <td><%= panel_picture.height %></td>
-    <td><%= panel_picture.flipv %></td>
-    <td><%= panel_picture.fliph %></td>
     <td><%= panel_picture.created_at %></td>
     <td><%= panel_picture.updated_at %></td>
   </tr>
diff --git a/app/views/users/browse.html.erb b/app/views/users/browse.html.erb
new file mode 100644 (file)
index 0000000..86d0e79
--- /dev/null
@@ -0,0 +1,38 @@
+<p id="notice"><%= notice %></p>
+
+<p>
+  <b>name:</b>
+  <%= h(@author.name) %>
+</p>
+
+<p>
+  <b>email:</b>
+  <%= h(@author.email) %>
+</p>
+
+<p>
+  <b>sign_in_count:</b>
+  <%= @author.sign_in_count %>
+</p>
+
+<p>
+  <b>current_sign_in_at:</b>
+  <%= @author.current_sign_in_at %>
+</p>
+
+<p>
+  <b>last_sign_in_at:</b>
+  <%= @author.last_sign_in_at %>
+</p>
+
+<p>
+  <b>current_sign_in_ip:</b>
+  <%= @author.current_sign_in_ip %>
+</p>
+
+<p>
+  <b>last_sign_in_ip:</b>
+  <%= @author.last_sign_in_ip %>
+</p>
+
+<%= link_to 'Back', :action => :list %>
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb
new file mode 100644 (file)
index 0000000..5691bbb
--- /dev/null
@@ -0,0 +1,13 @@
+<h1>Listing system_pictures</h1>
+
+<table>
+  <tr>
+    <th>Ext</th>
+  </tr>
+
+<% @authors.each do |author| %>
+  <tr>
+    <td><%= link_to h(author.name), :action => :show, :id => author.id %></td>
+  </tr>
+<% end %>
+</table>
diff --git a/app/views/users/list.html.erb b/app/views/users/list.html.erb
new file mode 100644 (file)
index 0000000..a559979
--- /dev/null
@@ -0,0 +1,31 @@
+<h1>Listing authors</h1>
+
+<table>
+  <tr>
+    <th>id</th>
+    <th>name</th>
+    <th>email</th>
+    <th>sign_in_count</th>
+    <th>current_sign_in_at</th>
+    <th>last_sign_in_at</th>
+    <th>current_sign_in_ip</th>
+    <th>last_sign_in_ip</th>
+    <th>created_at</th>
+    <th>updated_at</th>
+  </tr>
+
+<% @authors.each do |author| %>
+  <tr>
+    <td><%= link_to author.id, :action => :show, :id => author.id %></td>
+    <td><%= h(author.name) %></td>
+    <td><%= h(author.email) %></td>
+    <td><%= author.sign_in_count %></td>
+    <td><%= author.current_sign_in_at %></td>
+    <td><%= author.last_sign_in_at %></td>
+    <td><%= author.current_sign_in_ip %></td>
+    <td><%= author.last_sign_in_ip %></td>
+    <td><%= author.created_at %></td>
+    <td><%= author.updated_at %></td>
+  </tr>
+<% end %>
+</table>
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
new file mode 100644 (file)
index 0000000..464be42
--- /dev/null
@@ -0,0 +1,8 @@
+<p id="notice"><%= notice %></p>
+
+<p>
+  <b>name:</b>
+  <%= h(@author.name) %>
+</p>
+
+<%= link_to 'Back', :controller => 'authors' %>
index 8a92433..a06d818 100644 (file)
@@ -1,10 +1,23 @@
 Pettanr::Application.routes.draw do
 
+  devise_for :users, :controllers => { :registrations => "user_registrations" }
   devise_for :admins
-  devise_for :authors, :controllers => { :registrations => "author_registrations" }
 
   match 'original_pictures/:id(.:format)/refresh' => 'original_pictures#refresh'
 
+  resources :authors do
+    collection do
+      get :index
+      get :show
+      post :create
+      get :list
+      get :browse
+    end
+    member do
+      put :update
+      delete :destroy
+    end
+  end
   resources :artists do
     collection do
       get :index
diff --git a/db/migrate/20111206091950_create_authors.rb b/db/migrate/20111206091950_create_authors.rb
new file mode 100644 (file)
index 0000000..c2dc72f
--- /dev/null
@@ -0,0 +1,17 @@
+class CreateAuthors < ActiveRecord::Migration
+  def change
+    create_table(:authors) do |t|
+      t.string :name\r
+      t.integer :user_id, :null => false, :default => 0\r
+
+      t.timestamps
+    end
+
+    add_index :authors, :email,                :unique => true
+    add_index :authors, :reset_password_token, :unique => true
+    add_index :authors, :confirmation_token,   :unique => true
+    # add_index :authors, :unlock_token,         :unique => true
+    add_index :authors, :authentication_token, :unique => true
+  end
+
+end
index 2011abb..e05cbbf 100644 (file)
@@ -10,8 +10,6 @@ class CreatePanelPictures < ActiveRecord::Migration
       t.integer :t, :null => false, :default => 1
       t.integer :width, :null => false
       t.integer :height, :null => false
-      t.integer :flipv, :null => false, :default => 0
-      t.integer :fliph, :null => false, :default => 0
 
       t.timestamps
     end
@@ -1,7 +1,6 @@
-class DeviseCreateAuthors < ActiveRecord::Migration
+class DeviseCreateUsers < ActiveRecord::Migration
   def change
-    create_table(:authors) do |t|
-      t.string :name\r
+    create_table(:users) do |t|
       t.database_authenticatable :null => false
       t.recoverable
       t.rememberable
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
new file mode 100644 (file)
index 0000000..44032b4
--- /dev/null
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe User do
+  pending "add some examples to (or delete) #{__FILE__}"
+end