Skip to content

Commit

Permalink
Upgrade to Ruby on Rails 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Envek committed Mar 15, 2012
1 parent dcdaabb commit 4d6da89
Show file tree
Hide file tree
Showing 444 changed files with 5,093 additions and 28,033 deletions.
7 changes: 5 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
source "http://rubygems.org"

gem "rails", "~> 2.3.8"
gem "rails", "~> 3.0.0"

gem "devise", "~> 1.0.8"
gem "active_scaffold", "~> 3.0.0"
gem "recordselect", "~> 3.0.4"
gem "russian"
gem "devise", "~> 1.1.0"
gem "erubis"
gem "haml", "~> 3.0.21"
gem "pdfkit"
Expand Down
132 changes: 93 additions & 39 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,65 @@ GEM
Platform (>= 0.4.0)
open4
Platform (0.4.0)
actionmailer (2.3.14)
actionpack (= 2.3.14)
actionpack (2.3.14)
activesupport (= 2.3.14)
rack (~> 1.1.0)
activerecord (2.3.14)
activesupport (= 2.3.14)
activeresource (2.3.14)
activesupport (= 2.3.14)
activesupport (2.3.14)
backup (3.0.20)
abstract (1.0.0)
actionmailer (3.0.12)
actionpack (= 3.0.12)
mail (~> 2.2.19)
actionpack (3.0.12)
activemodel (= 3.0.12)
activesupport (= 3.0.12)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.5.0)
rack (~> 1.2.5)
rack-mount (~> 0.6.14)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
active_scaffold (3.0.26)
rails (~> 3.0.0)
render_component_vho
verification
activemodel (3.0.12)
activesupport (= 3.0.12)
builder (~> 2.1.2)
i18n (~> 0.5.0)
activerecord (3.0.12)
activemodel (= 3.0.12)
activesupport (= 3.0.12)
arel (~> 2.0.10)
tzinfo (~> 0.3.23)
activeresource (3.0.12)
activemodel (= 3.0.12)
activesupport (= 3.0.12)
activesupport (3.0.12)
arel (2.0.10)
backup (3.0.23)
POpen4 (~> 0.1.4)
thor (~> 0.14.6)
capistrano (2.9.0)
bcrypt-ruby (2.1.4)
builder (2.1.2)
capistrano (2.11.2)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.1.0)
chronic (0.6.6)
chronic (0.6.7)
columnize (0.3.6)
devise (1.0.11)
warden (~> 0.10.3)
erubis (2.7.0)
devise (1.1.9)
bcrypt-ruby (~> 2.1.2)
warden (~> 1.0.2)
erubis (2.6.6)
abstract (>= 1.0.0)
haml (3.0.25)
highline (1.6.9)
i18n (0.6.0)
highline (1.6.11)
i18n (0.5.0)
json (1.6.5)
kgio (2.7.2)
linecache (0.46)
rbx-require-relative (> 0.0.4)
mail (2.3.0)
mail (2.2.19)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
Expand All @@ -47,49 +75,73 @@ GEM
net-ssh (2.1.4)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
nokogiri (1.5.0)
nokogiri (1.5.2)
open4 (1.3.0)
pdfkit (0.5.2)
pg (0.12.2)
pg (0.13.2)
polyglot (0.3.3)
rack (1.1.3)
rails (2.3.14)
actionmailer (= 2.3.14)
actionpack (= 2.3.14)
activerecord (= 2.3.14)
activeresource (= 2.3.14)
activesupport (= 2.3.14)
rake (>= 0.8.3)
rack (1.2.5)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.12)
actionmailer (= 3.0.12)
actionpack (= 3.0.12)
activerecord (= 3.0.12)
activeresource (= 3.0.12)
activesupport (= 3.0.12)
bundler (~> 1.0)
railties (= 3.0.12)
railties (3.0.12)
actionpack (= 3.0.12)
activesupport (= 3.0.12)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.4)
raindrops (0.8.0)
rake (0.9.2.2)
rbx-require-relative (0.0.5)
rbx-require-relative (0.0.9)
rdoc (3.12)
json (~> 1.4)
recordselect (3.0.4)
rails (~> 3.0.0)
render_component_vho (3.0.3)
railties (~> 3.0.0)
ruby-debug (0.10.4)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.4.0)
ruby-debug-base (0.10.4)
linecache (>= 0.3)
russian (0.6.0)
i18n (>= 0.5.0)
thor (0.14.6)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
unicode (0.4.0)
unicorn (4.1.1)
kgio (~> 2.4)
tzinfo (0.3.32)
unicode (0.4.2)
unicorn (4.2.0)
kgio (~> 2.6)
rack
raindrops (~> 0.6)
warden (0.10.7)
rack (>= 1.0.0)
whenever (0.7.2)
raindrops (~> 0.7)
verification (1.0.1)
actionpack (~> 3.0.0)
activesupport (~> 3.0.0)
warden (1.0.6)
rack (>= 1.0)
whenever (0.7.3)
activesupport (>= 2.3.4)
chronic (~> 0.6.3)

