OSDN Git Service

fix:server
authoryasushiito <yas@pen-chan.jp>
Wed, 29 Apr 2015 02:26:21 +0000 (11:26 +0900)
committeryasushiito <yas@pen-chan.jp>
Wed, 29 Apr 2015 02:26:21 +0000 (11:26 +0900)
18 files changed:
app/controllers/panels_controller.rb
app/controllers/sheets_controller.rb
app/models/author.rb
app/models/balloon.rb
app/models/sheet.rb
app/models/sheet_panel.rb
app/models/speech.rb
app/views/ground_colors/show.html.erb
app/views/ground_pictures/show.html.erb
app/views/layouts/test.html.erb
app/views/panel_pictures/show.html.erb
app/views/panels/_element_copy.html.erb [deleted file]
app/views/panels/_footer.html.erb
app/views/sheets/play.html.erb
app/views/sheets/show.html.erb
config/routes.rb
lib/peta/element.rb
lib/peta/root.rb

index ad67b3e..b748c05 100644 (file)
@@ -1,13 +1,13 @@
 class PanelsController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
-    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy, :catch]
-    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy, :catch]
+    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
+    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
   else
     before_filter :authenticate_reader, :only => [
       :index, :show, :by_scroll, :by_sheet, :by_author, :by_speech_balloon_template
     ]
-    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy, :catch]
-    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy, :catch]
+    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
+    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
   end
   
   private
@@ -69,6 +69,7 @@ class PanelsController < ApplicationController
     end
   end
   
+=begin
   def new
     set_new
     respond_to do |format|
@@ -94,6 +95,15 @@ class PanelsController < ApplicationController
       format.json { render json: @item.to_json }
     end
   end
+=end
+  
+  def new
+    form_new
+  end
+  
+  def edit
+    form_edit
+  end
   
   def create
     set_model
@@ -115,13 +125,7 @@ class PanelsController < ApplicationController
         created_html_format format
         created_json_format format
       else
-        format.html {
-          flash[:notice] = I18n.t('flash.notice.not_created', :model => @my_model_class.model_name.human)
-          @editor = Editor::PanelEditor.new @item, @operators
-          render :template => @editor.template_name, :locals => {
-            :editor => @editor
-          }
-        }
+        not_created_html_format format
         not_created_json_format format
       end
     end
@@ -142,13 +146,7 @@ class PanelsController < ApplicationController
         updated_html_format format
         updated_json_format format
       else
-        format.html {
-          flash[:notice] = I18n.t('flash.notice.not_updated', :model => @my_model_class.model_name.human)
-          @editor = Editor::PanelEditor.new @item, @operators
-          render :template => @editor.template_name, :locals => {
-            :editor => @editor
-          }
-        }
+        not_updated_html_format format
         not_updated_json_format format
       end
     end
@@ -171,16 +169,4 @@ class PanelsController < ApplicationController
     end
   end
   
-  def catch
-    @item = Panel.edit(params[:id], @operators)
-
-    respond_to do |format|
-      @operators.author.working_panel_id = @item.id
-      if @operators.author.save
-        format.html { redirect_to @item }
-      else
-      end
-    end
-  end
-
 end
index 5a05a8f..0132a9d 100644 (file)
@@ -54,13 +54,14 @@ class SheetsController < ApplicationController
     respond_to do |format|
       format.html {
         if @operators.author
-          @new_panel_items = assist_items('panel', 'private')
+          @new_panel_items = assist_items('home', 'panels')
         end
       }
       list_json_format @list, format
     end
   end
   
+=begin
   def new
     set_new
     respond_to do |format|
@@ -87,9 +88,20 @@ class SheetsController < ApplicationController
     end
   end
   
+=end
+  
+  def new
+    form_new
+  end
+  
+  def edit
+    form_edit
+  end
+  
   def create
-    @sheet = Sheet.new
-    @sheet.supply_default 
+    set_model
+    @item = @my_model_class.new
+    @item.supply_default 
     jsn = nil
     if params[:json]
       jsn = JSON.parse_no_except(params[:json])
@@ -97,41 +109,29 @@ class SheetsController < ApplicationController
     @prm = params[:sheet] || jsn
     
     respond_to do |format|
-      if @sheet.store @prm, @operators
+      if @item.store @prm, @operators
         created_html_format format
         created_json_format format
       else
-        format.html {
-          flash[:notice] = I18n.t('flash.notice.not_created', :model => @my_model_class.model_name.human)
-          @editor = Editor::PanelEditor.new @item, @operators
-          render :template => @editor.template_name, :locals => {
-            :editor => @editor
-          }
-        }
+        not_created_html_format format
         not_created_json_format format
       end
     end
   end
   
   def update
