OSDN Git Service

temp
authoryasushiito <yas@pen-chan.jp>
Mon, 9 Dec 2013 05:07:42 +0000 (14:07 +0900)
committeryasushiito <yas@pen-chan.jp>
Mon, 9 Dec 2013 05:07:42 +0000 (14:07 +0900)
15 files changed:
app/controllers/authors_controller.rb
app/models/artist.rb
app/models/scroll_panel.rb
app/views/artists/_form.html.erb
app/views/artists/edit.html.erb
app/views/artists/new.html.erb
app/views/authors/_form.html.erb
app/views/authors/edit.html.erb
app/views/authors/new.html.erb
app/views/home/configure.html.erb
app/views/layouts/test.prof.erb
app/views/system/prof.prof.erb
lib/manifest/list.rb
lib/manifest/profiler.rb
lib/operator.rb

index 6c87f0f..0de9864 100644 (file)
@@ -284,8 +284,8 @@ class AuthorsController < ApplicationController
   end
   
   def new
-    @au = Author.new
-    @au.supply_default 
+    @author = Author.new
+    @author.supply_default 
 
     respond_to do |format|
       format.html # new.html.erb
@@ -295,19 +295,19 @@ class AuthorsController < ApplicationController
   end
 
   def edit
-    @au = Author.edit(params[:id], @author)
+    @author = Author.edit(params[:id], @operators)
   end
 
   def create
-    @au = Author.new()
-    @au.supply_default 
-    @au.attributes = params[:author]
-    @au.overwrite @user.id
+    @author = Author.new()
+    @author.supply_default 
+    @author.attributes = params[:author]
+    @author.overwrite @operators
     respond_to do |format|
-      if @au.save
+      if @author.save
         flash[:notice] = I18n.t('flash.notice.created', :model => Author.model_name.human)
         format.html { redirect_to root_path }
-        format.json { render json: @au.to_json(Author.show_json_opt), status: :created, location: @artist }
+        format.json { render json: @author.to_json(Author.show_json_opt), status: :created }
       else
         flash[:notice] = I18n.t('flash.notice.not_created', :model => Author.model_name.human)
         format.html { render action: "new" }
@@ -317,19 +317,19 @@ class AuthorsController < ApplicationController
   end
 
   def update
-    @au = Author.edit(params[:id], @author)
-    @au.attributes = params[:author]
-    @au.overwrite @user.id
+    @author = Author.edit(params[:id], @operators)
+    @author.attributes = params[:author]
+    @author.overwrite @operators
 
     respond_to do |format|
-      if @au.save
+      if @author.save
         flash[:notice] = I18n.t('flash.notice.updated', :model => Author.model_name.human)
         format.html { redirect_to '/home/configure' }
         format.json { head :ok }
       else
         flash[:notice] = I18n.t('flash.notice.not_updated', :model => Author.model_name.human)
         format.html { render action: "edit" }
-        format.json { render json: @au.errors, status: :unprocessable_entity }
+        format.json { render json: @author.errors, status: :unprocessable_entity }
       end
     end
   end
index 955c8ff..e1ef12d 100644 (file)
@@ -6,7 +6,7 @@ class Artist < Pettanr::Owner
   
   validates :name, :presence => true, :length => {:maximum => 30}
   validates :user_id, :numericality => true, :existence => {:both => false}
-  validates :provider, :numericality => true
+  validates :provider_id, :numericality => {:allow_nil => true}
   
   @@valid_encode_columns += ['name']
   @@visible_count_options = {:conditions => ['artists.author_id is not null']}
index f1314b4..520aacc 100644 (file)
@@ -84,6 +84,10 @@ class ScrollPanel < ActiveRecord::Base
     ['scroll_panels.scroll_id = ?', cid]
   end
   
+  def self.list_order
+    'scroll_panels.updated_at desc'
+  end
+  
   def self.list_where
     'scrolls.visible > 0'
   end
index 310be37..d71f45d 100644 (file)
@@ -1,5 +1,5 @@
-<%= form_for(ar) do |f| %>
-  <%= render 'system/error_explanation', :obj => ar %>
+<%= form_for(artist) do |f| %>
+  <%= render 'system/error_explanation', :obj => artist %>
 
   <div class="field">
     <%= f.label :name %><br />