PLATFORMS
ruby

DEPENDENCIES
active_scaffold (~> 3.0.0)
backup
capistrano
devise (~> 1.0.8)
devise (~> 1.1.0)
erubis
haml (~> 3.0.21)
mail
Expand All @@ -98,8 +150,10 @@ DEPENDENCIES
nokogiri
pdfkit
pg
rails (~> 2.3.8)
rails (~> 3.0.0)
recordselect (~> 3.0.4)
ruby-debug
russian
unicode
unicorn
whenever
7 changes: 2 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require(File.join(File.dirname(__FILE__), 'config', 'boot'))

require File.expand_path('../config/application', __FILE__)
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

require 'tasks/rails'
Taurus::Application.load_tasks
11 changes: 1 addition & 10 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,5 @@

class ApplicationController < ActionController::Base
protect_from_forgery # See ActionController::RequestForgeryProtection for details

# Scrub sensitive parameters from your log
filter_parameter_logging :password
ActiveScaffold.set_defaults do |config|
config.actions.exclude :show, :delete
config.search.live = true
config.ignore_columns = [:created_at, :updated_at, :lock_version]
config.list.per_page = 30
config.subform.layout = :vertical
end
clear_helpers
end
2 changes: 1 addition & 1 deletion app/controllers/dept_head/disciplines_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class DeptHead::DisciplinesController < DeptHead::BaseController
config.create.columns = [:name, :short_name]
config.update.columns = [:name, :short_name]
config.list.sorting = { :name => :asc }
config.nested.add_link 'Карты распределения нагрузки', [:charge_cards]
config.nested.add_link :charge_cards
end

protected
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/dept_head/specialities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class DeptHead::SpecialitiesController < DeptHead::BaseController
active_scaffold do |config|
config.actions << :delete
config.columns = [:code, :name]
config.nested.add_link('Группы', [:groups])
config.nested.add_link(:groups)
config.action_links.add :teaching_plan, :label => "Учебный план", :type => :member, :page => true
config.action_links.add :teaching_plan_import, :label => "Импорт учебного плана", :type => :collection, :page => true
config.action_links.add :add_charge_cards, :label => "Автосоздание карт нагрузки", :type => :member, :page => true
Expand All @@ -20,7 +20,7 @@ def teaching_plan
end

def teaching_plan_import
if params[:plan] and params[:plan].class == Tempfile
if params[:plan] and params[:plan].class == ActionDispatch::Http::UploadedFile
@specialities = current_dept_head.department.specialities
@speciality, @results, @errors = parse_and_fill_teaching_plan(params[:plan].read, @specialities)
render "supervisor/teaching_plans/fill"
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/dept_head/teaching_places_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class DeptHead::TeachingPlacesController < DeptHead::BaseController
config.columns[:lecturer].sort_by :sql => 'lecturers.name'
config.search.columns = :lecturer
config.columns[:lecturer].search_sql = 'lecturers.name'
config.nested.add_link('Карты распределения нагрузки', [:charge_cards])
config.nested.add_link :charge_cards
end

