forked from tildeverse/tilde.news
link tags from modlog
This commit is contained in:
parent
2105656d8f
commit
93fe0fdd74
|
@ -123,4 +123,4 @@ in a `config/initializers/production.rb` or similar file:
|
|||
#### Administration
|
||||
|
||||
Basic moderation happens on-site, but most other administrative tasks require use of the rails console in production.
|
||||
Side administrators can create and edit tags at `/tags`.
|
||||
Administrators can create and edit tags at `/tags`.
|
||||
|
|
|
@ -3,8 +3,9 @@ class Moderation < ApplicationRecord
|
|||
:class_name => "User",
|
||||
:foreign_key => "moderator_user_id",
|
||||
:inverse_of => :moderations
|
||||
belongs_to :story
|
||||
belongs_to :comment
|
||||
belongs_to :story
|
||||
belongs_to :tag
|
||||
belongs_to :user
|
||||
|
||||
after_create :send_message_to_moderated
|
||||
|
|
|
@ -60,6 +60,7 @@ class Tag < ApplicationRecord
|
|||
self.changes.map {|f, c| "changed #{f} from '#{c[0]}' to '#{c[1]}'" } .join(', ')
|
||||
end
|
||||
m.moderator_user_id = @edit_user_id
|
||||
m.tag = self
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
<%= mod.comment.user.username %>
|
||||
on
|
||||
<%= mod.comment.story.title %></a>
|
||||
<% elsif mod.tag %>
|
||||
<%= link_to("Tag: #{mod.tag.tag}", mod.tag) %>
|
||||
<% elsif mod.user_id %>
|
||||
<% if mod.user %>
|
||||
<a href="/u/<%= mod.user.username %>">User
|
||||
|
|
5
db/migrate/20180411131217_tag_moderation_log.rb
Normal file
5
db/migrate/20180411131217_tag_moderation_log.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class TagModerationLog < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_column :moderations, :tag_id, :integer, null: true, default: nil
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20180201184612) do
|
||||
ActiveRecord::Schema.define(version: 20180411131217) do
|
||||
|
||||
create_table "comments", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
|
||||
t.datetime "created_at", null: false
|
||||
|
@ -112,6 +112,7 @@ ActiveRecord::Schema.define(version: 20180201184612) do
|
|||
t.text "action", limit: 16777215
|
||||
t.text "reason", limit: 16777215
|
||||
t.boolean "is_from_suggestions", default: false
|
||||
t.integer "tag_id"
|
||||
t.index ["created_at"], name: "index_moderations_on_created_at"
|
||||
end
|
||||
|
||||
|
|
|
@ -39,9 +39,11 @@ describe TagsController do
|
|||
expect(tag.inactive).to be true
|
||||
end
|
||||
|
||||
it 'creates a moderation with the expected user_id' do
|
||||
it 'creates a moderation with the expected tag_id and user_id' do
|
||||
post :create, params: { tag: { tag: 'mytag' } }
|
||||
expect(Moderation.order(id: :desc).first.moderator_user_id).to eq user_id
|
||||
mod = Moderation.order(id: :desc).first
|
||||
expect(mod.tag_id).to eq Tag.order(id: :desc).first.id
|
||||
expect(mod.moderator_user_id).to eq user_id
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user