beetle_reporter 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 224576858692394234faa775751f23ebfa338a9aaabd4fd50330f60d87b38751
4
- data.tar.gz: 34afd7af8fa7c95315722dc50ee4110c5c8f1924a0bcf02aa334650fc3dc46b1
3
+ metadata.gz: d11171951d3f41267ff60f38549fe8448cba2bbd139f5c2e94a2a811ef59b8b0
4
+ data.tar.gz: db309e98c5fc8b773341534950a3180373624f79f0237a7e788cd59b5c4ebb53
5
5
  SHA512:
6
- metadata.gz: d3c6f2ce890632f07592eeedbe7a7a6d8dbea53d303b28325f931ed0ed4cf934f191c0c0bf0ccf48b60961476fbfc84063f70171cb31016610aaebe0c78117b4
7
- data.tar.gz: 667a1644f4244932806802bb813729d9a3569f4d43a8e0f961007ae87c269f2ac1b2638d485d110fc6a5974aea3e32f1c2c7073642162e27c30f3c39aea8b91c
6
+ metadata.gz: 190aff907f7d2a7c6c91454661f1005d6a259e51571ec39b0aece2f48f63c9ebf6b417dda9d8b9e87703946a97ec139f48850ecab1e18b9a715a88f81c9e3d5a
7
+ data.tar.gz: 94416c640937569fa17af54e45cf57636329fcae93ffbaaa7ace994a8602865bd54ece19ab0ed371aff79d4994cc81e371f640c409adb69b76cf9c99882e3bab
@@ -69,43 +69,65 @@ module BeetleReporter
69
69
  def ignore
70
70
  @report.ignore!
71
71
 
72
- redirect_to reports_url, notice: 'report was successfully ignored.'
72
+ respond_to do |format|
73
+ format.turbo_stream { render turbo_stream: turbo_stream.remove(dom_id(@report)) }
74
+ format.html { redirect_to reports_url, notice: 'report was successfully ignored.' }
75
+ end
73
76
  end
74
77
 
75
78
  def suspend
76
79
  @report.suspend!
77
80
 
78
- redirect_to reports_url, notice: 'report was successfully ignored.'
81
+ respond_to do |format|
82
+ format.turbo_stream { render turbo_stream: turbo_stream.remove(dom_id(@report)) }
83
+ format.html { redirect_to reports_url, notice: 'report was successfully suspended.' }
84
+ end
79
85
  end
80
86
 
81
87
  def hide
82
- @report.beetle_hide("fooobar hide")
88
+ @report.beetle_hide(params[:reason])
83
89
 
84
- redirect_to reports_url, notice: 'report was successfully hidden.'
90
+ respond_to do |format|
91
+ format.turbo_stream { render turbo_stream: turbo_stream.remove(dom_id(@report)) }
92
+ format.html { redirect_to reports_url, notice: 'report was successfully hidden.' }
93
+ end
85
94
  end
86
95
 
87
96
  def remove
88
- @report.beetle_remove("fooobar remove")
97
+ @report.beetle_remove(params[:reason])
89
98
 
90
- redirect_to reports_url, notice: 'report was successfully removed.'
99
+ respond_to do |format|
100
+ format.turbo_stream { render turbo_stream: turbo_stream.remove(dom_id(@report)) }
101
+ format.html { redirect_to reports_url, notice: 'report was successfully removed.' }
102
+ end
91
103
  end
92
104
 
93
105
  def mute
94
- @report.beetle_mute("fooobar mute")
106
+ # TODO: 禁言时间
107
+ @report.beetle_mute(params[:reason])
95
108
 
96
- redirect_to reports_url, notice: 'report was successfully muted.'
109
+ respond_to do |format|
110
+ format.turbo_stream { render turbo_stream: turbo_stream.remove(dom_id(@report)) }
111
+ format.html { redirect_to reports_url, notice: 'report was successfully muted.' }
112
+ end
97
113
  end
98
114
 
99
115
  def forbid
100
- @report.beetle_forbid("fooobar forbid")
116
+ @report.beetle_forbid(params[:reason])
101
117
 
102
- redirect_to reports_url, notice: 'report was successfully forbiden.'
118
+ respond_to do |format|
119
+ format.turbo_stream { render turbo_stream: turbo_stream.remove(dom_id(@report)) }
120
+ format.html { redirect_to reports_url, notice: 'report was successfully forbiden.' }
121
+ end
103
122
  end
104
123
 
105
124
  def undo
106
125
  @report.undo!
107
126
 
108
- redirect_to reports_url, notice: 'report was successfully ignored.'
127
+ respond_to do |format|
128
+ format.turbo_stream { render turbo_stream: turbo_stream.remove(dom_id(@report)) }
129
+ format.html { redirect_to reports_url, notice: 'report was successfully undo.' }
130
+ end
109
131
  end
