• R/O
  • HTTP
  • SSH
  • HTTPS

pettanr: コミット

サーバ側、Railsシステム本体


コミットメタ情報

リビジョンd45ca752c4e6e180bc551a5277710b9e4d4d075f (tree)
日時2012-01-04 08:38:10
作者yasushiito <yas@pen-...>
コミッターyasushiito

ログメッセージ

speach balloon permission change to admin

変更サマリ

差分

--- a/app/controllers/balloon_templates_controller.rb
+++ b/app/controllers/balloon_templates_controller.rb
@@ -1,5 +1,5 @@
11 class BalloonTemplatesController < ApplicationController
2- before_filter :authenticate_author!, :except => [:index]
2+ before_filter :authenticate_admin!, :except => [:index]
33
44 # GET /balloon_templates
55 # GET /balloon_templates.json
@@ -11,76 +11,4 @@ class BalloonTemplatesController < ApplicationController
1111 format.json { render json: @balloon_templates }
1212 end
1313 end
14-=begin
15- # GET /balloon_templates/1
16- # GET /balloon_templates/1.json
17- def show
18- @balloon_template = BalloonTemplate.find(params[:id])
19-
20- respond_to do |format|
21- format.html # show.html.erb
22- format.json { render json: @balloon_template }
23- end
24- end
25-
26- # GET /balloon_templates/new
27- # GET /balloon_templates/new.json
28- def new
29- @balloon_template = BalloonTemplate.new
30-
31- respond_to do |format|
32- format.html # new.html.erb
33- format.json { render json: @balloon_template }
34- end
35- end
36-
37- # GET /balloon_templates/1/edit
38- def edit
39- @balloon_template = BalloonTemplate.find(params[:id])
40- end
41-
42- # POST /balloon_templates
43- # POST /balloon_templates.json
44- def create
45- @balloon_template = BalloonTemplate.new(params[:balloon_template])
46-
47- respond_to do |format|
48- if @balloon_template.save
49- format.html { redirect_to @balloon_template, notice: 'Balloon template was successfully created.' }
50- format.json { render json: @balloon_template, status: :created, location: @balloon_template }
51- else
52- format.html { render action: "new" }
53- format.json { render json: @balloon_template.errors, status: :unprocessable_entity }
54- end
55- end
56- end
57-
58- # PUT /balloon_templates/1
59- # PUT /balloon_templates/1.json
60- def update
61- @balloon_template = BalloonTemplate.find(params[:id])
62-
63- respond_to do |format|
64- if @balloon_template.update_attributes(params[:balloon_template])
65- format.html { redirect_to @balloon_template, notice: 'Balloon template was successfully updated.' }
66- format.json { head :ok }
67- else
68- format.html { render action: "edit" }
69- format.json { render json: @balloon_template.errors, status: :unprocessable_entity }
70- end
71- end
72- end
73-
74- # DELETE /balloon_templates/1
75- # DELETE /balloon_templates/1.json
76- def destroy
77- @balloon_template = BalloonTemplate.find(params[:id])
78- @balloon_template.destroy
79-
80- respond_to do |format|
81- format.html { redirect_to balloon_templates_url }
82- format.json { head :ok }
83- end
84- end
85-=end
8614 end
--- a/app/controllers/speach_balloons_controller.rb
+++ b/app/controllers/speach_balloons_controller.rb
@@ -1,5 +1,6 @@
11 class SpeachBalloonsController < ApplicationController
2- before_filter :authenticate_author!, :except => [:index]
2+ before_filter :authenticate_author!, :only => [:index]
3+ before_filter :authenticate_admin!, :except => [:index]
34
45 private
56
@@ -79,7 +80,6 @@ class SpeachBalloonsController < ApplicationController
7980 # POST /speach_balloons.json
8081 def create
8182 @speach_balloon = SpeachBalloon.new(params[:speach_balloon])
82-
8383 if em = validate_param(params[:speach_balloon])
8484 respond_to do |format|
8585 format.json { render json: em, status: :unprocessable_entity }
--- a/app/controllers/speach_templates_controller.rb
+++ b/app/controllers/speach_templates_controller.rb
@@ -1,5 +1,5 @@
11 class SpeachTemplatesController < ApplicationController
2- before_filter :authenticate_author!, :except => [:index]
2+ before_filter :authenticate_admin!, :except => [:index]
33
44 # GET /speach_templates
55 # GET /speach_templates.json
@@ -12,76 +12,4 @@ class SpeachTemplatesController < ApplicationController
1212 end
1313 end
1414
15-=begin
16- # GET /speach_templates/1
17- # GET /speach_templates/1.json
18- def show
19- @speach_template = SpeachTemplate.find(params[:id])
20-
21- respond_to do |format|
22- format.html # show.html.erb
23- format.json { render json: @speach_template }
24- end
25- end
26-
27- # GET /speach_templates/new
28- # GET /speach_templates/new.json
29- def new
30- @speach_template = SpeachTemplate.new
31-
32- respond_to do |format|
33- format.html # new.html.erb
34- format.json { render json: @speach_template }
35- end
36- end
37-
38- # GET /speach_templates/1/edit
39- def edit
40- @speach_template = SpeachTemplate.find(params[:id])
41- end
42-
43- # POST /speach_templates
44- # POST /speach_templates.json
45- def create
46- @speach_template = SpeachTemplate.new(params[:speach_template])
47-
48- respond_to do |format|
49- if @speach_template.save
50- format.html { redirect_to @speach_template, notice: 'Speach template was successfully created.' }
51- format.json { render json: @speach_template, status: :created, location: @speach_template }
52- else
53- format.html { render action: "new" }
54- format.json { render json: @speach_template.errors, status: :unprocessable_entity }
55- end
56- end
57- end
58-
59- # PUT /speach_templates/1
60- # PUT /speach_templates/1.json
61- def update
62- @speach_template = SpeachTemplate.find(params[:id])
63-
64- respond_to do |format|
65- if @speach_template.update_attributes(params[:speach_template])
66- format.html { redirect_to @speach_template, notice: 'Speach template was successfully updated.' }
67- format.json { head :ok }
68- else
69- format.html { render action: "edit" }
70- format.json { render json: @speach_template.errors, status: :unprocessable_entity }
71- end
72- end
73- end
74-
75- # DELETE /speach_templates/1
76- # DELETE /speach_templates/1.json
77- def destroy
78- @speach_template = SpeachTemplate.find(params[:id])
79- @speach_template.destroy
80-
81- respond_to do |format|
82- format.html { redirect_to speach_templates_url }
83- format.json { head :ok }
84- end
85- end
86-=end
8715 end
--- a/app/models/admin.rb
+++ b/app/models/admin.rb
@@ -1,11 +1,12 @@
11 class Admin < ActiveRecord::Base
22 # Include default devise modules. Others available are:
3- # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
3+ # , :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
44 devise :database_authenticatable, :registerable,
5- :recoverable, :rememberable, :trackable, :validatable
5+ :recoverable, :rememberable, :trackable, :validatable, :token_authenticatable
66
77 # Setup accessible (or protected) attributes for your model
88 attr_accessible :email, :password, :password_confirmation, :remember_me
9+ before_save :ensure_authentication_token
910
1011 def self.start(email, passwd)
1112 Admin.create! :email => email, :password => passwd, :password_confirmation => passwd, :activate => 1
--- a/app/views/speach_balloons/index.html.erb
+++ b/app/views/speach_balloons/index.html.erb
@@ -1,11 +1,11 @@
11 <h1>Listing speach_balloons</h1>
2-
32 <table>
43 <tr>
54 <th>Name</th>
65 <th>Tail limit</th>
76 <th>Border limit</th>
87 <th></th>
8+ <th></th>
99 </tr>
1010
1111 <% @speach_balloons.each do |speach_balloon| %>
@@ -14,6 +14,11 @@
1414 <td><%= speach_balloon.tail_limit %></td>
1515 <td><%= speach_balloon.border_limit %></td>
1616 <td><%= link_to 'show', speach_balloon %></td>
17+ <td>
18+ <% if admin_signed_in? -%>
19+ <%= link_to 'Destroy', speach_balloon, confirm: 'Are you sure?', method: :delete %>
20+ <% end -%>
21+ </td>
1722 </tr>
1823 <% end %>
1924 </table>
--- a/app/views/system/index.html.erb
+++ b/app/views/system/index.html.erb
@@ -1 +1 @@
1- <%# current_admin.authentication_token %>
1+authentication_token:<%= current_admin.authentication_token %>
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -31,11 +31,12 @@ Pettanr::Application.routes.draw do
3131 match 'resource_pictures/:subdir/:id(.:format)/' => 'resource_pictures#show'
3232 match 'home/(:action)', :controller => 'home'
3333 match 'help/(:action)', :controller => 'help'
34- controller 'system' do
35- get 'start'
36- get 'index'
37-# match 'start', :to => 'system#start'
38- end
34+ match 'system/(:action)', :controller => 'system'
35+# controller 'system' do
36+# get 'start'
37+# get 'index'
38+## match 'start', :to => 'system#start'
39+# end
3940
4041 # Sample of named route:
4142 # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
--- a/db/migrate/20111206092734_devise_create_admins.rb
+++ b/db/migrate/20111206092734_devise_create_admins.rb
@@ -9,7 +9,7 @@ class DeviseCreateAdmins < ActiveRecord::Migration
99 # t.encryptable
1010 # t.confirmable
1111 # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
12- # t.token_authenticatable
12+ t.token_authenticatable
1313 t.integer :activate, :null => false, :default => 0
1414
1515 t.timestamps
@@ -19,7 +19,7 @@ class DeviseCreateAdmins < ActiveRecord::Migration
1919 add_index :admins, :reset_password_token, :unique => true
2020 # add_index :admins, :confirmation_token, :unique => true
2121 # add_index :admins, :unlock_token, :unique => true
22- # add_index :admins, :authentication_token, :unique => true
22+ add_index :admins, :authentication_token, :unique => true
2323 end
2424
2525 end
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -24,11 +24,13 @@ ActiveRecord::Schema.define(:version => 20120102071851) do
2424 t.datetime "last_sign_in_at"
2525 t.string "current_sign_in_ip"
2626 t.string "last_sign_in_ip"
27+ t.string "authentication_token"
2728 t.integer "activate", :default => 0, :null => false
2829 t.datetime "created_at"
2930 t.datetime "updated_at"
3031 end
3132
33+ add_index "admins", ["authentication_token"], :name => "index_admins_on_authentication_token", :unique => true
3234 add_index "admins", ["email"], :name => "index_admins_on_email", :unique => true
3335 add_index "admins", ["reset_password_token"], :name => "index_admins_on_reset_password_token", :unique => true
3436
旧リポジトリブラウザで表示