OSDN Git Service

speach balloon permission change to admin sb_permission
authoryasushiito <yas@pen-chan.jp>
Tue, 3 Jan 2012 23:38:10 +0000 (08:38 +0900)
committeryasushiito <yas@pen-chan.jp>
Tue, 3 Jan 2012 23:38:10 +0000 (08:38 +0900)
app/controllers/balloon_templates_controller.rb
app/controllers/speach_balloons_controller.rb
app/controllers/speach_templates_controller.rb
app/models/admin.rb
app/views/speach_balloons/index.html.erb
app/views/system/index.html.erb
config/routes.rb
db/migrate/20111206092734_devise_create_admins.rb
db/schema.rb

index a1ef251..22728ce 100644 (file)
@@ -1,5 +1,5 @@
 class BalloonTemplatesController < ApplicationController
-  before_filter :authenticate_author!, :except => [:index]
+  before_filter :authenticate_admin!, :except => [:index]
   
   # GET /balloon_templates
   # GET /balloon_templates.json
@@ -11,76 +11,4 @@ class BalloonTemplatesController < ApplicationController
       format.json { render json: @balloon_templates }
     end
   end
-=begin
-  # GET /balloon_templates/1
-  # GET /balloon_templates/1.json
-  def show
-    @balloon_template = BalloonTemplate.find(params[:id])
-
-    respond_to do |format|
-      format.html # show.html.erb
-      format.json { render json: @balloon_template }
-    end
-  end
-
-  # GET /balloon_templates/new
-  # GET /balloon_templates/new.json
-  def new
-    @balloon_template = BalloonTemplate.new
-
-    respond_to do |format|
-      format.html # new.html.erb
-      format.json { render json: @balloon_template }
-    end
-  end
-
-  # GET /balloon_templates/1/edit
-  def edit
-    @balloon_template = BalloonTemplate.find(params[:id])
-  end
-
-  # POST /balloon_templates
-  # POST /balloon_templates.json
-  def create
-    @balloon_template = BalloonTemplate.new(params[:balloon_template])
-
-    respond_to do |format|
-      if @balloon_template.save
-        format.html { redirect_to @balloon_template, notice: 'Balloon template was successfully created.' }
-        format.json { render json: @balloon_template, status: :created, location: @balloon_template }
-      else
-        format.html { render action: "new" }
-        format.json { render json: @balloon_template.errors, status: :unprocessable_entity }
-      end
-    end
-  end
-
-  # PUT /balloon_templates/1
-  # PUT /balloon_templates/1.json
-  def update
-    @balloon_template = BalloonTemplate.find(params[:id])
-
-    respond_to do |format|
-      if @balloon_template.update_attributes(params[:balloon_template])
-        format.html { redirect_to @balloon_template, notice: 'Balloon template was successfully updated.' }
-        format.json { head :ok }
-      else
-        format.html { render action: "edit" }
-        format.json { render json: @balloon_template.errors, status: :unprocessable_entity }
-      end
-    end
-  end
-
-  # DELETE /balloon_templates/1
-  # DELETE /balloon_templates/1.json
-  def destroy
-    @balloon_template = BalloonTemplate.find(params[:id])
-    @balloon_template.destroy
-
-    respond_to do |format|
-      format.html { redirect_to balloon_templates_url }
-      format.json { head :ok }
-    end
-  end
-=end
 end
index 3297494..54d0f29 100644 (file)
@@ -1,5 +1,6 @@
 class SpeachBalloonsController < ApplicationController
-  before_filter :authenticate_author!, :except => [:index]
+  before_filter :authenticate_author!, :only => [:index]
+  before_filter :authenticate_admin!, :except => [:index]
 
   private
   
@@ -79,7 +80,6 @@ class SpeachBalloonsController < ApplicationController
   # POST /speach_balloons.json
   def create
     @speach_balloon = SpeachBalloon.new(params[:speach_balloon])
-
     if em = validate_param(params[:speach_balloon])
       respond_to do |format|
         format.json { render json: em, status: :unprocessable_entity }
index 401844d..d8bb57a 100644 (file)
@@ -1,5 +1,5 @@
 class SpeachTemplatesController < ApplicationController
-  before_filter :authenticate_author!, :except => [:index]
+  before_filter :authenticate_admin!, :except => [:index]
 
   # GET /speach_templates
   # GET /speach_templates.json
@@ -12,76 +12,4 @@ class SpeachTemplatesController < ApplicationController
     end
   end
 