index 78e9943..1f7a8f3 100644 (file)
@@ -1,4 +1,4 @@
 <h1><%= t '.title' -%></h1>
 <p id="notice"><%= notice %></p>
 
-<%= render 'form', :ar => @ar %>
+<%= render 'form', :artist => @artist %>
index f6db1ed..4abac29 100644 (file)
@@ -2,6 +2,6 @@
 <p>素材の投稿には絵師登録が必要です。</p>
 <p>下記フォームで登録してください。</p>
 
-<%= render 'form', :ar => @ar %>
+<%= render 'form', :artist => @artist %>
 
 <%= link_to t('link.back'), artists_path %>
index 4629696..3cb583a 100644 (file)
@@ -1,5 +1,5 @@
-<%= form_for(au) do |f| %>
-  <%= render 'system/error_explanation', :obj => au %>
+<%= form_for(author) do |f| %>
+  <%= render 'system/error_explanation', :obj => author %>
 
   <div class="field">
     <%= f.label :name %><br />
index ea18093..c714a95 100644 (file)
@@ -1,5 +1,5 @@
 <h1><%= t '.title' -%></h1>
 <p id="notice"><%= notice %></p>
 
-<%= render 'form', :au => @au %>
+<%= render 'form', :author => @author %>
 
index 149cd95..6fc715a 100644 (file)
@@ -1,5 +1,5 @@
 <h1><%= t '.title' -%></h1>
 <h2><%= t '.announce' -%></h2>
 
-<%= render 'form', :au => @au  %>
+<%= render 'form', :author => @author  %>
 
index 70dea5c..96371d8 100644 (file)
@@ -1,15 +1,15 @@
 <h1><%= t '.title' -%></h1>
 <p id="notice"><%= notice %></p>
 
-<%= t('home.configure.caption', :email => @user.email) %>
+<%= t('home.configure.caption', :email => @operators.user.email) %>
 <table class="no-border" width="100%">
   <tr>
     <td width="70%">
       <h2><%= t 'home.configure.password_caption' -%></h2>
-      <%= render '/users/registrations/form', :resource => @user %>
+      <%= render '/users/registrations/form', :resource => @operators.user %>
       <h2><%= t 'home.configure.token_caption' -%></h2>
-      <% if @user.authentication_token %>
-        <div><%= t 'home.configure.your_token', :token => @user.authentication_token -%></div>
+      <% if @operators.user.authentication_token %>
+        <div><%= t 'home.configure.your_token', :token => @operators.user.authentication_token -%></div>
         <%= link_to t('home.configure.delete_token'), :action => :delete_token %>
       <% else %>
         <div><%= t 'home.configure.about_token' -%></div>
     </td>
     <td width="30%">
       <h2><%= t_m 'Author' -%></h2>
-      <% if @author %>
-        <%= render '/authors/form', :au => @author %>
+      <% if @operators.author %>
+        <%= render '/authors/form', :author => @operators.author %>
       <% else %>
         <div><%= t 'home.configure.no_author' -%></div>
         <div><%= t 'home.configure.about_author' -%></div>
-        <% @au = Author.new ; @au.supply_default %>
-        <%= render '/authors/form', :au => @au %>
+        <% @author = Author.new ; @author.supply_default %>
+        <%= render '/authors/form', :author => @author %>
       <% end %>
       <h2><%= t_m 'Artist' -%></h2>
-      <% if @artist %>
-        <%= render '/artists/form', :ar => @artist %>
+      <% if @operators.artist %>
+        <%= render '/artists/form', :artist => @operators.artist %>
       <% else %>
         <div><%= t 'home.configure.no_artist' -%></div>
         <div><%= t 'home.configure.about_artist' -%></div>
-        <% @ar = Artist.new ; @ar.supply_default %>
-        <%= render '/artists/form', :ar => @ar %>
+        <% @artist = Artist.new ; @artist.supply_default %>
+        <%= render '/artists/form', :artist => @artist %>
       <% end %>
     </td>
   </tr>
index e819a26..1835131 100644 (file)
@@ -20,7 +20,7 @@
 <table class="no-border">\r
   <tr>\r
     <td width="50%">\r
