mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-25 12:01:03 +00:00
Added model and controller stub
This commit is contained in:
parent
d3fdef95c4
commit
160fccd118
7 changed files with 66 additions and 1 deletions
11
app/controllers/match_proposals_controller.rb
Normal file
11
app/controllers/match_proposals_controller.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
class MatchProposalsController < ApplicationController
|
||||
def index
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def create
|
||||
end
|
||||
end
|
22
app/models/match_proposal.rb
Normal file
22
app/models/match_proposal.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
class MatchProposal < ActiveRecord::Base
|
||||
|
||||
STATUS_PENDING = 0
|
||||
STATUS_REVOKED = 1
|
||||
STATUS_REJECTED = 2
|
||||
STATUS_ACCEPTED = 3
|
||||
|
||||
belongs_to :match
|
||||
belongs_to :team
|
||||
attr_accessible :proposed_time, :status
|
||||
|
||||
validates_presence_of :match, :team, :proposed_time
|
||||
|
||||
def can_create? (match, cuser)
|
||||
match && cuser && cuser.team.is_leader?(cuser) && (match.of_team cuser.team)
|
||||
end
|
||||
|
||||
def can_destroy?
|
||||
cuser && cuser.admin?
|
||||
end
|
||||
|
||||
end
|
2
app/views/match_proposals/index.html.erb
Normal file
2
app/views/match_proposals/index.html.erb
Normal file
|
@ -0,0 +1,2 @@
|
|||
<h1>MatchProposals#show</h1>
|
||||
<p>Find me in app/views/match_proposals/show.html.erb</p>
|
2
app/views/match_proposals/new.html.erb
Normal file
2
app/views/match_proposals/new.html.erb
Normal file
|
@ -0,0 +1,2 @@
|
|||
<h1>MatchProposals#new</h1>
|
||||
<p>Find me in app/views/match_proposals/new.html.erb</p>
|
|
@ -1,4 +1,5 @@
|
|||
Ensl::Application.routes.draw do
|
||||
|
||||
%w(403 404 422 500).each do |code|
|
||||
get code, to: "errors#show", code: code
|
||||
end
|
||||
|
@ -60,6 +61,7 @@ Ensl::Application.routes.draw do
|
|||
get "matches/ref/:id" => "matches#ref", as: :match_ref
|
||||
resources :matches do
|
||||
get :admin, to: "matches#admin", on: :collection
|
||||
resources :match_proposals, path: "proposals", as: "proposals", only: [:index, :new, :create]
|
||||
end
|
||||
|
||||
resources :maps
|
||||
|
|
14
db/migrate/20170501121908_create_match_proposals.rb
Normal file
14
db/migrate/20170501121908_create_match_proposals.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
class CreateMatchProposals < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :match_proposals do |t|
|
||||
t.references :match
|
||||
t.references :team
|
||||
t.integer :status
|
||||
t.datetime :proposed_time
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :match_proposals, :match_id
|
||||
add_index :match_proposals, :team_id
|
||||
end
|
||||
end
|
14
db/schema.rb
14
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20170304191254) do
|
||||
ActiveRecord::Schema.define(:version => 20170501121908) do
|
||||
|
||||
create_table "admin_requests", :force => true do |t|
|
||||
t.string "addr"
|
||||
|
@ -432,6 +432,18 @@ ActiveRecord::Schema.define(:version => 20170304191254) do
|
|||
t.integer "category_id"
|
||||
end
|
||||
|
||||
create_table "match_proposals", :force => true do |t|
|
||||
t.integer "match_id"
|
||||
t.integer "team_id"
|
||||
t.integer "status"
|
||||
t.datetime "proposed_time"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
add_index "match_proposals", ["match_id"], :name => "index_match_proposals_on_match_id"
|
||||
add_index "match_proposals", ["team_id"], :name => "index_match_proposals_on_team_id"
|
||||
|
||||
create_table "matchers", :force => true do |t|
|
||||
t.integer "match_id", :null => false
|
||||
t.integer "user_id", :null => false
|
||||
|
|
Loading…
Reference in a new issue