-=begin
-  # GET /speach_templates/1
-  # GET /speach_templates/1.json
-  def show
-    @speach_template = SpeachTemplate.find(params[:id])
-
-    respond_to do |format|
-      format.html # show.html.erb
-      format.json { render json: @speach_template }
-    end
-  end
-
-  # GET /speach_templates/new
-  # GET /speach_templates/new.json
-  def new
-    @speach_template = SpeachTemplate.new
-
-    respond_to do |format|
-      format.html # new.html.erb
-      format.json { render json: @speach_template }
-    end
-  end
-
-  # GET /speach_templates/1/edit
-  def edit
-    @speach_template = SpeachTemplate.find(params[:id])
-  end
-
-  # POST /speach_templates
-  # POST /speach_templates.json
-  def create
-    @speach_template = SpeachTemplate.new(params[:speach_template])
-
-    respond_to do |format|
-      if @speach_template.save
-        format.html { redirect_to @speach_template, notice: 'Speach template was successfully created.' }
-        format.json { render json: @speach_template, status: :created, location: @speach_template }
-      else
-        format.html { render action: "new" }
-        format.json { render json: @speach_template.errors, status: :unprocessable_entity }
-      end
-    end
-  end
-
-  # PUT /speach_templates/1
-  # PUT /speach_templates/1.json
-  def update
-    @speach_template = SpeachTemplate.find(params[:id])
-
-    respond_to do |format|
-      if @speach_template.update_attributes(params[:speach_template])
-        format.html { redirect_to @speach_template, notice: 'Speach template was successfully updated.' }
-        format.json { head :ok }
-      else
-        format.html { render action: "edit" }
-        format.json { render json: @speach_template.errors, status: :unprocessable_entity }
-      end
-    end
-  end
-
-  # DELETE /speach_templates/1
-  # DELETE /speach_templates/1.json
-  def destroy
-    @speach_template = SpeachTemplate.find(params[:id])
-    @speach_template.destroy
-
-    respond_to do |format|
-      format.html { redirect_to speach_templates_url }
-      format.json { head :ok }
-    end
-  end
-=end
 end
index ca1d723..eee4ac4 100644 (file)
@@ -1,11 +1,12 @@
 class Admin < ActiveRecord::Base
   # Include default devise modules. Others available are:
-  # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
+  # , :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
   devise :database_authenticatable, :registerable,
-         :recoverable, :rememberable, :trackable, :validatable
+         :recoverable, :rememberable, :trackable, :validatable, :token_authenticatable
 
   # Setup accessible (or protected) attributes for your model
   attr_accessible :email, :password, :password_confirmation, :remember_me
+  before_save :ensure_authentication_token\r
   
   def self.start(email, passwd)
     Admin.create! :email => email, :password => passwd, :password_confirmation => passwd, :activate => 1
index 648f9bc..bb51d37 100644 (file)
@@ -1,11 +1,11 @@
 <h1>Listing speach_balloons</h1>
-
 <table>
   <tr>
     <th>Name</th>
     <th>Tail limit</th>
     <th>Border limit</th>
     <th></th>
+    <th></th>
   </tr>
 
 <% @speach_balloons.each do |speach_balloon| %>
     <td><%= speach_balloon.tail_limit %></td>
     <td><%= speach_balloon.border_limit %></td>
     <td><%= link_to 'show', speach_balloon %></td>
+    <td>
+      <% if admin_signed_in? -%>
+        <%= link_to 'Destroy', speach_balloon, confirm: 'Are you sure?', method: :delete %>
+      <% end -%>
+    </td>
   </tr>
 <% end %>
 </table>
index 5c66bd6..3d98020 100644 (file)
@@ -1 +1 @@
-    <%# current_admin.authentication_token %>
+authentication_token:<%= current_admin.authentication_token %>
index fe47bc6..2567080 100644 (file)
@@ -31,11 +31,12 @@ Pettanr::Application.routes.draw do
   match 'resource_pictures/:subdir/:id(.:format)/' => 'resource_pictures#show'
   match 'home/(:action)', :controller => 'home'
   match 'help/(:action)', :controller => 'help'
-  controller 'system' do
-    get 'start'
-    get 'index'
-#    match 'start', :to => 'system#start'
-  end
+  match 'system/(:action)', :controller => 'system'
+#  controller 'system' do
+#    get 'start'
+#    get 'index'
+##    match 'start', :to => 'system#start'
+#  end
   
   # Sample of named route:
   #   match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
index e7bb867..871148e 100644 (file)
@@ -9,7 +9,7 @@ class DeviseCreateAdmins < ActiveRecord::Migration
       # t.encryptable
       # t.confirmable
       # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
-      t.token_authenticatable
+      t.token_authenticatable
       t.integer :activate, :null => false, :default => 0
 
       t.timestamps
@@ -19,7 +19,7 @@ class DeviseCreateAdmins < ActiveRecord::Migration
     add_index :admins, :reset_password_token, :unique => true
     # add_index :admins, :confirmation_token,   :unique => true
     # add_index :admins, :unlock_token,         :unique => true
-    add_index :admins, :authentication_token, :unique => true
+    add_index :admins, :authentication_token, :unique => true
   end
 
 end
index b1a4f0b..c2ba199 100644 (file)
@@ -24,11 +24,13 @@ ActiveRecord::Schema.define(:version => 20120102071851) do
     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.integer  "activate",                              :default => 0,  :null => false\r
     t.datetime "created_at"\r
     t.datetime "updated_at"\r
   end\r
 \r
+  add_index "admins", ["authentication_token"], :name => "index_admins_on_authentication_token", :unique => true\r
   add_index "admins", ["email"], :name => "index_admins_on_email", :unique => true\r
   add_index "admins", ["reset_password_token"], :name => "index_admins_on_reset_password_token", :unique => true\r
 \r