-    @sheet = Sheet.edit(params[:id], @operators)
+    set_edit
     jsn = nil
     if params[:json]
       jsn = JSON.parse(params[:json])
     end
     @prm = params[:sheet] || jsn
     respond_to do |format|
-      if @sheet.store @prm, @operators
+      if @item.store @prm, @operators
         updated_html_format format
         updated_json_format format
       else
-        format.html {
-          flash[:notice] = I18n.t('flash.notice.not_updated', :model => @my_model_class.model_name.human)
-          @editor = Editor::PanelEditor.new @item, @operators
-          render :template => @editor.template_name, :locals => {
-            :editor => @editor
-          }
-        }
+        not_updated_html_format format
         not_updated_json_format format
       end
     end
index 0ea5aab..594e36c 100644 (file)
@@ -5,10 +5,8 @@ class Author < Peta::Owner
   has_many :comics
   has_many :sheets
   has_many :panels
-  belongs_to :working_panel, :class_name => "Panel"
   
   validates :name, :presence => true, :length => {:maximum => 30}
-  validates :working_panel_id, :numericality => {:allow_nil => true}
   validates :user_id, :numericality => true, :existence => {:both => false}
   
   def supply_default
@@ -16,10 +14,6 @@ class Author < Peta::Owner
     self.user_id = nil
   end
   
-  def working?
-    self.working_panel_id and self.working_panel
-  end
-  
   def self.show_opt
     {:include => {:user => {:artist => {}}} }
   end
index 73f538c..f4287fe 100644 (file)
@@ -62,10 +62,6 @@ self.system_picture_id = 1
     }
   end
   
-  def self.panelize balloon_attributes
-    {'balloon_attributes' => balloon_attributes}
-  end
-  
   def scenario
   end
   
index c63abe7..dd4d5eb 100644 (file)
@@ -72,28 +72,12 @@ class Sheet < Peta::Root
   
   def copyable?
     r = true
-    Sheet.each_element_class_names do |n|
-      self.elements_by_class_name(n).each do |elm|
-        next if elm.copyable?
-        r = false
-        break
-      end
-      break unless r
+    self.elements_items.each do |elm|
+      next if elm.copyable?
+      r = false
+      break
     end
     r
   end
   
-  def copy
-    attr = self.copy_attributes
-    Sheet.each_element_class_names do |n|
-      element_attr = Sheet.class_name_to_class(n).panelize(
-        self.elements_by_class_name(n).map {|elm|
-          elm.copy_attributes.merge elm.panel_attributes
-        }
-      )
-      attr.merge! element_attr
-    end
-    attr
-  end
-  
 end
index 591b259..4acf27c 100644 (file)
@@ -76,46 +76,11 @@ class SheetPanel < Peta::Element
     end
   end
   
-    def self.panelize elements_attributes
-      elements_attributes = [elements_attributes] unless elements_attributes.is_a?(Array)
-      hash = {}
-      index = 0
-      elements_attributes.each do |element_attributes|
-        hash[self.to_s.tableize + '_attributes'] ||= {}
-        n = if element_attributes['id']
-          element_attributes['id'].to_s
-        else
-          index += 1
-          'new' + index.to_s 
-        end
-        hash[self.to_s.tableize + '_attributes'][n] = element_attributes
-      end
-      hash
-    end
-    
-    def copy_attributes
-      r = self.attributes
-      r.delete 'id'
-      r.delete 'sheet_id'
-      r.delete 'panel_id'   # create panel
-      r.delete 'created_at'
-      r.delete 'updated_at'
-      r
-    end
-  
   def copyable?
-    if self.panel and self.panel.publish? == false
-      false
-    else
+    if self.panel and self.panel.publish?
       true
-    end
-  end
-  
-  def panel_attributes
-    if self.panel
-      {'panel_attributes' => self.panel.copy}
     else
-      {}
+      false
     end
   end
   
index 6cb3f9c..afdc511 100644 (file)
@@ -75,17 +75,13 @@ class Speech < Peta::Element
     {:include => {:speech_balloon => {:panel => {:author => {}}, :balloon => {}, :speech_balloon_template => {} }}}
   end
   
-  def self.panelize speech_attributes
-    {'speech_attributes' => speech_attributes}
-  end
-  
   def scenario
     self.boosts 'read'
     self.render
   end
   
   def plain_scenario
-    self.content + "\n"
+    self.content.to_s + "\n"
   end
   
   def feed
index a2bc17d..380f423 100644 (file)
@@ -10,5 +10,3 @@
 
 <%= link_to t('link.edit'), edit_ground_color_path(@ground_color) %>
 <%= link_to t('link.destroy'), ground_color_path(@ground_color), :method => :delete %>