110
132
 
111
133
  private
@@ -3,6 +3,8 @@ module BeetleReporter
3
3
  include AASM
4
4
  include Discard::Model
5
5
 
6
+ REASON_TYPES = %w(垃圾广告营销 侮辱谩骂内容 淫秽色情内容 涉政敏感信息 违法有害信息 内容令人不适 内容存在错误)
7
+
6
8
  belongs_to :record, polymorphic: true, required: false
7
9
  belongs_to :user, class_name: BeetleReporter.config.user_class, optional: true
8
10
 
@@ -40,18 +40,27 @@
40
40
  %div
41
41
  - report.images.each do |img|
42
42
  = image_tag img[:src], class: "w-16 rounded-md"
43
- %div{class: "flex space-x-2 items-center justify-end"}
43
+ %div{class: "flex flex-col space-y-2"}
44
44
  - if report.may_ignore?
45
- = link_to "忽略", report_ignore_path(report), class: "text-yellow-600 cursor-pointer"
45
+ = button_to "无效举报", report_ignore_path(report), class: "text-yellow-600 cursor-pointer px-2 py-0.5 bg-gray-100 rounded-lg"
46
+ - if report.may_suspend?
47
+ = button_to "暂缓处理", report_suspend_path(report), class: "text-indigo-600 cursor-pointer px-2 py-0.5 bg-gray-100 rounded-lg"
48
+ - if report.may_undo?
49
+ = button_to "撤销", report_undo_path(report), class: "text-red-600 cursor-pointer px-2 py-0.5 bg-gray-100 rounded-lg"
46
50
  - if report.may_hide?
47
- = link_to "隐藏内容", report_hide_path(report), class: "text-purple-600 cursor-pointer"
51
+ = form_with(url: report_hide_path(report), class: "space-x-1 flex items-center") do |f|
52
+ = f.text_field :reason, value: report.reason, placeholder: "隐藏原因是什么?", class: "border rounded-md m py-0.5 px-1"
53
+ = f.submit "隐藏内容", class: "bg-red-500 text-white cursor-pointer px-2 py-0.5 bg-gray-100 rounded-lg"
48
54
  - if report.may_remove?
49
- = link_to "删除内容", report_remove_path(report), class: "text-red-800 cursor-pointer"
55
+ = form_with(url: report_remove_path(report), class: "space-x-1 flex items-center") do |f|
56
+ = f.text_field :reason, value: report.reason, placeholder: "删除原因是什么?", class: "border rounded-md m py-0.5 px-1"
57
+ = f.submit "删除内容", class: "bg-red-600 text-white cursor-pointer px-2 py-0.5 bg-gray-100 rounded-lg"
50
58
  - if report.may_mute?
51
- = link_to "禁言用户", report_mute_path(report), class: "text-red-600 cursor-pointer"
59
+ = form_with(url: report_mute_path(report), class: "space-x-1 flex items-center") do |f|
60
+ -# = f.text_field :mute_days, value: report.mute_days, placeholder: "禁言天数", class: "border rounded-md m py-0.5 px-1"
61
+ = f.text_field :reason, value: report.reason, placeholder: "禁言原因是什么?", class: "border rounded-md m py-0.5 px-1"
62
+ = f.submit "禁言用户", class: "bg-red-700 text-white cursor-pointer px-2 py-0.5 bg-gray-100 rounded-lg"
52
63
  - if report.may_forbid?
53
- = link_to "封禁用户",report_forbid_path(report), class: "text-red-700 cursor-pointer"
54
- - if report.may_suspend?
55
- = link_to "暂缓处理", report_suspend_path(report), class: "text-indigo-600 cursor-pointer"
56
- - if report.may_undo?
57
- = link_to "撤销", report_undo_path(report), class: "text-red-600 cursor-pointer"
64
+ = form_with(url: report_forbid_path(report), class: "space-x-1 flex items-center") do |f|
65
+ = f.text_field :reason, value: report.reason, placeholder: "封禁原因是什么?", class: "border rounded-md m py-0.5 px-1"
66
+ = f.submit "封禁用户", class: "bg-red-800 text-white cursor-pointer px-2 py-0.5 bg-gray-100 rounded-lg"
data/config/routes.rb CHANGED
@@ -1,12 +1,12 @@
1
1
  BeetleReporter::Engine.routes.draw do
2
2
  resources :reports do
3
- get :ignore
4
- get :suspend
5
- get :undo
6
- get :hide
7
- get :remove
8
- get :mute
9
- get :forbid
3
+ post :ignore
4
+ post :undo
5
+ post :suspend
6
+ post :hide
7
+ post :remove
8
+ post :mute
9
+ post :forbid
10
10
  end
11
11
 
12
12
  root "reports#index"
@@ -1,3 +1,3 @@
1
1
  module BeetleReporter
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beetle_reporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - 42up