redirect_to :controller => '/system', :action => 'start'
end
else
- if author_signed_in?
- @artist = if current_author.artist?
- current_author.artist
+ if user_signed_in?
+ @user = current_user
+ @author = @user.author
+ @artist = if @author and @author.artist?
+ @author.artist
else
- Artist.new author_id: current_author.id, email: current_author.email, name: current_author.name
+ Artist.new author_id: @author.id, email: @user.email, name: @author.name, default_license_id: 1
end
end
end
class ArtistsController < ApplicationController
- before_filter :authenticate_author!, :only => [:index, :show, :create, :update, :destroy]
+ before_filter :authenticate_user!, :only => [:index, :show, :create, :update, :destroy]
before_filter :authenticate_admin!, :only => [:list, :browse]
# GET /artists
class AuthorsController < ApplicationController
- before_filter :authenticate_author!, :only => [:index, :show]
+ before_filter :authenticate_user!, :only => [:index, :show]
before_filter :authenticate_admin!, :only => [:list, :browse]
def index
class BalloonTemplatesController < ApplicationController
- before_filter :authenticate_author!, :only => [:index, :show]
+ before_filter :authenticate_user!, :only => [:index, :show]
before_filter :authenticate_admin!, :only => [:list, :browse]
# GET /balloon_templates
class BalloonsController < ApplicationController
- before_filter :authenticate_author!, :only => [:index, :show]
+ before_filter :authenticate_user!, :only => [:index, :show]
before_filter :authenticate_admin!, :only => [:list, :browse]
# GET /balloons
class ComicsController < ApplicationController
- before_filter :authenticate_author!, :only => [:top, :index, :show, :play, :create, :update, :destroy]
+ before_filter :authenticate_user!, :only => [:top, :index, :show, :play, :create, :update, :destroy]
before_filter :authenticate_admin!, :only => [:list, :browse]
private
def treat_param comic
- comic.author_id = current_author.id
+ comic.author_id = @author.id
end
public
# PUT /comics/1.json
def update
@comic = Comic.find(params[:id])
- if @comic.own? current_author
+ if @comic.own? @author
respond_to do |format|
if @comic.update_attributes(params[:comic])
format.html { redirect_to @comic, notice: 'Comic was successfully updated.' }
# DELETE /comics/1.json
def destroy
@comic = Comic.find(params[:id])
- if @comic.own? current_author
+ if @comic.own? @author
@comic.destroy
respond_to do |format|
format.html { redirect_to comics_url }
class CommonLicensesController < ApplicationController
- before_filter :authenticate_author!, :only => [:index, :show]
+ before_filter :authenticate_user!, :only => [:index, :show]
before_filter :authenticate_admin!, :only => [:list, :browse, :new, :edit, :create, :update, :destroy]
# GET /common_licenses
class HomeController < ApplicationController
- before_filter :authenticate_author!, :only => [
+ before_filter :authenticate_user!, :only => [
:index, :show, :profile, :configure, :create_token, :delete_token, :step2, :save_step2, :step3, :save_step3,
:comic, :picture
]
end
def create_token
- @author = current_author
respond_to do |format|
- if @author.create_token
- format.html { redirect_to({:action => :configure}, {:notice => 'author token was successfully created.'}) }
+ if @user.create_token
+ format.html { redirect_to({:action => :configure}, {:notice => 'user token was successfully created.'}) }
else
format.html { render action: "auth_token" }
end
end
def delete_token
- current_author.delete_token
+ @user.delete_token
respond_to do |format|
format.html { redirect_to :action => :configure}
end
end
def step2
- @author = current_author
end
def save_step2
- @author = current_author
respond_to do |format|
if @author.step2(params[:author][:name])
a = if params[:step3].to_i == 1
end
def step3
- @artist = Artist.new :author_id => current_author.id, :name => current_author.name, :default_license_id => 1
end
def save_step3
- if current_author.artist?
+ if @author.artist?
redirect_to :action => :index
else
@artist = Artist.new params[:artist]
def comic
@comics = Comic.find(:all,
- :include => :author, :conditions => ['author_id = ?', current_author.id],
+ :include => :author, :conditions => ['author_id = ?', @author.id],
:order => 'updated_at desc', :limit => 20
)
end
def picture
- if current_author.artist?
+ if @author.artist?
@original_pictures = OriginalPicture.find(:all,
- :include => [:artist, :license, :resource_picture], :conditions => ['artist_id = ?', current_author.artist.id],
+ :include => [:artist, :license, :resource_picture], :conditions => ['artist_id = ?', @author.artist.id],
:order => 'updated_at', :limit => 20
)
class LicensesController < ApplicationController
- before_filter :authenticate_author!, :only => [:index, :show]
+ before_filter :authenticate_user!, :only => [:index, :show]
before_filter :authenticate_admin!, :only => [:list, :browse]
# GET /licenses
class OriginalLicensesController < ApplicationController
- before_filter :authenticate_author!, :only => [:index, :show, :new, :edit, :create, :update, :destroy]
+ before_filter :authenticate_user!, :only => [:index, :show, :new, :edit, :create, :update, :destroy]
before_filter :authenticate_admin!, :only => [:list, :browse]
# GET /original_licenses
# POST /original_licenses.json
def create
@original_license = OriginalLicense.new(params[:original_license])
- @original_license.artist_id = current_author.artist.id
+ @original_license.artist_id = @author.artist.id
respond_to do |format|
if @original_license.save_save
format.html { redirect_to @original_license, notice: 'Original license was successfully created.' }
class OriginalPicturesController < ApplicationController
- before_filter :authenticate_author!, :only => [:index, :show, :new, :edit, :create, :update, :destroy]
+ before_filter :authenticate_user!, :only => [:index, :show, :new, :edit, :create, :update, :destroy]
before_filter :authenticate_admin!, :only => [:list, :browse]
private
end
@original_picture = OriginalPicture.new
img = set_image params
- @original_picture.artist_id = current_author.artist.id
- @original_picture.license_id = current_author.artist.default_license_id
+ @original_picture.artist_id = @author.artist.id
+ @original_picture.license_id = @author.artist.default_license_id
respond_to do |format|
OriginalPicture.transaction do
return
end
@original_picture = OriginalPicture.find(params[:id])
- unless @original_picture.own? current_author
+ unless @original_picture.own? @author
respond_to do |format|
format.html { redirect_to @original_picture, notice: 'Failed! ' }
format.json { render json: @original_picture.errors, status: :unprocessable_entity }
return
end
@original_picture = OriginalPicture.find(params[:id])
- unless @original_picture.own? current_author
+ unless @original_picture.own? @author
respond_to do |format|
format.html { redirect_to @original_picture, notice: 'Failed! ' }
format.json { render json: @original_picture.errors, status: :unprocessable_entity }
class PanelPicturesController < ApplicationController
- before_filter :authenticate_author!, :only => [:index, :show]
+ before_filter :authenticate_user!, :only => [:index, :show]
before_filter :authenticate_admin!, :only => [:list, :browse]
# GET /panel_pictures
class PanelsController < ApplicationController
- before_filter :authenticate_author!, :only => [:index, :show, :create, :update, :destroy]
+ before_filter :authenticate_user!, :only => [:index, :show, :create, :update, :destroy]
before_filter :authenticate_admin!, :only => [:list, :browse]
private
def treat_param panel
- panel.author_id = current_author.id
+ panel.author_id = @author.id
end
public
# PUT /panels/1.json
def update
@panel = Panel.find(params[:id])
- if @panel.own? current_author
+ if @panel.own? @author
respond_to do |format|
Panel.transaction do
if params[:panel][:t] and params[:panel][:t].to_i != @panel.t
# DELETE /panels/1.json
def destroy
@panel = Panel.find(params[:id])
- if @panel.own? current_author
+ if @panel.own? @author
respond_to do |format|
Panel.transaction do
@panel.destroy_and_shorten
class ResourcePicturesController < ApplicationController
- before_filter :authenticate_author!, :only => [:index, :show]
+ before_filter :authenticate_user!, :only => [:index, :show]
before_filter :authenticate_admin!, :only => [:list, :browse]
# GET /resource_pictures
class SpeachBalloonsController < ApplicationController
- before_filter :authenticate_author!, :only => [:index, :show]
+ before_filter :authenticate_user!, :only => [:index, :show]
before_filter :authenticate_admin!, :only => [:list, :browse, :create, :update, :destroy]
private
class SpeachTemplatesController < ApplicationController
- before_filter :authenticate_author!, :only => [:index, :show]
+ before_filter :authenticate_user!, :only => [:index, :show]
before_filter :authenticate_admin!, :only => [:list, :browse]
# GET /speach_templates
class SpeachesController < ApplicationController
- before_filter :authenticate_author!, :only => [:index, :show]
+ before_filter :authenticate_user!, :only => [:index, :show]
before_filter :authenticate_admin!, :only => [:list, :browse]
# GET /speaches
class SystemPicturesController < ApplicationController
- before_filter :authenticate_author!, :only => [:index, :show]
+ before_filter :authenticate_user!, :only => [:index, :show]
before_filter :authenticate_admin!, :only => [:list, :browse, :create, :update, :destroy]
private
# Setup accessible (or protected) attributes for your model
attr_accessible :id, :name, :password, :password_confirmation, :remember_me , :email
+ before_create do |r|
+ r.build_author :name => 'no name'
+ end
+
def create_token
self.ensure_authentication_token
self.save
<h1><%= h @comic.title %></h1>
-<% if author_signed_in? -%>
- <% if @comic.own? current_author -%>
- <div>
- <p id="notice"><%= notice %></p>
- <p>
- <b>Title:</b>
- <%= h @comic.title %>
- </p>
- <p>
- <b>visible:</b>
- <%= @comic.visible %>
- </p>
- <p>
- <b>editable:</b>
- <%= @comic.editable %>
- </p>
- <%= link_to 'Destroy', @comic, confirm: 'Are you sure?', method: :delete %>
- </div>
- <% end -%>
+<% if @comic.own? @author -%>
+<div>
+ <p id="notice"><%= notice %></p>
+ <p>
+ <b>Title:</b>
+ <%= h @comic.title %>
+ </p>
+ <p>
+ <b>visible:</b>
+ <%= @comic.visible %>
+ </p>
+ <p>
+ <b>editable:</b>
+ <%= @comic.editable %>
+ </p>
+ <%= link_to 'Destroy', @comic, confirm: 'Are you sure?', method: :delete %>
+</div>
<% end -%>
<% @comic.panels.each do |panel| %>
<td><%= comic.author_id%></td>
<td><%= comic.updated_at %></td>
<td>
- <% if author_signed_in? -%>
- <% if comic.own? current_author -%>
+ <% if user_signed_in? -%>
+ <% if comic.own? @author -%>
<%= link_to 'Destroy', comic, confirm: 'Are you sure?', method: :delete %>
<% end -%>
<% end -%>
<h2>認証トークン</h2>
<div>
-あなたの認証トークンは<%= current_author.authentication_token %>です
+あなたの認証トークンは<%= @user.authentication_token %>です
</div>
<div>
- <% if current_author.authentication_token %>
+ <% if @user.authentication_token %>
<%= link_to 'delete token', :action => :delete_token %>
<% else %>
<%= link_to 'generate token', :action => :create_token %>
</div>
<h2>退会</h2>
<div>
- <%= link_to('退会する', {:controller => 'author_registrations', :action => :destroy, :id => current_author.id}, {:method => :delete}) %>
+ <%= link_to('退会する', {:controller => 'user_registrations', :action => :destroy, :id => @user.id}, {:method => :delete}) %>
</div>
-<h1><%= h(current_author.name) -%>(<%= h(current_author.email) -%>)</h1>
+<h1><%= h(@author.name) -%>(<%= h(@user.email) -%>)</h1>
<div>
<p>絵師活動</p>
-<% if current_author.artist? -%>
- <%= link_to h(current_author.artist.name), current_author.artist %>です
+<% if @author.artist? -%>
+ <%= link_to h(@author.artist.name), @author.artist %>です
<% else -%>
<p>まだ絵師登録していません。</p>
<p>登録する</p>
+ <%= render 'original_pictures/artist_register' %>
<% end -%>
</div>
<h1>ようこそ、ぺったんRへ</h1>
<div>
-<%= h(current_author.email) -%>さんはぺったんRで作家としてデビューしました。
+<%= h(@user.email) -%>さんはぺったんRで作家としてデビューしました。
今すぐにでも作品を作れますが、より良い活動をするために作家名を登録してください。
</div>
<%= form_for(:author, :url => {:controller => '/home', :action => :save_step2}) do |f| %>
<h1>ようこそ、ぺったんRへ</h1>
-<%= h(current_author.name) -%>さん
+<%= h(@author.name) -%>さん
<div>
<%= form_for(:artist, :url => {:controller => '/home', :action => :save_step3}) do |f| %>
<% if @artist.errors.any? %>
<a href="/">ぺったんR</a>
<div>
-<% if author_signed_in? %>
+<% if user_signed_in? %>
<%= link_to "my home", :controller => '/home' %>
<%= link_to "my comics", :controller => '/home', :action => :comic %>
<%= link_to "my pictures", :controller => '/home', :action => :picture %>
<%= link_to "config", :controller => '/home', :action => :configure %>
- <%= link_to "ログアウト", destroy_author_session_path, :method => :delete %>
+ <%= link_to "ログアウト", destroy_user_session_path, :method => :delete %>
<% else %>
- <%= link_to "ログイン", new_author_session_path %>
+ <%= link_to "ログイン", new_user_session_path %>
<% end %>
</div>
<div>
<a href="/">ぺったんR</a>
<div>
-<% if author_signed_in? %>
+<% if user_signed_in? %>
<%= link_to "my home", :controller => '/home' %>
- <%= link_to "ログアウト", destroy_author_session_path, :method => :delete %>
+ <%= link_to "ログアウト", destroy_user_session_path, :method => :delete %>
<% else %>
- <%= link_to "ログイン", new_author_session_path %>
+ <%= link_to "ログイン", new_user_session_path %>
<% end %>
</div>
<div>
-<% if author_signed_in? -%>
- <% if current_author.artist? -%>
+<% if user_signed_in? -%>
+ <% if @author.artist? -%>
<%= form_tag( {:action => "create"} , { :multipart => true }) do %>
<label for="file">File to Upload</label> <%= file_field_tag "original_picture[file]" %>
license
- <%= collection_select :original_picture, :license_id, License.all.map {|l| [l.name, l.id] }, :last, :first, :html => {:selected => current_author.artist.default_license_id} %>
+ <%= collection_select :original_picture, :license_id, License.all.map {|l| [l.name, l.id] }, :last, :first, :html => {:selected => @author.artist.default_license_id} %>
<%= submit_tag 'upload' -%>
<% end -%>
<% else -%>
<%= render 'artist_register' %>
<% end -%>
<% else -%>
- 素材を投稿するなら<%= link_to "ログイン", new_author_session_path %>
+ 素材を投稿するなら<%= link_to "ログイン", new_user_session_path %>
<% end -%>
<p>
<%= link_to '再生成', :action => :refresh, :id => @original_picture.id %>
</p>
-<% if @original_picture.own? current_author -%>
+<% if @original_picture.own? @author -%>
<p>
Replace picture
</p>
<p>
<%= link_to '再生成', :action => :refresh, :id => @original_picture.id %>
</p>
-<% if @original_picture.own? current_author -%>
+<% if @original_picture.own? @author -%>
<p>
Replace picture
</p>
Pettanr::Application.routes.draw do
- devise_for :users, :controllers => { :registrations => "user_registrations" }
+ devise_for :users , :controllers => { :registrations => "user_registrations" }
devise_for :admins
match 'original_pictures/:id(.:format)/refresh' => 'original_pictures#refresh'
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
+ add_index :authors, :user_id, :unique => true
end
end
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
+ add_index :users, :email, :unique => true
+ add_index :users, :reset_password_token, :unique => true
+ add_index :users, :confirmation_token, :unique => true
+ # add_index :users, :unlock_token, :unique => true
+ add_index :users, :authentication_token, :unique => true
end
end
#\r
# It's strongly recommended to check this file into your version control system.\r
\r
-ActiveRecord::Schema.define(:version => 20120102071851) do\r
+ActiveRecord::Schema.define(:version => 20120306231650) do\r
\r
create_table "admins", :force => true do |t|\r
t.string "email", :default => "", :null => false\r
t.string "name"\r
t.string "homepage_url"\r
t.string "api_url"\r
- t.integer "default_license_id"\r
+ t.integer "default_license_id", :default => 0, :null => false\r
t.datetime "crowled_at"\r
t.datetime "created_at"\r
t.datetime "updated_at"\r
\r
create_table "authors", :force => true do |t|\r
t.string "name"\r
- t.string "email", :default => "", :null => false\r
- t.string "encrypted_password", :limit => 128, :default => "", :null => false\r
- t.string "reset_password_token"\r
- t.datetime "reset_password_sent_at"\r
- t.datetime "remember_created_at"\r
- t.integer "sign_in_count", :default => 0\r
- t.datetime "current_sign_in_at"\r
- t.datetime "last_sign_in_at"\r
- t.string "current_sign_in_ip"\r
- t.string "last_sign_in_ip"\r
- t.string "authentication_token"\r
- t.string "confirmation_token"\r
- t.datetime "confirmed_at"\r
- t.datetime "confirmation_sent_at"\r
+ t.integer "user_id", :default => 0, :null => false\r
t.datetime "created_at"\r
t.datetime "updated_at"\r
end\r
\r
- add_index "authors", ["authentication_token"], :name => "index_authors_on_authentication_token", :unique => true\r
- add_index "authors", ["confirmation_token"], :name => "index_authors_on_confirmation_token", :unique => true\r
- add_index "authors", ["email"], :name => "index_authors_on_email", :unique => true\r
- add_index "authors", ["reset_password_token"], :name => "index_authors_on_reset_password_token", :unique => true\r
+ add_index "authors", ["user_id"], :name => "index_authors_on_user_id", :unique => true\r
\r
create_table "balloon_templates", :force => true do |t|\r
t.integer "speach_balloon_id", :null => false\r
end\r
\r
create_table "original_pictures", :force => true do |t|\r
- t.string "ext", :null => false\r
- t.integer "width", :null => false\r
- t.integer "height", :null => false\r
- t.integer "filesize", :null => false\r
- t.integer "artist_id"\r
- t.integer "license_id"\r
+ t.string "ext", :null => false\r
+ t.integer "width", :null => false\r
+ t.integer "height", :null => false\r
+ t.integer "filesize", :null => false\r
+ t.integer "artist_id", :default => 0, :null => false\r
+ t.integer "license_id", :default => 0, :null => false\r
t.datetime "created_at"\r
t.datetime "updated_at"\r
end\r
t.integer "t", :default => 1, :null => false\r
t.integer "width", :null => false\r
t.integer "height", :null => false\r
- t.integer "flipv", :default => 0, :null => false\r
- t.integer "fliph", :default => 0, :null => false\r
t.datetime "created_at"\r
t.datetime "updated_at"\r
end\r
add_index "panels", ["comic_id", "t"], :name => "panels_idt", :unique => true\r
\r
create_table "resource_pictures", :force => true do |t|\r
- t.string "ext", :null => false\r
- t.integer "width", :null => false\r
- t.integer "height", :null => false\r
- t.integer "filesize", :null => false\r
- t.integer "artist_id"\r
- t.integer "license_id"\r
- t.integer "original_picture_id", :null => false\r
+ t.string "ext", :null => false\r
+ t.integer "width", :null => false\r
+ t.integer "height", :null => false\r
+ t.integer "filesize", :null => false\r
+ t.integer "artist_id", :default => 0, :null => false\r
+ t.integer "license_id", :default => 0, :null => false\r
+ t.integer "original_picture_id", :null => false\r
t.datetime "created_at"\r
t.datetime "updated_at"\r
end\r
t.datetime "updated_at"\r
end\r
\r
+ create_table "users", :force => true do |t|\r
+ t.string "email", :default => "", :null => false\r
+ t.string "encrypted_password", :limit => 128, :default => "", :null => false\r
+ t.string "reset_password_token"\r
+ t.datetime "reset_password_sent_at"\r
+ t.datetime "remember_created_at"\r
+ t.integer "sign_in_count", :default => 0\r
+ t.datetime "current_sign_in_at"\r
+ t.datetime "last_sign_in_at"\r
+ t.string "current_sign_in_ip"\r
+ t.string "last_sign_in_ip"\r
+ t.string "authentication_token"\r
+ t.string "confirmation_token"\r
+ t.datetime "confirmed_at"\r
+ t.datetime "confirmation_sent_at"\r
+ t.datetime "created_at"\r
+ t.datetime "updated_at"\r
+ end\r
+\r
+ add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token", :unique => true\r
+ add_index "users", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true\r
+ add_index "users", ["email"], :name => "index_users_on_email", :unique => true\r
+ add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true\r
+\r
end\r