-
-<%= render 'panels/element_copy', :element => @ground_color, :operators => @operators %>
index c4fcd31..acf40d2 100644 (file)
@@ -10,5 +10,3 @@
 
 <%= link_to t('link.edit'), edit_ground_picture_path(@ground_picture) %>
 <%= link_to t('link.destroy'), ground_picture_path(@ground_picture), :method => :delete %>
-
-<%= render 'panels/element_copy', :element => @ground_picture, :operators => @operators %>
index 763fb69..646a16c 100644 (file)
@@ -79,9 +79,6 @@
     <%= link_to t('*'), main_app.new_original_picture_path %>\r
     <%= link_to t('tab.creator.resource_picture'), '/home/resource_pictures' %>\r
   <% end %>\r
-  <% if @operators.author and @operators.author.working? -%>\r
-    <%= link_to t('tab.creator..catch'), main_app.panel_path(@operators.author.working_panel) %>\r
-  <% end %>\r
 </div>\r
 <%= yield %>\r
 <div width="100%" style="background-color: #faddfa; padding: 5px;">\r
index ad72431..37258f4 100644 (file)
@@ -10,5 +10,3 @@
 
 <%= link_to t('link.edit'), edit_panel_picture_path(@panel_picture) %>
 <%= link_to t('link.destroy'), panel_picture_path(@panel_picture), :method => :delete %>
-
-<%= render 'panels/element_copy', :element => @panel_picture, :operators => @operators %>
diff --git a/app/views/panels/_element_copy.html.erb b/app/views/panels/_element_copy.html.erb
deleted file mode 100644 (file)
index 4de1370..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<% if operators.author and operators.author.working? -%>
-  <h2><%= t('panels.element_copy') -%></h2>
-  <h3><%= t('home.index.catch') -%></h3>
-  <%= link_to panel_icon(:object => operators.author.working_panel, :size => 25), panel_path(operators.author.working_panel) %>
-  <%= link_to operators.author.working_panel.caption, main_app.panel_path(operators.author.working_panel) %>
-
-  <%= form_for(operators.author.working_panel) do |f| %>
-    <%= hidden_field_tag "json", element.copy(operators.author.working_panel).to_json %>
-    <div>
-      <%= submit_tag t('panels.inspire') -%>
-    </div>
-  <% end %>
-<% end -%>
index 121718c..071ad98 100644 (file)
@@ -8,7 +8,6 @@
     <td>
       <% if panel.own? operators %>
         <%= link_to t('link.edit'), main_app.edit_panel_path(panel) %>
-        <%= link_to t('link.catch'), main_app.catch_panel_path(panel) %>
       <% end %>
     </td>
   </tr>
index befcce8..464deab 100644 (file)
@@ -1,7 +1,7 @@
 <% @page_caption = @item.caption %>
 <p id="notice"><%= notice %></p>
 
-<% if @item.sheet_elements.empty? -%>
+<% if @item.sheet_panels.empty? -%>
   <h2><%= t('sheet_panels.sheet.empty') %></h2>
 <% else %>
   <div id=" @item.tag_id wrapper" sheet_id=" @item.tag_sheet_id " class="pettanr-sheet-wrapper" editable="true">
index 45366b5..d508b92 100644 (file)
@@ -9,7 +9,7 @@
     <h2><%= t('sheets.show.copy') -%></h2>
     <%= form_for(Sheet.new, :html => {:jqform => 'pettanr-sheet-form'}) do |f| %>
 
-      <%= hidden_field_tag "json", @item.copy().to_json %>
+      <%= hidden_field_tag "json", @item.post_attributes(:all => true).to_json %>
       <div>
         <%= submit_tag t('sheets.show.inspire') -%>
       </div>
index 4b404d0..e159c8a 100644 (file)
@@ -194,7 +194,6 @@ Pettanr::Application.routes.draw do
       get :by_sheet
       get :by_author
       get :by_speech_balloon_template
-      get :catch
       get :edit
       put :update
       delete :destroy
index cf0bd70..6542e9b 100644 (file)
@@ -67,23 +67,6 @@ module Peta
       {}
     end
     
-    def self.panelize elements_attributes
-      elements_attributes = [elements_attributes] unless elements_attributes.is_a?(Array)
-      hash = {}
-      index = 0
-      elements_attributes.each do |element_attributes|
-        hash[self.to_s.tableize + '_attributes'] ||= {}
-        n = if element_attributes['id']
-          element_attributes['id'].to_s
-        else
-          index += 1
-          'new' + index.to_s 
-        end
-        hash[self.to_s.tableize + '_attributes'][n] = element_attributes
-      end
-      hash
-    end
-    
     def has_picture?
       false
     end
index c0a3887..379ad0a 100644 (file)
@@ -145,12 +145,6 @@ module Peta
       res
     end
     
-    def self.panelize panel
-      attr = panel.attributes
-      attr.delete 'id'
-      attr
-    end
-    
   end
 end