protected
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/editor/groups/charge_cards_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
class Editor::Groups::ChargeCardsController < Editor::BaseController
def index
charge_card_search = params[:charge_card].to_s.split
charge_card = ChargeCard.all :joins => :jets,
:select => "charge_cards.id,charge_cards.editor_name",
:conditions => {:jets => {:group_id => params[:group_id]}}
charge_card = ChargeCard.joins(:jets).where(:jets => {:group_id => params[:group_id]}).select("charge_cards.id,charge_cards.editor_name").all
charge_card_search.each do |s|
charge_card = charge_card.select { |c| c.editor_name_include? s }
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/editor/reference/charge_cards_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Editor::Reference::ChargeCardsController < Editor::BaseController
active_scaffold do |config|
config.actions = [:list]
active_scaffold :charge_cards do |config|
config.actions = [:list, :search, :nested]
config.list.columns = [:teaching_place, :assistant_teaching_place, :lesson_type, :discipline, :hours_quantity, :hours_per_week, :weeks_quantity, :groups]
config.columns[:teaching_place].clear_link
config.columns[:assistant_teaching_place].clear_link
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/editor/reference/departments_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class Editor::Reference::DepartmentsController < Editor::BaseController
active_scaffold do |config|
config.actions = [:list, :nested]
config.columns = [:name, :short_name]
active_scaffold :departments do |config|
config.actions = [:list, :search, :nested]
config.list.columns = [:name, :short_name]
config.list.sorting = { :name => :asc }
config.nested.add_link('Дисциплины', [:disciplines])
config.nested.add_link('Преподаватели', [:teaching_places])
config.nested.add_link :disciplines
config.nested.add_link :teaching_places
end
end
8 changes: 4 additions & 4 deletions app/controllers/editor/reference/disciplines_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class Editor::Reference::DisciplinesController < Editor::BaseController
record_select :search_on => :name, :order_by => :name
active_scaffold do |config|
config.actions = [:list, :nested]
config.columns = [:short_name, :name]
active_scaffold :disciplines do |config|
config.actions = [:list, :search, :nested]
config.list.columns = [:short_name, :name]
config.list.sorting = { :name => :asc }
config.nested.add_link 'Карты распределения нагрузки', [:charge_cards]
config.nested.add_link :charge_cards
end
end
11 changes: 6 additions & 5 deletions app/controllers/editor/reference/teaching_places_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
class Editor::Reference::TeachingPlacesController < Editor::BaseController
active_scaffold do |config|
config.actions = [:list, :nested]
config.columns = [:position, :lecturer, :whish]
active_scaffold :teaching_places do |config|
config.actions = [:list, :search, :nested]
config.list.columns = [:position, :lecturer, :whish]
config.columns[:lecturer].clear_link
config.columns[:lecturer].sort_by :sql => 'lecturers.name'
config.list.sorting = { :lecturer => :asc }
config.nested.add_link('Карты распределения нагрузки', [:charge_cards])
config.columns[:lecturer].search_sql = 'lecturers.name'
config.search.columns << :lecturer
config.nested.add_link :charge_cards
end
end
2 changes: 1 addition & 1 deletion app/controllers/supervisor/departments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ class Supervisor::DepartmentsController < Supervisor::BaseController
active_scaffold do |config|
config.actions << :delete
config.columns = [:name, :short_name, :gosinsp_code]
config.nested.add_link('Специальности', [:specialities])
config.nested.add_link :specialities
end
end
2 changes: 1 addition & 1 deletion app/controllers/supervisor/faculties_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ class Supervisor::FacultiesController < Supervisor::BaseController
active_scaffold do |config|
config.actions << :delete
config.columns = [:full_name, :name]
config.nested.add_link('Кафедры', [:departments])
config.nested.add_link :departments
end
end
2 changes: 1 addition & 1 deletion app/controllers/supervisor/specialities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Supervisor::SpecialitiesController < Supervisor::BaseController
active_scaffold do |config|
config.actions << :delete
config.columns = [:code, :name, :department]
config.nested.add_link('Группы', [:groups])
config.nested.add_link :groups
config.columns[:department].form_ui = :select
config.action_links.add :teaching_plan, :label => "Учебный план", :type => :member, :page => true
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/supervisor/teaching_plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def new
end

def fill
if params[:plan] and params[:plan].class == Tempfile
if params[:plan] and params[:plan].class == ActionDispatch::Http::UploadedFile
@speciality, @results, @errors = parse_and_fill_teaching_plan(params[:plan].read)
end
end
Expand Down
12 changes: 4 additions & 8 deletions app/models/charge_card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ class ChargeCard < ActiveRecord::Base
validates_presence_of :discipline, :lesson_type, :weeks_quantity, :hours_per_week
validates_numericality_of :weeks_quantity, :hours_per_week

named_scope :with_recommended_first_for, lambda { |department|
scope :with_recommended_first_for, lambda { |department|
if department.class == Department
{
:joins => :teaching_place,
:order => "teaching_places.department_id = #{department.id} DESC NULLS LAST, charge_cards.editor_name ASC"
}
joins(:teaching_place).order("teaching_places.department_id = #{department.id} DESC NULLS LAST, charge_cards.editor_name ASC")
end
}

Expand Down Expand Up @@ -64,12 +61,11 @@ def editor_name_with_recommendation

def self.for_autocreation(discipline_id, lesson_type_id, groups)
groups = [groups].flatten # In case of single group make it look like an array
pretendents = all(:joins => :jets, :conditions => {
pretendents = joins(:jets).where(
:discipline_id => discipline_id,
:lesson_type_id => lesson_type_id,
:jets => {:group_id => groups}
}
)
).all
pretendents = pretendents.find_all {|cc| cc.groups == groups }
if pretendents.empty?
return new(:discipline_id => discipline_id, :lesson_type_id => lesson_type_id)
Expand Down
Loading

0 comments on commit 4d6da89

Please sign in to comment.