Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add migs n models for bonus

  • Loading branch information...
commit 8866f5bb7d4ba6baadfe96abbb9095419f6217bd 1 parent 58741e6
@geraldb geraldb authored
View
9 app/controllers/admin/bonus_controller.rb
@@ -0,0 +1,9 @@
+class Admin::BonusController < Admin::BaseController
+
+ def index
+ end
+
+ def update
+ end
+
+end # class BonusController
View
7 app/models/bonus_question.rb
@@ -0,0 +1,7 @@
+
+class BonusQuestion < ActiveRecord::Base
+
+ self.table_name = 'bonus_questions'
+
+
+end # class BonusQuestion
View
7 app/models/bonus_round.rb
@@ -0,0 +1,7 @@
+
+class BonusRound < ActiveRecord::Base
+
+ self.table_name = 'bonus_rounds'
+
+
+end # class BonusRound
View
7 app/models/bonus_tip.rb
@@ -0,0 +1,7 @@
+
+class BonusTip < ActiveRecord::Base
+
+ self.table_name = 'bonus_tips'
+
+
+end # class BonusTip
View
2  app/views/admin/bonus/index.html.erb
@@ -0,0 +1,2 @@
+
+<h1> form for bonus updates here </h1>
View
1  app/views/layouts/admin.html.erb
@@ -43,6 +43,7 @@
<%= link_to 'Update', update_path() %> &bull;
<%= link_to 'Users', users_path() %> &bull;
<%= link_to 'Pools', admin_pools_path() %> &bull;
+ <%= link_to 'Bonus', admin_bonus_path() %> &bull;
<%= link_to 'Jobs', jobs_path() %>
<!-- todo: add some more links -->
</div>
View
4 config/initializers/inflections.rb
@@ -13,3 +13,7 @@
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.acronym 'RESTful'
# end
+
+ActiveSupport::Inflector.inflections do |inflect|
+ inflect.irregular 'bonus', 'bonuses'
+end
View
3  config/routes.rb
@@ -30,6 +30,9 @@
namespace :admin do
resources :pools
+
+ match 'bonus', :to => 'bonus#index'
+ match 'bonus/update', :to => 'bonus#update'
end
##############################
View
37 db/migrate/20120621074414_add_bonus.rb
@@ -0,0 +1,37 @@
+class AddBonus < ActiveRecord::Migration
+
+ def up
+
+ create_table :bonus_rounds do |t|
+ t.references :pool, :null => false
+ t.string :title, :null => false
+ t.integer :pos, :null => false
+ t.timestamps
+ end
+
+ create_table :bonus_questions do |t|
+ t.references :round, :null => false
+ t.string :title, :null => false
+ t.integer :pos, :null => false
+ t.timestamps
+ end
+
+ create_table :bonus_answers do |t|
+ # to be done
+ t.timestamps
+ end
+
+ create_table :bonus_tips do |t|
+ t.references :user, :null => false
+ t.references :question, :null => false
+ t.integer :pts , :null => false, :default => 0
+ t.timestamps
+ end
+
+ Prop.create!( :key => 'db.mig.bonus.version', :value => '1' )
+ end
+
+ def down
+ end
+
+end
View
31 db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120607120146) do
+ActiveRecord::Schema.define(:version => 20120621074414) do
create_table "actions", :force => true do |t|
t.text "text"
@@ -25,6 +25,35 @@
t.datetime "updated_at", :null => false
end
+ create_table "bonus_answers", :force => true do |t|
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ create_table "bonus_questions", :force => true do |t|
+ t.integer "round_id", :null => false
+ t.string "title", :null => false
+ t.integer "pos", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ create_table "bonus_rounds", :force => true do |t|
+ t.integer "pool_id", :null => false
+ t.string "title", :null => false
+ t.integer "pos", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ create_table "bonus_tips", :force => true do |t|
+ t.integer "user_id", :null => false
+ t.integer "question_id", :null => false
+ t.integer "pts", :default => 0, :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
create_table "event_quotes", :force => true do |t|
t.integer "service_id", :null => false
t.integer "event_id", :null => false
View
34 db/seeds/uss/euro_bonus.rb
@@ -0,0 +1,34 @@
+
+puts "*** loading seed data in seeds/uss/euro_bonus.rb"
+
+
+behrooz = User.find_by_key!( 'behrooz' )
+
+euro = Event.find_by_key!( 'euro')
+
+poolfix = Pool.find_by_event_id_and_user_id_and_fix!( euro.id, behrooz.id, true )
+poolflex = Pool.find_by_event_id_and_user_id_and_fix!( euro.id, behrooz.id, false )
+
+rfix1 = BonusRound.create!( :pool_id => poolfix.id, :pos => 1, :title => 'Bonuspunkte - Europa- und Vizemeister' )
+rfix2 = BonusRound.create!( :pool_id => poolfix.id, :pos => 2, :title => 'Bonuspunkte - Gruppenplazierung' )
+
+qfix1 = BonusQuestion.create!( :round_id => rfix1.id, :pos => 1, :title => 'Europameister? Vizemeister?' )
+qfix2 = BonusQuestion.create!( :round_id => rfix2.id, :pos => 1, :title => 'Gruppenerster? Gruppenzweiter? Grupperdritter? Gruppenvierter?' )
+
+
+rflex1 = BonusRound.create!( :pool_id => poolflex.id, :pos => 1, :title => 'Bonuspunkte - Europa- und Vizemeister' )
+qflex1 = BonusQuestion.create!( :round_id => rflex1.id, :pos => 1, :title => 'Europameister? Vizemeister?' )
+
+poolfix.players.each do |player|
+ [qfix1,qfix2].each do |question|
+ BonusTip.create!( :question_id => question.id, :user_id => player.id )
+ end
+end
+
+poolflex.players.each do |player|
+ [qflex1].each do |question|
+ BonusTip.create!( :question_id => question.id, :user_id => player.id )
+ end
+end
+
+Prop.create!( :key => 'db.seeds.uss.euro.bonus.version', :value => '1' )
View
11 lib/tasks/load_uss_euro.rake
@@ -8,6 +8,17 @@ task :load_uss_euro => [:environment] do |t|
end
+desc "load seed data for uss euro bonus questions"
+task :load_uss_euro_bonus => [:environment] do |t|
+
+ ['uss/euro_bonus' ].each do |seed|
+ require "#{Rails.root}/db/seeds/#{seed}.rb"
+ end
+
+end
+
+
+
desc "load seed data for uss euro pools (tips) - part ii"
task :load_uss_euro_tips => [:environment] do |t|
Please sign in to comment.
Something went wrong with that request. Please try again.