From ecf9b1a88198581aa2bbede0486ca93116d59d73 Mon Sep 17 00:00:00 2001 From: yasushiito Date: Thu, 25 Jun 2015 18:52:23 +0900 Subject: [PATCH] rails upgrade to 4 --- Gemfile | 15 ++++++----- app/controllers/application_controller.rb | 2 +- app/controllers/artists_controller.rb | 14 +++++----- app/controllers/authors_controller.rb | 14 +++++----- app/controllers/balloons_controller.rb | 10 ++++---- app/controllers/comic_stories_controller.rb | 14 +++++----- app/controllers/comics_controller.rb | 14 +++++----- app/controllers/demander_statuses_controller.rb | 2 +- app/controllers/demanders_controller.rb | 2 +- app/controllers/folders_controller.rb | 6 ++--- app/controllers/ground_colors_controller.rb | 10 ++++---- app/controllers/ground_pictures_controller.rb | 10 ++++---- app/controllers/home_controller.rb | 6 ++--- app/controllers/license_groups_controller.rb | 8 +++--- app/controllers/licenses_controller.rb | 8 +++--- .../original_picture_license_groups_controller.rb | 6 ++--- .../original_picture_licenses_controller.rb | 8 +++--- app/controllers/original_pictures_controller.rb | 6 ++--- app/controllers/panel_pictures_controller.rb | 10 ++++---- app/controllers/panels_controller.rb | 10 ++++---- app/controllers/pictures_controller.rb | 12 ++++----- app/controllers/provider_sources_controller.rb | 2 +- app/controllers/provider_statuses_controller.rb | 2 +- app/controllers/providers_controller.rb | 2 +- .../resource_picture_pictures_controller.rb | 6 ++--- app/controllers/resource_pictures_controller.rb | 14 +++++----- app/controllers/scroll_panels_controller.rb | 14 +++++----- app/controllers/scrolls_controller.rb | 14 +++++----- app/controllers/sheet_panels_controller.rb | 10 ++++---- app/controllers/sheets_controller.rb | 25 +++++++++--------- .../speech_balloon_templates_controller.rb | 8 +++--- app/controllers/speech_balloons_controller.rb | 10 ++++---- app/controllers/speeches_controller.rb | 12 ++++----- app/controllers/stories_controller.rb | 14 +++++----- app/controllers/story_sheets_controller.rb | 14 +++++----- app/controllers/system_controller.rb | 4 +-- app/controllers/system_pictures_controller.rb | 12 ++++----- app/controllers/top_controller.rb | 10 ++++---- app/controllers/user_sessions_controller.rb | 2 +- app/controllers/writing_formats_controller.rb | 12 ++++----- app/models/admin.rb | 18 ++++++------- app/models/artist.rb | 14 +++------- app/models/demand_user.rb | 7 +++-- app/models/folder.rb | 6 ++--- app/models/license.rb | 9 +++---- app/models/original_picture.rb | 16 ++++-------- app/models/picture.rb | 24 +++++++---------- app/models/resource_picture.rb | 2 +- app/models/scroll.rb | 30 ++++++++++++++++++++++ app/models/scroll_panel.rb | 30 ++++++++++++++++++---- app/models/user.rb | 7 +++-- app/models/writing_format.rb | 2 +- bin/bundle | 3 +++ {script => bin}/encode64.rb | 0 {script => bin}/gem_builder.rb | 0 {script => bin}/ls_helper.rb | 0 {script => bin}/panel_import.rb | 0 {script => bin}/preup.rb | 0 bin/rails | 4 +++ bin/rake | 4 +++ {script => bin}/sbt_helper.rb | 0 {script => bin}/uploader.rb | 0 config/application.rb | 1 - config/boot.rb | 5 +--- config/environments/development.rb | 8 ++---- config/environments/production.rb | 2 ++ config/environments/test.rb | 5 ++-- config/routes.rb | 8 +++--- config/secrets.yml | 8 ++++++ db/migrate/20120618023403_connect_story.rb | 8 +++--- db/migrate/20130911043458_copy_to_scroll.rb | 4 +-- .../20131205030518_artist_belongs_to_user_data.rb | 2 +- .../20140329222717_fix_extend_system_data.rb | 6 ++--- db/migrate/20140409095030_fix_ext_sys_pict_data.rb | 4 +-- ...20150330234954_gen_resource_picture_pictures.rb | 4 +-- lib/locmare/booster.rb | 2 +- lib/locmare/list_group/list/base.rb | 9 +++++-- lib/locmare/list_group/list/filter.rb | 5 ++++ lib/peta/content.rb | 2 +- lib/peta/item.rb | 11 +++++++- lib/peta/leaf.rb | 6 ++--- lib/peta/system_resource.rb | 2 +- lib/peta/template.rb | 2 +- script/cucumber | 10 -------- script/rails | 6 ----- 85 files changed, 361 insertions(+), 309 deletions(-) create mode 100644 bin/bundle rename {script => bin}/encode64.rb (100%) rename {script => bin}/gem_builder.rb (100%) rename {script => bin}/ls_helper.rb (100%) rename {script => bin}/panel_import.rb (100%) rename {script => bin}/preup.rb (100%) create mode 100644 bin/rails create mode 100644 bin/rake rename {script => bin}/sbt_helper.rb (100%) rename {script => bin}/uploader.rb (100%) create mode 100644 config/secrets.yml delete mode 100644 script/cucumber delete mode 100644 script/rails diff --git a/Gemfile b/Gemfile index 8951587d..0f08acde 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,8 @@ source 'https://rubygems.org' -gem 'rails', '~> 3.2.0' +gem 'rails', '~> 4.1.0' gem 'devise' -# gem 'devise_token_auth' +gem 'devise_token_auth' gem 'rest-client' gem 'underscore-rails' # gem 'backbone-rails' @@ -10,7 +10,8 @@ gem 'rails-timeago' gem 'kaminari' gem 'sanitize' gem 'aws-s3' -gem 'awesome_nested_set', '~> 2.0' +gem 'aws-sdk', '< 2.0' +gem 'awesome_nested_set', '~> 3.0' gem 'validates_existence' gem "validate_url" gem "pettanr_creative_commons_v30_licenses" @@ -28,13 +29,14 @@ gem 'pettanr_simple_format' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'i18n-js' +gem 'nokogiri' # Gems used only for assets and not required # in production environments by default. group :assets do - gem 'sass-rails', '~> 3.0' - gem 'coffee-rails', '~> 3.0' - gem 'uglifier', '>= 1.0.3' + gem 'sass-rails', '~> 4.0' + gem 'coffee-rails', '~> 4.0' + gem 'uglifier', '>= 1.3.0' # http://qiita.com/scivola/items/ec7625118fcf6de5203a gem 'coffee-script-source', '~> 1.8.0' end @@ -87,3 +89,4 @@ group :test do gem 'factory_girl' end +gem 'tzinfo-data' diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9072fb31..2b3138f4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,7 @@ class ApplicationController < ActionController::Base protect_from_forgery layout :devise_layout - before_filter :bf + before_action :bf def devise_layout if devise_controller? diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index e5e582db..4e7f9611 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -1,13 +1,13 @@ class ArtistsController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_artist, :only => [:edit, :update, :destroy] + before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_artist, :only => [:edit, :update, :destroy] else - before_filter :authenticate_resource_reader, :only => [ + before_action :authenticate_resource_reader, :only => [ :index, :show ] - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_artist, :only => [:edit, :update, :destroy] + before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_artist, :only => [:edit, :update, :destroy] end def index @@ -40,14 +40,14 @@ class ArtistsController < ApplicationController set_model @item = @my_model_class.new @item.supply_default - @item.attributes = params[@my_model_class.item_name] + @item.attributes = @item.permit_params params @item.overwrite @operators render_create root_path end def update set_edit - @item.attributes = params[@my_model_class.item_name] + @item.attributes = @item.permit_params params @item.overwrite @operators render_update '/home/configure' end diff --git a/app/controllers/authors_controller.rb b/app/controllers/authors_controller.rb index 2b01c915..320d74e7 100644 --- a/app/controllers/authors_controller.rb +++ b/app/controllers/authors_controller.rb @@ -1,11 +1,11 @@ class AuthorsController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [:new, :create, :edit, :update] - before_filter :authenticate_author, :only => [:edit, :update] + before_action :authenticate_user, :only => [:new, :create, :edit, :update] + before_action :authenticate_author, :only => [:edit, :update] else - before_filter :authenticate_reader, :only => [:index, :show] - before_filter :authenticate_user, :only => [:new, :create, :edit, :update] - before_filter :authenticate_author, :only => [:edit, :update] + before_action :authenticate_reader, :only => [:index, :show] + before_action :authenticate_user, :only => [:new, :create, :edit, :update] + before_action :authenticate_author, :only => [:edit, :update] end def index @@ -38,14 +38,14 @@ class AuthorsController < ApplicationController set_model @item = @my_model_class.new @item.supply_default - @item.attributes = params[@my_model_class.item_name] + @item.attributes = @item.permit_params params @item.overwrite @operators render_create root_path end def update set_edit - @item.attributes = params[@my_model_class.item_name] + @item.attributes = @item.permit_params params @item.overwrite @operators render_update '/home/configure' end diff --git a/app/controllers/balloons_controller.rb b/app/controllers/balloons_controller.rb index f9079cc1..95784aa4 100644 --- a/app/controllers/balloons_controller.rb +++ b/app/controllers/balloons_controller.rb @@ -1,14 +1,14 @@ class BalloonsController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] + before_action :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] + before_action :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] else - before_filter :authenticate_reader, :only => [ + before_action :authenticate_reader, :only => [ :index, :show, :by_author, :by_speech_balloon, :by_speech_balloon_template, :by_system_picture ] - before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] + before_action :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] + before_action :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] end def index diff --git a/app/controllers/comic_stories_controller.rb b/app/controllers/comic_stories_controller.rb index 120935b4..6b9d6e07 100644 --- a/app/controllers/comic_stories_controller.rb +++ b/app/controllers/comic_stories_controller.rb @@ -1,13 +1,13 @@ class ComicStoriesController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else - before_filter :authenticate_reader, :only => [ + before_action :authenticate_reader, :only => [ :index, :show, :by_story, :by_comic, :by_author ] - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] end def index @@ -50,7 +50,7 @@ class ComicStoriesController < ApplicationController set_model @item = @my_model_class.new @item.supply_default - @item.attributes = params[@item.item_name] + @item.attributes = @item.permit_params params @item.overwrite @operators @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id @panel = @my_model_class.destination_model.show(@item.destination_id, @operators) if @item.destination_id @@ -62,7 +62,7 @@ class ComicStoriesController < ApplicationController set_model @item = @my_model_class.edit(params[:id], @operators) ot = @item.t - @item.attributes = params[@item.item_name] + @item.attributes = @item.permit_params params @item.overwrite @operators @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id # no check permission for destination diff --git a/app/controllers/comics_controller.rb b/app/controllers/comics_controller.rb index 838d7d80..6acc8c9f 100644 --- a/app/controllers/comics_controller.rb +++ b/app/controllers/comics_controller.rb @@ -1,13 +1,13 @@ class ComicsController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else - before_filter :authenticate_reader, :only => [ + before_action :authenticate_reader, :only => [ :index, :show, :play, :by_story, :by_author ] - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] end def index @@ -70,7 +70,7 @@ class ComicsController < ApplicationController @item = @my_model_class.new @item.supply_default @my_model_class.fold_extend_settings params[@my_model_class.item_name] - @item.attributes = params[@my_model_class.item_name] + @item.attributes = @item.permit_params params @item.overwrite @operators render_create end @@ -78,7 +78,7 @@ class ComicsController < ApplicationController def update set_edit @my_model_class.fold_extend_settings params[@my_model_class.item_name] - @item.attributes = params[@my_model_class.item_name] + @item.attributes = @item.permit_params params @item.overwrite @operators render_update end diff --git a/app/controllers/demander_statuses_controller.rb b/app/controllers/demander_statuses_controller.rb index 32318ac4..1d947e0a 100644 --- a/app/controllers/demander_statuses_controller.rb +++ b/app/controllers/demander_statuses_controller.rb @@ -1,5 +1,5 @@ class DemanderStatusesController < ApplicationController - before_filter :authenticate_admin!, :only => [:index, :show, :edit, :update, :destroy] + before_action :authenticate_admin!, :only => [:index, :show, :edit, :update, :destroy] def index @page = DemanderStatus.page params[:page] diff --git a/app/controllers/demanders_controller.rb b/app/controllers/demanders_controller.rb index 92d4eeab..ac54721e 100644 --- a/app/controllers/demanders_controller.rb +++ b/app/controllers/demanders_controller.rb @@ -1,5 +1,5 @@ class DemandersController < ApplicationController - before_filter :authenticate_demand_user!, :only => [:index, :show, :new, :create, :edit, :update, :destroy, :req, :licenses_export, :artists_export, :original_pictures_export, :pictures_export, :export] + before_action :authenticate_demand_user!, :only => [:index, :show, :new, :create, :edit, :update, :destroy, :req, :licenses_export, :artists_export, :original_pictures_export, :pictures_export, :export] def index @demander = @demand_user.demander diff --git a/app/controllers/folders_controller.rb b/app/controllers/folders_controller.rb index f535d7af..73623fa4 100644 --- a/app/controllers/folders_controller.rb +++ b/app/controllers/folders_controller.rb @@ -1,9 +1,9 @@ class FoldersController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy] else - before_filter :authenticate_reader, :only => [:root, :index, :show, :watch] - before_filter :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_reader, :only => [:root, :index, :show, :watch] + before_action :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy] end def root diff --git a/app/controllers/ground_colors_controller.rb b/app/controllers/ground_colors_controller.rb index 0f031f96..7128abec 100644 --- a/app/controllers/ground_colors_controller.rb +++ b/app/controllers/ground_colors_controller.rb @@ -1,13 +1,13 @@ class GroundColorsController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [] - before_filter :authenticate_author, :only => [] + before_action :authenticate_user, :only => [] + before_action :authenticate_author, :only => [] else - before_filter :authenticate_reader, :only => [ + before_action :authenticate_reader, :only => [ :index, :show, :by_panel, :by_author ] - before_filter :authenticate_user, :only => [] - before_filter :authenticate_author, :only => [] + before_action :authenticate_user, :only => [] + before_action :authenticate_author, :only => [] end def index diff --git a/app/controllers/ground_pictures_controller.rb b/app/controllers/ground_pictures_controller.rb index db7c5534..2d90010c 100644 --- a/app/controllers/ground_pictures_controller.rb +++ b/app/controllers/ground_pictures_controller.rb @@ -1,13 +1,13 @@ class GroundPicturesController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [] - before_filter :authenticate_author, :only => [] + before_action :authenticate_user, :only => [] + before_action :authenticate_author, :only => [] else - before_filter :authenticate_reader, :only => [ + before_action :authenticate_reader, :only => [ :index, :show, :by_panel, :by_author ] - before_filter :authenticate_user, :only => [] - before_filter :authenticate_author, :only => [] + before_action :authenticate_user, :only => [] + before_action :authenticate_author, :only => [] end def index diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 38af1a30..6280b673 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,16 +1,16 @@ class HomeController < ApplicationController - before_filter :authenticate_user, :only => [ + before_action :authenticate_user, :only => [ :index, :show, :profile, :configure, :create_token, :delete_token, :scrolls, :scroll_panels, :comics, :comic_stories, :stories, :story_sheets, :sheets, :sheet_panels, :panels, :panel_pictures, :speech_balloons, :balloons, :speeches, :ground_pictures, :ground_colors ] - before_filter :authenticate_author, :only => [ + before_action :authenticate_author, :only => [ :scrolls, :scroll_panels, :comics, :comic_stories, :stories, :story_sheets, :sheets, :sheet_panels, :panels, :panel_pictures, :speech_balloons, :balloons, :speeches, :ground_pictures, :ground_colors ] - before_filter :authenticate_artist, :only => [:resource_pictures] + before_action :authenticate_artist, :only => [:resource_pictures] def index end diff --git a/app/controllers/license_groups_controller.rb b/app/controllers/license_groups_controller.rb index c4c487f9..b7ea646a 100644 --- a/app/controllers/license_groups_controller.rb +++ b/app/controllers/license_groups_controller.rb @@ -1,11 +1,11 @@ class LicenseGroupsController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 else - before_filter :authenticate_reader, :only => [ + before_action :authenticate_reader, :only => [ :by_resource_picture ] end - before_filter :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy] def index filer_list @@ -43,7 +43,7 @@ class LicenseGroupsController < ApplicationController @item = @my_model_class.new @item.supply_default @my_model_class.fold_extend_settings params[@my_model_class.item_name] - @item.attributes = params[@my_model_class.item_name] + @item.attributes = @item.permit_params params @item.overwrite render_create end @@ -51,7 +51,7 @@ class LicenseGroupsController < ApplicationController def update set_edit @my_model_class.fold_extend_settings params[@my_model_class.item_name] - @item.attributes = params[@my_model_class.item_name] + @item.attributes = @item.permit_params params @item.overwrite render_update end diff --git a/app/controllers/licenses_controller.rb b/app/controllers/licenses_controller.rb index cd697dda..bb7e49ae 100644 --- a/app/controllers/licenses_controller.rb +++ b/app/controllers/licenses_controller.rb @@ -1,8 +1,8 @@ class LicensesController < ApplicationController - before_filter :authenticate_resource_reader, :only => [ + before_action :authenticate_resource_reader, :only => [ :by_license_group, :by_system_picture ] - before_filter :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy] def index filer_list @@ -53,7 +53,7 @@ class LicensesController < ApplicationController @item = @my_model_class.new @item.supply_default @my_model_class.fold_extend_settings params[@my_model_class.item_name] - @item.attributes = params[@my_model_class.item_name] + @item.attributes = @item.permit_params params @item.overwrite render_create end @@ -61,7 +61,7 @@ class LicensesController < ApplicationController def update set_edit @my_model_class.fold_extend_settings params[@my_model_class.item_name] - @item.attributes = params[@my_model_class.item_name] + @item.attributes = @item.permit_params params @item.overwrite render_update end diff --git a/app/controllers/original_picture_license_groups_controller.rb b/app/controllers/original_picture_license_groups_controller.rb index 9b78878e..3f74b0e3 100644 --- a/app/controllers/original_picture_license_groups_controller.rb +++ b/app/controllers/original_picture_license_groups_controller.rb @@ -1,6 +1,6 @@ class OriginalPictureLicenseGroupsController < ApplicationController - before_filter :authenticate_user, :only => [:new, :create] - before_filter :authenticate_artist, :only => [:new, :create] + before_action :authenticate_user, :only => [:new, :create] + before_action :authenticate_artist, :only => [:new, :create] def new @original_picture = OriginalPicture.show params[:original_picture_id], @operators @@ -20,7 +20,7 @@ class OriginalPictureLicenseGroupsController < ApplicationController @item = @my_model_class.new @my_model_class.fold_extend_settings params[@my_model_class.item_name] - @item.attributes = params[@my_model_class.item_name] + @item.attributes = @item.permit_params params @item.overwrite @original_picture = OriginalPicture.show @item.original_picture, @operators diff --git a/app/controllers/original_picture_licenses_controller.rb b/app/controllers/original_picture_licenses_controller.rb index 9a6543e5..7300cb31 100644 --- a/app/controllers/original_picture_licenses_controller.rb +++ b/app/controllers/original_picture_licenses_controller.rb @@ -1,6 +1,6 @@ class OriginalPictureLicensesController < ApplicationController - before_filter :authenticate_user, :only => [:new, :create] - before_filter :authenticate_artist, :only => [:new, :create] + before_action :authenticate_user, :only => [:new, :create] + before_action :authenticate_artist, :only => [:new, :create] def new # use @item, @original_picture, @form @@ -15,14 +15,14 @@ class OriginalPictureLicensesController < ApplicationController @item = @my_model_class.new @my_model_class.fold_extend_settings params[@my_model_class.item_name] - @item.attributes = params[@my_model_class.item_name] + @item.attributes = @item.permit_params params @item.overwrite @item.boosts 'post' @original_picture = OriginalPicture.show @item.original_picture, @operators if @item.valid? # switch my_model_class - @item = OriginalPictureLicense.build_resource_picture @item, @original_picture, params[@my_model_class.item_name] + @item = OriginalPictureLicense.build_resource_picture @item, @original_picture, @item.permit_params(params) respond_to do |format| format.html { render main_app.new_resource_picture_path diff --git a/app/controllers/original_pictures_controller.rb b/app/controllers/original_pictures_controller.rb index 59c06788..5e70e363 100644 --- a/app/controllers/original_pictures_controller.rb +++ b/app/controllers/original_pictures_controller.rb @@ -1,8 +1,8 @@ #原画 class OriginalPicturesController < ApplicationController - before_filter :authenticate_reader, :only => [:show, :history] - before_filter :authenticate_user, :only => [:index, :new, :edit, :create, :update, :destroy] - before_filter :authenticate_artist, :only => [:index, :new, :edit, :create, :update, :destroy] + before_action :authenticate_reader, :only => [:show, :history] + before_action :authenticate_user, :only => [:index, :new, :edit, :create, :update, :destroy] + before_action :authenticate_artist, :only => [:index, :new, :edit, :create, :update, :destroy] def index filer_list diff --git a/app/controllers/panel_pictures_controller.rb b/app/controllers/panel_pictures_controller.rb index 3ae4dac9..87ee815e 100644 --- a/app/controllers/panel_pictures_controller.rb +++ b/app/controllers/panel_pictures_controller.rb @@ -1,13 +1,13 @@ class PanelPicturesController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [] - before_filter :authenticate_author, :only => [] + before_action :authenticate_user, :only => [] + before_action :authenticate_author, :only => [] else - before_filter :authenticate_reader, :only => [ + before_action :authenticate_reader, :only => [ :index, :show, :by_panel, :by_author ] - before_filter :authenticate_user, :only => [] - before_filter :authenticate_author, :only => [] + before_action :authenticate_user, :only => [] + before_action :authenticate_author, :only => [] end def index diff --git a/app/controllers/panels_controller.rb b/app/controllers/panels_controller.rb index 301b7741..805a4da3 100644 --- a/app/controllers/panels_controller.rb +++ b/app/controllers/panels_controller.rb @@ -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] - before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] + before_action :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] + before_action :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] else - before_filter :authenticate_reader, :only => [ + before_action :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] - before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] + before_action :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] + before_action :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] end private diff --git a/app/controllers/pictures_controller.rb b/app/controllers/pictures_controller.rb index 1dd8e5bb..bf72c918 100644 --- a/app/controllers/pictures_controller.rb +++ b/app/controllers/pictures_controller.rb @@ -1,15 +1,15 @@ class PicturesController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [] - before_filter :authenticate_author, :only => [] + before_action :authenticate_user, :only => [] + before_action :authenticate_author, :only => [] else - before_filter :authenticate_user, :only => [] - before_filter :authenticate_resource_reader, :only => [ + before_action :authenticate_user, :only => [] + before_action :authenticate_resource_reader, :only => [ :show, :credit, :search ] - before_filter :authenticate_author, :only => [] + before_action :authenticate_author, :only => [] end - before_filter :authenticate_admin, :only => [:index, :by_artist ] + before_action :authenticate_admin, :only => [:index, :by_artist ] def index filer_list diff --git a/app/controllers/provider_sources_controller.rb b/app/controllers/provider_sources_controller.rb index f4c48ba5..baf83a9e 100644 --- a/app/controllers/provider_sources_controller.rb +++ b/app/controllers/provider_sources_controller.rb @@ -1,5 +1,5 @@ class ProviderSourcesController < ApplicationController - before_filter :authenticate_admin!, :only => [:index, :import] + before_action :authenticate_admin!, :only => [:index, :import] def index @urls = MagicNumber['provider_sources'] diff --git a/app/controllers/provider_statuses_controller.rb b/app/controllers/provider_statuses_controller.rb index c91693e2..799bc75b 100644 --- a/app/controllers/provider_statuses_controller.rb +++ b/app/controllers/provider_statuses_controller.rb @@ -1,5 +1,5 @@ class ProviderStatusesController < ApplicationController - before_filter :authenticate_admin!, :only => [:index, :show, :edit, :update, :destroy, :licenses_import, :artists_import, :original_pictures_import, :import, :import_all] + before_action :authenticate_admin!, :only => [:index, :show, :edit, :update, :destroy, :licenses_import, :artists_import, :original_pictures_import, :import, :import_all] def index @page = ProviderStatus.page params[:page] diff --git a/app/controllers/providers_controller.rb b/app/controllers/providers_controller.rb index 88b6e875..526a465d 100644 --- a/app/controllers/providers_controller.rb +++ b/app/controllers/providers_controller.rb @@ -1,5 +1,5 @@ class ProvidersController < ApplicationController - before_filter :authenticate_admin!, :only => [:index, :show, :destroy] + before_action :authenticate_admin!, :only => [:index, :show, :destroy] def index @page = Provider.page params[:page] diff --git a/app/controllers/resource_picture_pictures_controller.rb b/app/controllers/resource_picture_pictures_controller.rb index 8a0ddc30..eb08b001 100644 --- a/app/controllers/resource_picture_pictures_controller.rb +++ b/app/controllers/resource_picture_pictures_controller.rb @@ -1,9 +1,9 @@ class ResourcePicturePicturesController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy] else - before_filter :authenticate_reader, :only => [:index, :show, :by_original_picture, :by_resource_picture, :by_picture] - before_filter :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_reader, :only => [:index, :show, :by_original_picture, :by_resource_picture, :by_picture] + before_action :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy] end def index diff --git a/app/controllers/resource_pictures_controller.rb b/app/controllers/resource_pictures_controller.rb index 27b1b31a..60972c4d 100644 --- a/app/controllers/resource_pictures_controller.rb +++ b/app/controllers/resource_pictures_controller.rb @@ -1,14 +1,14 @@ class ResourcePicturesController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [:new, :create, :update, :destroy] - before_filter :authenticate_artist, :only => [:new, :create, :update, :destroy] + before_action :authenticate_user, :only => [:new, :create, :update, :destroy] + before_action :authenticate_artist, :only => [:new, :create, :update, :destroy] else - before_filter :authenticate_resource_reader, :only => [ + before_action :authenticate_resource_reader, :only => [ :index, :show, :credit, :by_original_picture, :by_license_group, :by_license, :by_artist ] - before_filter :authenticate_user, :only => [:new, :create, :update, :destroy] - before_filter :authenticate_artist, :only => [:new, :create, :update, :destroy] + before_action :authenticate_user, :only => [:new, :create, :update, :destroy] + before_action :authenticate_artist, :only => [:new, :create, :update, :destroy] end def index @@ -73,9 +73,9 @@ class ResourcePicturesController < ApplicationController jsn = JSON.parse_no_except(params[:json]) end @prm = if params[:resource_picture] == nil or params[:resource_picture].empty? - jsn + jsn else - params[:resource_picture] + @item.permit_params(:resource_picture) end @item = @original_picture.resource_picture || ResourcePicture.new @item.attributes = @prm diff --git a/app/controllers/scroll_panels_controller.rb b/app/controllers/scroll_panels_controller.rb index a35d0b30..5d62976b 100644 --- a/app/controllers/scroll_panels_controller.rb +++ b/app/controllers/scroll_panels_controller.rb @@ -1,13 +1,13 @@ class ScrollPanelsController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else - before_filter :authenticate_reader, :only => [ + before_action :authenticate_reader, :only => [ :index, :show, :by_panel, :by_scroll, :by_author ] - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] end def index @@ -46,7 +46,7 @@ class ScrollPanelsController < ApplicationController set_model @item = @my_model_class.new @item.supply_default - @item.attributes = params[@item.item_name] + @item.attributes = @item.permit_params params @item.overwrite @operators @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id @panel = @my_model_class.destination_model.show(@item.destination_id, @operators) if @item.destination_id @@ -58,7 +58,7 @@ class ScrollPanelsController < ApplicationController set_model @item = @my_model_class.edit(params[:id], @operators) ot = @item.t - @item.attributes = params[@item.item_name] + @item.attributes = @item.permit_params params @item.overwrite @operators @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id # no check permission for destination diff --git a/app/controllers/scrolls_controller.rb b/app/controllers/scrolls_controller.rb index 246411f0..bed3e557 100644 --- a/app/controllers/scrolls_controller.rb +++ b/app/controllers/scrolls_controller.rb @@ -1,13 +1,13 @@ class ScrollsController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else - before_filter :authenticate_reader, :only => [ + before_action :authenticate_reader, :only => [ :top, :index, :show, :play, :by_panel, :by_author ] - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] end def index @@ -66,14 +66,14 @@ class ScrollsController < ApplicationController set_model @item = @my_model_class.new @item.supply_default - @item.attributes = params[@my_model_class.item_name] + @item.attributes = @item.permit_params params @item.overwrite @operators render_create end def update set_edit - @item.attributes = params[@my_model_class.item_name] + @item.attributes = @item.permit_params params @item.overwrite @operators render_update end diff --git a/app/controllers/sheet_panels_controller.rb b/app/controllers/sheet_panels_controller.rb index aaa19694..40d6c6a0 100644 --- a/app/controllers/sheet_panels_controller.rb +++ b/app/controllers/sheet_panels_controller.rb @@ -1,13 +1,13 @@ class SheetPanelsController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else - before_filter :authenticate_reader, :only => [ + before_action :authenticate_reader, :only => [ :index, :show, :by_sheet, :by_panel, :by_author ] - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] end def index diff --git a/app/controllers/sheets_controller.rb b/app/controllers/sheets_controller.rb index f0a14559..c2173aa1 100644 --- a/app/controllers/sheets_controller.rb +++ b/app/controllers/sheets_controller.rb @@ -1,13 +1,13 @@ class SheetsController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else - before_filter :authenticate_reader, :only => [ + before_action :authenticate_reader, :only => [ :index, :show, :play, :by_story, :by_panel, :by_author ] - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] end def index @@ -102,11 +102,11 @@ class SheetsController < ApplicationController set_model @item = @my_model_class.new @item.supply_default - jsn = nil - if params[:json] - jsn = JSON.parse_no_except(params[:json]) + @prm = if params[:json] + JSON.parse_no_except(params[:json]) + else + @item.permit_params params end - @prm = params[:sheet] || jsn respond_to do |format| if @item.store @prm, @operators @@ -122,10 +122,11 @@ class SheetsController < ApplicationController def update set_edit jsn = nil - if params[:json] - jsn = JSON.parse(params[:json]) + @prm = if params[:json] + JSON.parse(params[:json]) + else + @item.permit_params params end - @prm = params[:sheet] || jsn respond_to do |format| if @item.store @prm, @operators updated_html_format format diff --git a/app/controllers/speech_balloon_templates_controller.rb b/app/controllers/speech_balloon_templates_controller.rb index 2499e6e5..2b38a27c 100644 --- a/app/controllers/speech_balloon_templates_controller.rb +++ b/app/controllers/speech_balloon_templates_controller.rb @@ -1,13 +1,13 @@ class SpeechBalloonTemplatesController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [] + before_action :authenticate_user, :only => [] else - before_filter :authenticate_reader, :only => [ + before_action :authenticate_reader, :only => [ :index, :show, :by_panel, :by_system_picture ] - before_filter :authenticate_user, :only => [] + before_action :authenticate_user, :only => [] end - before_filter :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy] def index filer_list diff --git a/app/controllers/speech_balloons_controller.rb b/app/controllers/speech_balloons_controller.rb index 3b8e4002..c449f902 100644 --- a/app/controllers/speech_balloons_controller.rb +++ b/app/controllers/speech_balloons_controller.rb @@ -1,13 +1,13 @@ class SpeechBalloonsController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [] - before_filter :authenticate_author, :only => [] + before_action :authenticate_user, :only => [] + before_action :authenticate_author, :only => [] else - before_filter :authenticate_reader, :only => [ + before_action :authenticate_reader, :only => [ :index, :show, :by_panel, :by_author, :by_speech_balloon_template ] - before_filter :authenticate_user, :only => [] - before_filter :authenticate_author, :only => [] + before_action :authenticate_user, :only => [] + before_action :authenticate_author, :only => [] end def index diff --git a/app/controllers/speeches_controller.rb b/app/controllers/speeches_controller.rb index fb37d662..b09e05b0 100644 --- a/app/controllers/speeches_controller.rb +++ b/app/controllers/speeches_controller.rb @@ -1,16 +1,16 @@ class SpeechesController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] + before_action :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] + before_action :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] else - before_filter :authenticate_reader, :only => [ + before_action :authenticate_reader, :only => [ :index, :show, :by_author, :by_speech_balloon, :by_speech_balloon_template, :by_writing_format ] - before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] + before_action :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] + before_action :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] end - before_filter :authenticate_admin!, :only => [] + before_action :authenticate_admin!, :only => [] def index filer_list diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index 67ba22a9..6466664b 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -1,13 +1,13 @@ class StoriesController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else - before_filter :authenticate_reader, :only => [ + before_action :authenticate_reader, :only => [ :index, :show, :play, :by_comic, :by_sheet, :by_author ] - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] end def index @@ -73,7 +73,7 @@ class StoriesController < ApplicationController @story = @item @item = @my_model_class.new @item.supply_default - @item.attributes = params[@my_model_class.item_name] + @item.attributes = @item.permit_params params @item.overwrite @operators render_create end @@ -81,7 +81,7 @@ class StoriesController < ApplicationController def update set_edit @story = @item - @item.attributes = params[@my_model_class.item_name] + @item.attributes = @item.permit_params params @item.overwrite @operators render_update end diff --git a/app/controllers/story_sheets_controller.rb b/app/controllers/story_sheets_controller.rb index 262b5dac..6458220c 100644 --- a/app/controllers/story_sheets_controller.rb +++ b/app/controllers/story_sheets_controller.rb @@ -1,13 +1,13 @@ class StorySheetsController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else - before_filter :authenticate_reader, :only => [ + before_action :authenticate_reader, :only => [ :index, :show, :by_story, :by_sheet, :by_author ] - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] end def index @@ -46,7 +46,7 @@ class StorySheetsController < ApplicationController set_model @item = @my_model_class.new @item.supply_default - @item.attributes = params[@item.item_name] + @item.attributes = @item.permit_params params @item.overwrite @operators @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id @panel = @my_model_class.destination_model.show(@item.destination_id, @operators) if @item.destination_id @@ -58,7 +58,7 @@ class StorySheetsController < ApplicationController set_model @item = @my_model_class.edit(params[:id], @operators) ot = @item.t - @item.attributes = params[@item.item_name] + @item.attributes = @item.permit_params params @item.overwrite @operators @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id # no check permission for destination diff --git a/app/controllers/system_controller.rb b/app/controllers/system_controller.rb index be48d475..f5f8d956 100644 --- a/app/controllers/system_controller.rb +++ b/app/controllers/system_controller.rb @@ -1,5 +1,5 @@ class SystemController < ApplicationController - before_filter :authenticate_admin!, :except => [:start] + before_action :authenticate_admin!, :except => [:start] #layout :system @@ -64,7 +64,7 @@ class SystemController < ApplicationController end def waiting_list - @waits = Admin.find(:all, :conditions => ['approve = 0']) + @waits = Admin.where(approve: 0) end def accept_admin diff --git a/app/controllers/system_pictures_controller.rb b/app/controllers/system_pictures_controller.rb index 3917ca62..4b544d3c 100644 --- a/app/controllers/system_pictures_controller.rb +++ b/app/controllers/system_pictures_controller.rb @@ -1,13 +1,13 @@ class SystemPicturesController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [] - before_filter :authenticate_author, :only => [] + before_action :authenticate_user, :only => [] + before_action :authenticate_author, :only => [] else - before_filter :authenticate_resource_reader, :only => [:index, :show] - before_filter :authenticate_user, :only => [] - before_filter :authenticate_author, :only => [] + before_action :authenticate_resource_reader, :only => [:index, :show] + before_action :authenticate_user, :only => [] + before_action :authenticate_author, :only => [] end - before_filter :authenticate_admin!, :only => [] + before_action :authenticate_admin!, :only => [] def index filer_list diff --git a/app/controllers/top_controller.rb b/app/controllers/top_controller.rb index 91fb1d89..14f8f15a 100644 --- a/app/controllers/top_controller.rb +++ b/app/controllers/top_controller.rb @@ -1,11 +1,11 @@ class TopController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [] - before_filter :authenticate_author, :only => [] + before_action :authenticate_user, :only => [] + before_action :authenticate_author, :only => [] else - before_filter :authenticate_reader, :only => []#[:index] - before_filter :authenticate_user, :only => [] - before_filter :authenticate_author, :only => [] + before_action :authenticate_reader, :only => []#[:index] + before_action :authenticate_user, :only => [] + before_action :authenticate_author, :only => [] end def index diff --git a/app/controllers/user_sessions_controller.rb b/app/controllers/user_sessions_controller.rb index 93be44e2..52312a81 100644 --- a/app/controllers/user_sessions_controller.rb +++ b/app/controllers/user_sessions_controller.rb @@ -1,5 +1,5 @@ class UserSessionsController < Devise::SessionsController - prepend_before_filter :require_no_authentication, :only => [:create ] + prepend_before_action :require_no_authentication, :only => [:create ] respond_to :json def create diff --git a/app/controllers/writing_formats_controller.rb b/app/controllers/writing_formats_controller.rb index 0e4c6631..e6e8878e 100644 --- a/app/controllers/writing_formats_controller.rb +++ b/app/controllers/writing_formats_controller.rb @@ -1,13 +1,13 @@ class WritingFormatsController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [] + before_action :authenticate_user, :only => [] else - before_filter :authenticate_reader, :only => [ + before_action :authenticate_reader, :only => [ :index, :by_system_picture, :show ] - before_filter :authenticate_user, :only => [] + before_action :authenticate_user, :only => [] end - before_filter :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy] def index filer_list @@ -44,7 +44,7 @@ class WritingFormatsController < ApplicationController @item = @my_model_class.new @item.supply_default @my_model_class.fold_extend_settings params[@my_model_class.item_name] - @item.attributes = params[@my_model_class.item_name] + @item.attributes = @item.permit_params params @item.overwrite render_create end @@ -52,7 +52,7 @@ class WritingFormatsController < ApplicationController def update set_edit @my_model_class.fold_extend_settings params[@my_model_class.item_name] - @item.attributes = params[@my_model_class.item_name] + @item.attributes = @item.permit_params params @item.overwrite render_update end diff --git a/app/models/admin.rb b/app/models/admin.rb index 0788a942..5ec56f91 100644 --- a/app/models/admin.rb +++ b/app/models/admin.rb @@ -3,9 +3,6 @@ class Admin < ActiveRecord::Base # , :encryptable, :lockable, :timeoutable and :omniauthable, :confirmable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable - - # Setup accessible (or protected) attributes for your model - attr_accessible :email, :password, :password_confirmation, :remember_me def active_for_authentication? super && (self.approve == 1) @@ -27,15 +24,16 @@ class Admin < ActiveRecord::Base end def self.start(email, passwd) - a = Admin.find(:first, :conditions => ['email = ?', email]) - if a - a.password = passwd - a.password_confirmation = passwd - else - a = Admin.create! :email => email, :password => passwd, :password_confirmation => passwd - end + a = Admin.find_or_initialize_by(email: email) + a.password = passwd + a.password_confirmation = passwd a.approve = 1 a.save! end + private + def admin_params + params.require(:admin).permit(:email, :password, :password_confirmation, :remember_me, :authentication_token) + end + end diff --git a/app/models/artist.rb b/app/models/artist.rb index 3fc4bc9c..77dbf1f7 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -15,7 +15,7 @@ class Artist < Peta::Owner end def self.find_by_author author - Artist.find( :first, :conditions => ['author_id = ?', author.id]) + Artist.where(author_id: author.id).first end def self.index_list_where list @@ -27,15 +27,9 @@ class Artist < Peta::Owner end def self.export(dt = nil) - opt = {} - cond = if dt - ['artists.artists.provider = 0 and artists.updated_at >= ?', dt] - else - 'artists.artists.provider = 0' - end - opt.merge!({:conditions => cond}) - opt.merge!({:order => 'id'}) - Artist.find(:all, opt) + artists = Artist.where('artists.provider = 0') + artists = artists.where(['artists.updated_at >= ?', dt]) if dt + artists.order(:id) end end diff --git a/app/models/demand_user.rb b/app/models/demand_user.rb index 6c2a2c02..b92fda7f 100644 --- a/app/models/demand_user.rb +++ b/app/models/demand_user.rb @@ -5,8 +5,6 @@ class DemandUser < ActiveRecord::Base # :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable - # Setup accessible (or protected) attributes for your model - attr_accessible :email, :password, :password_confirmation, :remember_me def create_token self.ensure_authentication_token @@ -18,4 +16,9 @@ class DemandUser < ActiveRecord::Base self.save end + private + def demand_user_params + params.require(:demand_user).permit(:email, :password, :password_confirmation, :remember_me, :authentication_token) + end + end diff --git a/app/models/folder.rb b/app/models/folder.rb index e004a57c..e66fbb20 100644 --- a/app/models/folder.rb +++ b/app/models/folder.rb @@ -31,7 +31,7 @@ class Folder < Peta::SystemResource attr = { :name => key, :category_id => 0, :t => 0 } - if i = self.find_by_name(key) + if i = self.find_by(name: key) i.attributes = attr i.save else @@ -48,7 +48,7 @@ class Folder < Peta::SystemResource :controller_name => (controller_name || name), :action_name => action_name } - if i = self.find_by_name(key) + if i = self.find_by(name: key) i.attributes = attr i.save else @@ -59,7 +59,7 @@ class Folder < Peta::SystemResource end def self.generate - if r = self.find_by_name('/') + if r = self.find_by(name: '/') else r = self.create :name => '/', :category_id => 0, :t => 0 end diff --git a/app/models/license.rb b/app/models/license.rb index 009f51ef..0ebfe564 100644 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -30,7 +30,7 @@ class License < Peta::SystemResource end def self.list_by_name name - License.find :all, :conditions => ['licenses.name = ?', name], :order => 'licenses.updated_at desc' + License.where(name: name).order(updated_at: :desc) end def self.store name, attr @@ -59,10 +59,9 @@ class License < Peta::SystemResource end def self.export(dt = nil) - opt = {} - opt.merge!({:conditions => ['updated_at >= ?', dt]}) if dt -# opt.merge!({:order => 'name'}) - License.find(:all, opt) + licenses = License.all + licenses = licenses.where(['licenses.updated_at >= ?', dt]) if dt + licenses.order(:id) end end diff --git a/app/models/original_picture.rb b/app/models/original_picture.rb index 65d99d16..883b1df8 100644 --- a/app/models/original_picture.rb +++ b/app/models/original_picture.rb @@ -79,7 +79,7 @@ class OriginalPicture < Peta::Content end def history - Picture.find(:all, {:conditions => ['pictures.original_picture_id = ?', self.id], :order => 'pictures.revision desc'} ) + Picture.where(original_picture_id: self.id).order(revision: :desc) end def self.show_opt @@ -112,15 +112,9 @@ class OriginalPicture < Peta::Content end def self.export(dt = nil) - opt = {} - cond = if dt - ['artists.author_id is not null and original_pictures.updated_at >= ?', dt] - else - 'artists.author_id is not null' - end - opt.merge!({:conditions => cond}) - opt.merge!({:include => {:resource_picture => {}, :artist => {}}, :order => 'original_pictures.id'}) - OriginalPicture.find(:all, opt) + original_pictures = OriginalPicture.includes(:resource_picture, :artist).where('artists.author_id is not null') + original_pictures = original_pictures.where(['original_pictures.updated_at >= ?', dt]) if dt + original_pictures.order('original_pictures.id').references(:artist) end def list_as_json_with_resource_picture @@ -160,7 +154,7 @@ class OriginalPicture < Peta::Content end def self.publish oid, lsname, attr - l = License.find_by_name lsname + l = License.find_by(name: lsname) op = OriginalPicture.find oid lg = l.license_group attr[:license_id] = l.id diff --git a/app/models/picture.rb b/app/models/picture.rb index 39645a76..ec914f3d 100644 --- a/app/models/picture.rb +++ b/app/models/picture.rb @@ -90,7 +90,7 @@ class Picture < Peta::Content end def new_revision - Picture.maximum(:revision, :conditions => ['original_picture_id = ?', self.original_picture_id]).to_i + 1 + Picture.where(original_picture_id: self.original_picture_id).maximum(:revision).to_i + 1 end def enable? @@ -99,7 +99,7 @@ class Picture < Peta::Content end def self.head opid - Picture.find(:first, :conditions => ['original_picture_id = ?', opid], :order => 'pictures.revision desc') + Picture.where(original_picture_id: opid).order('pictures.revision desc').first end def head @@ -119,16 +119,16 @@ class Picture < Peta::Content end def self.find_by_md5 md5 - r = Picture.find :all, :conditions => ['pictures.md5 = ?', md5], :order => 'pictures.updated_at desc' + r = Picture.where(md5: md5).order(updated_at: :desc) end def self.list_by_md5 md5, opid = nil cond = if opid.blank? - ['pictures.md5 = ?', md5] + {md5: md5} else - ['pictures.md5 = ? and pictures.original_picture_id <> ?', md5, opid] + ['md5 = :md5 and original_picture_id <> :opid', {md5: md5, opid: opid}] end - r = Picture.find :all, :conditions => cond, :order => 'pictures.updated_at desc' + r = Picture.where(cond).order(updated_at: :desc) end def self.exist_by_md5 md5, opid @@ -182,15 +182,9 @@ class Picture < Peta::Content end def self.export(dt = nil) - opt = {} - cond = if dt - ['artists.author_id is not null and pictures.updated_at >= ?', dt] - else - 'artists.author_id is not null' - end - opt.merge!({:conditions => cond}) - opt.merge!({:include => {:artist => {}}, :order => 'pictures.updated_at desc'}) - Picture.find(:all, opt) + pictures = Picture.includes(:artist).where('artists.author_id is not null') + pictures = pictures.where(['pictures.updated_at >= ?', dt]) if dt + pictures.order('pictures.updated_at desc').references(:artist) end def self.list_as_json_text ary diff --git a/app/models/resource_picture.rb b/app/models/resource_picture.rb index e087b995..3488ab04 100644 --- a/app/models/resource_picture.rb +++ b/app/models/resource_picture.rb @@ -235,7 +235,7 @@ class ResourcePicture < Peta::Content end def self.remake_all - ResourcePicture.find(:all).each do |resource_picture| + ResourcePicture.find_each do |resource_picture| resource_picture.boosts 'post' full = resource_picture.restore 'full' imager = PettanImager.load full diff --git a/app/models/scroll.rb b/app/models/scroll.rb index a2066621..b7484144 100644 --- a/app/models/scroll.rb +++ b/app/models/scroll.rb @@ -3,10 +3,40 @@ class Scroll < Peta::Binder has_many :scroll_panels belongs_to :author + has_many :panels, :through => :scroll_panels + validates :title, :presence => true, :length => {:maximum => 100} validates :visible, :presence => true, :numericality => true, :inclusion => {:in => 0..1} validates :author_id, :presence => true, :numericality => true, :existence => {:both => false} + scope :find_index, -> do + where(arel_table[:visible].gt 0) + end + + scope :find_private, -> (operators) do + where(author_id: operators.author.id) + end + + scope :find_by_author, -> (author_id) do + find_index.where(author_id: author_id) + end + + scope :with_panels, -> do + includes(scroll_panels: :panel) + end + + scope :find_by_panel, -> (panel_id) do + with_panels.find_index.where(Panel.arel_table[:id].eq panel_id).references(:panel) + end + + scope :find_play, -> (id) do + with_panels.find_index.where(id: id).references(:scroll_panels) + end + + scope :find_private_play, -> (id, operators) do + with_panels.find_private(operators).where(self.arel_table[:id].eq id).references(:scroll_panels) + end + def supply_default self.visible = 0 if self.visible.blank? self.author_id = nil diff --git a/app/models/scroll_panel.rb b/app/models/scroll_panel.rb index 12fab0f6..913cf578 100644 --- a/app/models/scroll_panel.rb +++ b/app/models/scroll_panel.rb @@ -8,6 +8,30 @@ class ScrollPanel < Peta::Leaf validates :panel_id, :presence => true, :numericality => true, :existence => {:both => false} validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0} + scope :with_scroll, -> do + includes(:scroll) + end + + scope :find_index, -> do + with_scroll.where(Scroll.arel_table[:visible].gt 0).references(:scroll) + end + + scope :find_private, -> (operators) do + with_scroll.where(Scroll.arel_table[:author_id].eq operators.author.id).references(:scroll) + end + + scope :find_by_scroll, -> (scroll_id) do + find_index.where(scroll_id: scroll_id).references(:scroll) + end + + scope :find_by_panel, -> (panel_id) do + find_index.where(panel_id: panel_id).references(:scroll) + end + + scope :find_by_author, -> (author_id) do + find_index.where(Scroll.arel_table[:author_id].eq author_id).references(:scroll) + end + def supply_default self.scroll_id = nil self.panel_id = nil @@ -22,11 +46,7 @@ class ScrollPanel < Peta::Leaf end def self.by_author_list_includes - { - :scroll => { - :author => {} - } - } + [:scroll => :author] end def self.show_opt diff --git a/app/models/user.rb b/app/models/user.rb index 20c2250d..11d7d12f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -7,8 +7,6 @@ class User < ActiveRecord::Base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable#, :confirmable - # Setup accessible (or protected) attributes for your model - attr_accessible :id, :name, :password, :password_confirmation, :remember_me , :email def create_token self.ensure_authentication_token @@ -42,4 +40,9 @@ class User < ActiveRecord::Base res end + private + def user_params + params.require(:user).permit(:email, :password, :password_confirmation, :remember_me, :authentication_token) + end + end diff --git a/app/models/writing_format.rb b/app/models/writing_format.rb index 7060fb2b..850d7353 100644 --- a/app/models/writing_format.rb +++ b/app/models/writing_format.rb @@ -31,7 +31,7 @@ def self.list end def self.enable_list include_available = false - r = WritingFormat.find(:all) + r = WritingFormat.all unless include_available r.delete_if {|wf| wf.enable? == false diff --git a/bin/bundle b/bin/bundle new file mode 100644 index 00000000..e3c2f622 --- /dev/null +++ b/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby.exe +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/script/encode64.rb b/bin/encode64.rb similarity index 100% rename from script/encode64.rb rename to bin/encode64.rb diff --git a/script/gem_builder.rb b/bin/gem_builder.rb similarity index 100% rename from script/gem_builder.rb rename to bin/gem_builder.rb diff --git a/script/ls_helper.rb b/bin/ls_helper.rb similarity index 100% rename from script/ls_helper.rb rename to bin/ls_helper.rb diff --git a/script/panel_import.rb b/bin/panel_import.rb similarity index 100% rename from script/panel_import.rb rename to bin/panel_import.rb diff --git a/script/preup.rb b/bin/preup.rb similarity index 100% rename from script/preup.rb rename to bin/preup.rb diff --git a/bin/rails b/bin/rails new file mode 100644 index 00000000..b9f87878 --- /dev/null +++ b/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby.exe +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/bin/rake b/bin/rake new file mode 100644 index 00000000..f6ed5a2a --- /dev/null +++ b/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby.exe +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/script/sbt_helper.rb b/bin/sbt_helper.rb similarity index 100% rename from script/sbt_helper.rb rename to bin/sbt_helper.rb diff --git a/script/uploader.rb b/bin/uploader.rb similarity index 100% rename from script/uploader.rb rename to bin/uploader.rb diff --git a/config/application.rb b/config/application.rb index 17af8a03..e3586812 100644 --- a/config/application.rb +++ b/config/application.rb @@ -4,7 +4,6 @@ require File.expand_path('../boot', __FILE__) require "active_record/railtie" require "action_controller/railtie" require "action_mailer/railtie" -require "active_resource/railtie" require "sprockets/railtie" # require "rails/test_unit/railtie" require 'digest/md5' diff --git a/config/boot.rb b/config/boot.rb index 4489e586..6b750f00 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,6 +1,3 @@ -require 'rubygems' - -# Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/environments/development.rb b/config/environments/development.rb index e16e8c43..72d98a80 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -15,9 +15,6 @@ end # since you don't have to restart the web server when you make code changes. config.cache_classes = false - # Log error messages when you accidentally call methods on nil. - config.whiny_nils = true - # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = false @@ -28,9 +25,6 @@ end # Print deprecation notices to the Rails logger config.active_support.deprecation = :log - # Only use best-standards-support built into browsers - config.action_dispatch.best_standards_support = :builtin - # Do not compress assets config.assets.compress = false @@ -39,5 +33,7 @@ end # config.assets.digest = true # config.static_cache_control = "public, max-age=1" +config.eager_load = false +config.active_record.migration_error = :page_load end diff --git a/config/environments/production.rb b/config/environments/production.rb index 12104b07..3e74fdde 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -61,6 +61,8 @@ config.assets.precompile += %w( *.css *.js ) # Send deprecation notices to registered listeners config.active_support.deprecation = :notify +config.eager_load = true +config.active_record.migration_error = :page_load end require 'aws/s3' require 'yaml' diff --git a/config/environments/test.rb b/config/environments/test.rb index 3ceac7c9..a3e7fdd1 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -11,9 +11,6 @@ Pettanr::Application.configure do config.serve_static_assets = true config.static_cache_control = "public, max-age=3600" - # Log error messages when you accidentally call methods on nil - config.whiny_nils = true - # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = false @@ -36,6 +33,8 @@ Pettanr::Application.configure do # Print deprecation notices to the stderr config.active_support.deprecation = :stderr +config.eager_load = false +config.active_record.migration_error = :page_load end module Pettanr diff --git a/config/routes.rb b/config/routes.rb index e159c8a2..b3c1a9b5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -548,9 +548,9 @@ Pettanr::Application.routes.draw do # match 'resource_pictures/full/:id(.:format)/' => 'resource_pictures#show' # match 'pictures/:subdir/:id(.:format)/' => 'pictures#show' #match 'scroll_panels/scroll/:id(.:format)' => 'scroll_panels#scroll' - match 'top/(:action)', :controller => 'top' - match 'home/(:action)', :controller => 'home' - match 'system/(:action)', :controller => 'system' + match 'top/(:action)', :controller => 'top', via: [:get] + match 'home/(:action)', :controller => 'home', via: [:get] + match 'system/(:action)', :controller => 'system', via: [:get, :post] #match 'authors/(:action(/:id))', :controller => 'authors' # Sample of named route: @@ -601,5 +601,5 @@ Pettanr::Application.routes.draw do # This is a legacy wild controller route that's not recommended for RESTful applications. # Note: This route will make all actions in every controller accessible via GET requests. - match ':controller(/:action(/:id(.:format)))' + match ':controller(/:action(/:id(.:format)))', via: [:get, :post] end diff --git a/config/secrets.yml b/config/secrets.yml new file mode 100644 index 00000000..19d32f83 --- /dev/null +++ b/config/secrets.yml @@ -0,0 +1,8 @@ +development: + secret_key_base: 6809ff947425908bae66f4c4b2d9a88366d900609d88034914d5719ddf434123772c9cd26fd9d0a15fa080164c6fef77d74033a05de57f0694df0d52dad4e37a + +test: + secret_key_base: 6809ff947425908bae66f4c4b2d9a88366d900609d88034914d5719ddf434123772c9cd26fd9d0a15fa080164c6fef77d74033a05de57f0694df0d52dad4e37a + +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/db/migrate/20120618023403_connect_story.rb b/db/migrate/20120618023403_connect_story.rb index 1806125c..efae69de 100644 --- a/db/migrate/20120618023403_connect_story.rb +++ b/db/migrate/20120618023403_connect_story.rb @@ -1,12 +1,11 @@ class ConnectStory < ActiveRecord::Migration def up - pn = Panel.find :all - pn.each do |i| + pn = Panel.find_each do |i| c = i.comic_id t = i.t a = i.author_id s = i.id - st = Story.find(:first, :conditions => ['comic_id = ? and panel_id = ? and t = ?', c, s, t]) + st = Story.where(['comic_id = ? and panel_id = ? and t = ?', c, s, t]).first st = Story.new(:comic_id => c, :panel_id => s, :t => t) unless st st.author_id = a st.save! @@ -22,8 +21,7 @@ class ConnectStory < ActiveRecord::Migration add_column :panels, :comic_id, :integer, :null => false, :default => 0 add_column :panels, :t, :integer, :null => false, :default => 0 remove_column :panels, :publish - st = Story.find :all - st.each do |i| + st = Story.find_each do |i| c = i.comic_id t = i.t pn = Panel.find(i.panel_id) diff --git a/db/migrate/20130911043458_copy_to_scroll.rb b/db/migrate/20130911043458_copy_to_scroll.rb index 37f9f544..b93852de 100644 --- a/db/migrate/20130911043458_copy_to_scroll.rb +++ b/db/migrate/20130911043458_copy_to_scroll.rb @@ -1,12 +1,12 @@ require Rails.root + 'config/environment' class CopyToScroll < ActiveRecord::Migration def up - ::Comic.find(:all).each do |i| + ::Comic.find_each do |i| attr = i.attributes attr.delete 'id' ::Scroll.create! attr end - ::Story.find(:all).each do |i| + ::Story.find_each do |i| attr = i.attributes attr.delete 'id' attr.delete 'x' diff --git a/db/migrate/20131205030518_artist_belongs_to_user_data.rb b/db/migrate/20131205030518_artist_belongs_to_user_data.rb index 51eef280..35547c2d 100644 --- a/db/migrate/20131205030518_artist_belongs_to_user_data.rb +++ b/db/migrate/20131205030518_artist_belongs_to_user_data.rb @@ -1,6 +1,6 @@ class ArtistBelongsToUserData < ActiveRecord::Migration def up - Artist.find(:all).each do |artist| + Artist.find_each do |artist| if artist.author_id artist.user_id = Author.find(artist.author_id).user_id else diff --git a/db/migrate/20140329222717_fix_extend_system_data.rb b/db/migrate/20140329222717_fix_extend_system_data.rb index 78682313..6e87e622 100644 --- a/db/migrate/20140329222717_fix_extend_system_data.rb +++ b/db/migrate/20140329222717_fix_extend_system_data.rb @@ -1,6 +1,6 @@ class FixExtendSystemData < ActiveRecord::Migration def up - Balloon.find(:all).each do |balloon| + Balloon.find_each do |balloon| sbt = balloon.speech_balloon.speech_balloon_template if balloon.speech_balloon_template_classname == 'noname' balloon.speech_balloon_template_id = sbt.id @@ -9,7 +9,7 @@ class FixExtendSystemData < ActiveRecord::Migration end balloon.save! end - Speech.find(:all).each do |speech| + Speech.find_each do |speech| sbt = speech.speech_balloon.speech_balloon_template if speech.speech_balloon_template_classname == 'noname' speech.speech_balloon_template_id = sbt.id @@ -22,7 +22,7 @@ class FixExtendSystemData < ActiveRecord::Migration speech.boosts 'post' speech.save! end - License.find(:all).each do |license| + License.find_each do |license| lg = license.license_group if license.license_group_classname == 'noname' license.license_group_classname = lg.classname diff --git a/db/migrate/20140409095030_fix_ext_sys_pict_data.rb b/db/migrate/20140409095030_fix_ext_sys_pict_data.rb index c1299f3a..23a4bd6f 100644 --- a/db/migrate/20140409095030_fix_ext_sys_pict_data.rb +++ b/db/migrate/20140409095030_fix_ext_sys_pict_data.rb @@ -1,11 +1,11 @@ class FixExtSysPictData < ActiveRecord::Migration def up - ResourcePicture.find(:all).each do |resource_picture| + ResourcePicture.find_each do |resource_picture| license = resource_picture.license resource_picture.credit_picture_settings = license.credit_picture_settings resource_picture.save! end - Picture.find(:all).each do |picture| + Picture.find_each do |picture| license = picture.license picture.credit_picture_settings = license.credit_picture_settings picture.save! diff --git a/db/migrate/20150330234954_gen_resource_picture_pictures.rb b/db/migrate/20150330234954_gen_resource_picture_pictures.rb index b143c958..31e01287 100644 --- a/db/migrate/20150330234954_gen_resource_picture_pictures.rb +++ b/db/migrate/20150330234954_gen_resource_picture_pictures.rb @@ -1,7 +1,7 @@ class GenResourcePicturePictures < ActiveRecord::Migration def up - Picture.find(:all).each do |picture| - resource_picture_picture = ResourcePicturePicture.find(:first, {:conditions => ['picture_id = ?', picture.id]}) + Picture.find_each do |picture| + resource_picture_picture = ResourcePicturePicture.where(['picture_id = ?', picture.id]}).first opid = picture.original_picture ? picture.original_picture.id : nil rpid = picture.original_picture.resource_picture ? picture.original_picture.resource_picture.id : nil if resource_picture_picture diff --git a/lib/locmare/booster.rb b/lib/locmare/booster.rb index 8fef2360..be64fa15 100644 --- a/lib/locmare/booster.rb +++ b/lib/locmare/booster.rb @@ -1,6 +1,6 @@ module Locmare class Booster - attr :boost + attr :boost, :manifest def initialize manifest, item @manifest = manifest diff --git a/lib/locmare/list_group/list/base.rb b/lib/locmare/list_group/list/base.rb index bc15c90f..75e8d90c 100644 --- a/lib/locmare/list_group/list/base.rb +++ b/lib/locmare/list_group/list/base.rb @@ -3,7 +3,7 @@ module Locmare class Base attr_accessor :list_group_name, :list_name, :operators, :options, :item_name, :controller_manifest, :action_manifest, :list_manifest, :model, :table_name, - :page_status, :item_wheres, :list_wheres + :page_status, :item_wheres, :list_wheres, :wheres def initialize list_group_name, list_name, operators, options = {} @list_group_name = list_group_name @@ -90,11 +90,16 @@ module Locmare def arel r = @model + return @model.__send__('find_' + @action_name) + + r.includes( + self.include_hash + ) @wheres.each do |key| n = key + '_list_where' r = r.where(@model.respond_to?(n) ? @model.__send__(n, self) : self.__send__(n)) end - r.includes( + r.references( self.include_hash ) end diff --git a/lib/locmare/list_group/list/filter.rb b/lib/locmare/list_group/list/filter.rb index 846d60fa..b2d4bf8a 100644 --- a/lib/locmare/list_group/list/filter.rb +++ b/lib/locmare/list_group/list/filter.rb @@ -31,6 +31,11 @@ module Locmare r end + def arel + r = @model + return @model.__send__('find_' + @action_name, self.filter_id) + end + end end diff --git a/lib/peta/content.rb b/lib/peta/content.rb index 11050f49..65a10fa6 100644 --- a/lib/peta/content.rb +++ b/lib/peta/content.rb @@ -39,7 +39,7 @@ module Peta end def self.edit content_id, operators - content = self.find content_id, self.show_opt + content = self.find content_id raise ActiveRecord::Forbidden unless content.own?(operators) content end diff --git a/lib/peta/item.rb b/lib/peta/item.rb index b6f2ca6b..b23dd20c 100644 --- a/lib/peta/item.rb +++ b/lib/peta/item.rb @@ -129,7 +129,7 @@ module Peta def self.show item_id, operators = nil opt = {} opt.merge!(self.show_opt) - item = self.find(item_id, opt) + item = self.find(item_id) item.boosts 'read' raise ActiveRecord::Forbidden if operators and item.visible?(operators) == false item @@ -154,6 +154,10 @@ module Peta #InstanceMethods + def my_manifest + self.class.my_manifest + end + def singular self.class.singular end @@ -251,6 +255,11 @@ module Peta true end + def permit_params params + attrs = self.my_manifest.attributes.keys + params.require(self.item_name).permit(attrs) + end + def editize? self.respond_to? :editor end diff --git a/lib/peta/leaf.rb b/lib/peta/leaf.rb index 4ed0c3c4..a736a719 100644 --- a/lib/peta/leaf.rb +++ b/lib/peta/leaf.rb @@ -71,15 +71,15 @@ module Peta end def self.max_t binder_id - self.maximum(:t, :conditions => [self.binder_key + ' = ?', binder_id]) + self.where([self.binder_key + ' = ?', binder_id]).maximum(:t) end def self.find_t binder_id, t - self.find(:first, :conditions => [self.binder_key + ' = ? and t = ?', binder_id, t]) + self.where([self.binder_key + ' = ? and t = ?', binder_id, t]).first end def self.collect_t binder_id - r = self.find(:all, :conditions => [self.binder_key + ' = ?', binder_id], :order => 't') + r = self.where([self.binder_key + ' = ?', binder_id]).order('t') r.map {|sp| sp.t} end diff --git a/lib/peta/system_resource.rb b/lib/peta/system_resource.rb index 7799ed3c..1fdabd06 100644 --- a/lib/peta/system_resource.rb +++ b/lib/peta/system_resource.rb @@ -7,7 +7,7 @@ module Peta # ClassMethods def self.edit system_resource_id, operators - system_resource = self.find system_resource_id, self.show_opt + system_resource = self.find system_resource_id raise ActiveRecord::Forbidden unless system_resource.own?(operators) system_resource end diff --git a/lib/peta/template.rb b/lib/peta/template.rb index 097b306c..e7faa6f4 100644 --- a/lib/peta/template.rb +++ b/lib/peta/template.rb @@ -7,7 +7,7 @@ module Peta # ClassMethods def self.enable_list - self.find(:all).delete_if {|i| + self.all.delete_if {|i| i.enable? == false } end diff --git a/script/cucumber b/script/cucumber deleted file mode 100644 index 7fa5c920..00000000 --- a/script/cucumber +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env ruby - -vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first -if vendored_cucumber_bin - load File.expand_path(vendored_cucumber_bin) -else - require 'rubygems' unless ENV['NO_RUBYGEMS'] - require 'cucumber' - load Cucumber::BINARY -end diff --git a/script/rails b/script/rails deleted file mode 100644 index 81eab02f..00000000 --- a/script/rails +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby.exe -# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. - -APP_PATH = File.expand_path('../../config/application', __FILE__) -require File.expand_path('../../config/boot', __FILE__) -require 'rails/commands' -- 2.11.0