mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-01-13 13:21:29 +00:00
Fix deprecated finds
This commit is contained in:
parent
39ce9c613f
commit
e855b46bd9
7 changed files with 15 additions and 7 deletions
|
@ -47,7 +47,7 @@ class GroupsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def addUser
|
def addUser
|
||||||
@user = User.first conditions: {username: params[:username]}
|
@user = User.where(username: params[:username])
|
||||||
raise AccessError unless @group.can_update? cuser
|
raise AccessError unless @group.can_update? cuser
|
||||||
raise Error, t(:duplicate_user) if @group.users.include? @user
|
raise Error, t(:duplicate_user) if @group.users.include? @user
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ class ServersController < ApplicationController
|
||||||
before_action :get_server, except: [:index, :refresh, :new, :create]
|
before_action :get_server, except: [:index, :refresh, :new, :create]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@servers = Server.hlds.active.ordered.all :include => :user
|
@servers = Server.hlds.active.ordered.includes(:user).all
|
||||||
@ns2 = Server.ns2.active.ordered.all :include => :user
|
@ns2 = Server.ns2.active.ordered.includes(:user).all
|
||||||
@officials = Server.ns2.active.ordered.where ["name LIKE ?", "%NSL%"]
|
@officials = Server.ns2.active.ordered.where ["name LIKE ?", "%NSL%"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -178,6 +178,7 @@ module ApplicationHelper
|
||||||
f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)")
|
f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# FIXME: this won't work.
|
||||||
def link_to_add_fields(name, f, association)
|
def link_to_add_fields(name, f, association)
|
||||||
new_object = f.object.class.reflect_on_association(association).klass.new
|
new_object = f.object.class.reflect_on_association(association).klass.new
|
||||||
fields = f.fields_for(association, new_object, child_index: "new_#{association}") do |builder|
|
fields = f.fields_for(association, new_object, child_index: "new_#{association}") do |builder|
|
||||||
|
|
|
@ -121,11 +121,11 @@ class Article < ActiveRecord::Base
|
||||||
if (new_record? or status_changed?) and status == STATUS_PUBLISHED
|
if (new_record? or status_changed?) and status == STATUS_PUBLISHED
|
||||||
case category.domain
|
case category.domain
|
||||||
when Category::DOMAIN_NEWS
|
when Category::DOMAIN_NEWS
|
||||||
Profile.includes(:user).all(conditions: "notify_news = 1").each do |p|
|
Profile.includes(:user).where("notify_news = 1").each do |p|
|
||||||
Notifications.news p.user, self if p.user
|
Notifications.news p.user, self if p.user
|
||||||
end
|
end
|
||||||
when Category::DOMAIN_ARTICLES
|
when Category::DOMAIN_ARTICLES
|
||||||
Profile.includes(:user).all(conditions: "notify_articles = 1").each do |p|
|
Profile.includes(:user).where("notify_articles = 1").each do |p|
|
||||||
Notifications.article p.user, self if p.user
|
Notifications.article p.user, self if p.user
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -123,7 +123,7 @@ class DataFile < ActiveRecord::Base
|
||||||
|
|
||||||
if location.include? "_preview.mp4" and !related
|
if location.include? "_preview.mp4" and !related
|
||||||
stripped = location.gsub(/_preview\.mp4/, "")
|
stripped = location.gsub(/_preview\.mp4/, "")
|
||||||
DataFile.all(:conditions => ["path LIKE ?", stripped + "%"]).each do |r|
|
DataFile.where(["path LIKE ?", stripped + "%"]).each do |r|
|
||||||
if r.location.match(/#{stripped}\.\w{1,5}$/)
|
if r.location.match(/#{stripped}\.\w{1,5}$/)
|
||||||
self.related = r
|
self.related = r
|
||||||
end
|
end
|
||||||
|
|
|
@ -149,6 +149,7 @@ class Directory < ActiveRecord::Base
|
||||||
strio = StringIO.new
|
strio = StringIO.new
|
||||||
logger = Logger.new(strio)
|
logger = Logger.new(strio)
|
||||||
logger.info 'Starting recreate on Directory(%d): %s.' % [id, name]
|
logger.info 'Starting recreate on Directory(%d): %s.' % [id, name]
|
||||||
|
logger.info 'DataFiles: %d Directories: %d' % [DataFile.all.count, Directory.all.count]
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
# We use destroy lists so technically there can be seperate roots
|
# We use destroy lists so technically there can be seperate roots
|
||||||
destroy_dirs = Hash.new
|
destroy_dirs = Hash.new
|
||||||
|
@ -159,9 +160,11 @@ class Directory < ActiveRecord::Base
|
||||||
destroy_dirs = recreate(destroy_dirs, logger: logger)
|
destroy_dirs = recreate(destroy_dirs, logger: logger)
|
||||||
destroy_dirs.each do |key, dir|
|
destroy_dirs.each do |key, dir|
|
||||||
logger.info 'Removed dir: %s' % dir.full_path
|
logger.info 'Removed dir: %s' % dir.full_path
|
||||||
|
dir.preserve_files = true
|
||||||
dir.destroy!
|
dir.destroy!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
logger.info 'DataFiles: %d Directories: %d' % [DataFile.all.count, Directory.all.count]
|
||||||
logger.info 'Finish recreate'
|
logger.info 'Finish recreate'
|
||||||
return strio
|
return strio
|
||||||
# TODO: check items that weren't checked.
|
# TODO: check items that weren't checked.
|
||||||
|
|
|
@ -4,7 +4,11 @@ class FileUploader < CarrierWave::Uploader::Base
|
||||||
# Override the directory where uploaded files will be stored.
|
# Override the directory where uploaded files will be stored.
|
||||||
# This is a sensible default for uploaders that are meant to be mounted:
|
# This is a sensible default for uploaders that are meant to be mounted:
|
||||||
def store_dir
|
def store_dir
|
||||||
model.directory.full_path
|
if model and model.directory
|
||||||
|
model.directory.full_path
|
||||||
|
else
|
||||||
|
Directory.find(Directory::ROOT).full_path
|
||||||
|
end
|
||||||
# .gsub(/public\//, '')
|
# .gsub(/public\//, '')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue