mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-26 04:21:36 +00:00
Added creator to ban modell
This commit is contained in:
parent
f3baf7e896
commit
9a0d2c6a25
4 changed files with 13 additions and 2 deletions
|
@ -20,6 +20,7 @@ class BansController < ApplicationController
|
||||||
def create
|
def create
|
||||||
@ban = Ban.new(params[:ban])
|
@ban = Ban.new(params[:ban])
|
||||||
raise AccessError unless @ban.can_create? cuser
|
raise AccessError unless @ban.can_create? cuser
|
||||||
|
@ban.creator = cuser
|
||||||
|
|
||||||
if @ban.save
|
if @ban.save
|
||||||
flash[:notice] = t(:bans_create)
|
flash[:notice] = t(:bans_create)
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# ban_type :integer
|
# ban_type :integer
|
||||||
# ip :string(255)
|
# ip :string(255)
|
||||||
#
|
# creator_id :integer
|
||||||
|
|
||||||
class Ban < ActiveRecord::Base
|
class Ban < ActiveRecord::Base
|
||||||
include Extra
|
include Extra
|
||||||
|
@ -44,6 +44,8 @@ class Ban < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :server
|
belongs_to :server
|
||||||
|
|
||||||
|
belongs_to :creator, foreign_key: 'creator_id', class_name: 'User'
|
||||||
|
|
||||||
def color
|
def color
|
||||||
expiry.past? ? "green" : "red"
|
expiry.past? ? "green" : "red"
|
||||||
end
|
end
|
||||||
|
|
6
db/migrate/20170304191254_add_creator_to_bans.rb
Normal file
6
db/migrate/20170304191254_add_creator_to_bans.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
class AddCreatorToBans < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :bans, :creator_id, :integer
|
||||||
|
add_index :bans, :creator_id
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20150820223313) do
|
ActiveRecord::Schema.define(:version => 20170304191254) do
|
||||||
|
|
||||||
create_table "admin_requests", :force => true do |t|
|
create_table "admin_requests", :force => true do |t|
|
||||||
t.string "addr"
|
t.string "addr"
|
||||||
|
@ -69,8 +69,10 @@ ActiveRecord::Schema.define(:version => 20150820223313) do
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.integer "ban_type"
|
t.integer "ban_type"
|
||||||
t.string "ip"
|
t.string "ip"
|
||||||
|
t.integer "creator_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_index "bans", ["creator_id"], :name => "index_bans_on_creator_id"
|
||||||
add_index "bans", ["server_id"], :name => "index_bans_on_server_id"
|
add_index "bans", ["server_id"], :name => "index_bans_on_server_id"
|
||||||
add_index "bans", ["user_id"], :name => "index_bans_on_user_id"
|
add_index "bans", ["user_id"], :name => "index_bans_on_user_id"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue