Merge pull request #99 from Absurdon/master

Made bans show who created them
This commit is contained in:
Absurdon 2017-03-04 22:57:42 +01:00 committed by GitHub
commit 303fbf9587
5 changed files with 14 additions and 3 deletions

View file

@ -20,6 +20,7 @@ class BansController < ApplicationController
def create
@ban = Ban.new(params[:ban])
raise AccessError unless @ban.can_create? cuser
@ban.creator = cuser
if @ban.save
flash[:notice] = t(:bans_create)

View file

@ -13,7 +13,7 @@
# updated_at :datetime
# ban_type :integer
# ip :string(255)
#
# creator_id :integer
class Ban < ActiveRecord::Base
include Extra
@ -44,6 +44,8 @@ class Ban < ActiveRecord::Base
belongs_to :user
belongs_to :server
belongs_to :creator, foreign_key: 'creator_id', class_name: 'User'
def color
expiry.past? ? "green" : "red"
end

View file

@ -3,7 +3,7 @@
</h1>
<div class="wide box">
<%= cascade @ban, ["steamid", :user, "addr", :server, "expiry", "reason_b", "created_at"] %>
<%= cascade @ban, ["steamid", :user, "addr", :server, "expiry", "reason_b", "created_at", :creator] %>
</div>
<%= link_to "Back", bans_url %>

View file

@ -0,0 +1,6 @@
class AddCreatorToBans < ActiveRecord::Migration
def change
add_column :bans, :creator_id, :integer
add_index :bans, :creator_id
end
end

View file

@ -11,7 +11,7 @@
#
# 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|
t.string "addr"
@ -69,8 +69,10 @@ ActiveRecord::Schema.define(:version => 20150820223313) do
t.datetime "updated_at"
t.integer "ban_type"
t.string "ip"
t.integer "creator_id"
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", ["user_id"], :name => "index_bans_on_user_id"