-      <h3><%= link_to MagicNumber['profile']['users']['caption'], main_app.root_path %></h3>\r
+      <h3><%= link_to manifest.magic_numbers['profile']['users']['caption'], main_app.root_path %></h3>\r
     </td>\r
     <td width="30%">\r
       <% if user_signed_in? %>\r
     </td>\r
     <td>\r
       <div>\r
-        <% if @author %>\r
-          <%= link_to h(truncate(@author.name, :length => 12)), main_app.author_path(@author) %>\r
+        <% if @operators.author %>\r
+          <%= link_to h(truncate(@operators.author.name, :length => 12)), main_app.author_path(@operators.author) %>\r
         <% end %>\r
       </div>\r
       <div>\r
-        <% if @artist %>\r
-          <%= link_to h(truncate(@artist.name, :length => 12)), main_app.artist_path(@artist) %>\r
+        <% if @operators.artist %>\r
+          <%= link_to h(truncate(@operators.artist.name, :length => 12)), main_app.artist_path(@operators.artist) %>\r
         <% end %>\r
       </div>\r
     </td>\r
index 1ddb2cc..6faf50e 100644 (file)
@@ -18,7 +18,7 @@
 <div>\r
   <%= 'has_many' %>\r
 </div>\r
-<% profiler.each_belongs_to do |has_many_filer| %>\r
+<% profiler.each_has_many do |has_many_filer| %>\r
   <%= render 'system/filer.html', :filer => has_many_filer %>\r
 <% end %>\r
 <div>\r
index 3ac0765..4882d2e 100644 (file)
@@ -70,7 +70,7 @@ module Pettanr
       end
       
       def paginate
-        @model.list_paginate(@page, @page_size)
+        Kaminari.paginate_array(Array.new(@model.where(self.where()).includes(@model.list_opt).count, nil)).page(page).per(page_size)
       end
       
     end
@@ -104,7 +104,7 @@ module Pettanr
       end
       
       def paginate
-        @model.list_paginate(@page, @page_size)
+        Kaminari.paginate_array(Array.new(@model.where(self.where(parent_item)).includes(@model.list_opt).count, nil)).page(page).per(page_size)
       end
       
     end
@@ -122,12 +122,22 @@ module Pettanr
         @filter_key = @conf['filter_key']
       end
       
+      def where filter_item
+        w = @model.list_where
+        w += ' and ' unless w.blank?
+          p w
+          p @model.table_name
+          p @filter_key
+          p filter_item
+        [w + @model.table_name + '.' + @filter_key + ' = ?', filter_item.id] 
+      end
+      
       def items filter_item
-        @model.filtered_list filter_item, @filter_key, @operators, @page, @page_size
+        @model.where(self.where(filter_item)).includes(@model.list_opt).order(@model.list_order).offset(@offset).limit(@page_size)
       end
       
       def paginate filter_item
-        @model.list_paginate(filter_item, @filter_key, @operators, @page, @page_size)
+        Kaminari.paginate_array(Array.new(@model.where(self.where(filter_item)).includes(@model.list_opt).count, nil)).page(page).per(page_size)
       end
       
     end
index 1512dbb..30df16a 100644 (file)
@@ -120,10 +120,10 @@ module Pettanr
       
       def each_has_many
         @has_many_conf.each do |profiler_list_name|
-          model_name = @lists['model_name']
-          list_name = @lists['list_name']
+          model_name = @lists[profiler_list_name]['model_name']
+          list_name = @lists[profiler_list_name]['list_name']
           list = @manifest.list_managers[model_name].open(list_name, 1, 3, @operators)
-          items = list.items 
+          items = list.items @item
           has_many_filer = @manifest.filer_managers[model_name].open model_name, items, @operators, nil
           yield has_many_filer
         end
index 316bcbb..a0104fb 100644 (file)
@@ -7,6 +7,15 @@ class Operator
   end
   
   #InstanceMethods
+  def find_user
+    @operators.each do |operator|
+      return operator if operator.is_a?(User)
+      return operator.user if operator.is_a?(Author)
+      return operator.user if operator.is_a?(Artist)
+    end
+    nil
+  end
+  
   def find_author
     @operators.each do |operator|
       return operator if operator.is_a?(Author)
@@ -32,6 +41,11 @@ class Operator
     nil
   end
   
+  def user
+    return @user if @user
+    @user = find_user
+  end
+  
   def author
     return @author if @author
     @author = find_author