beetle_reporter 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/controllers/beetle_reporter/reports_controller.rb +2 -1
- data/app/models/beetle_reporter/report.rb +4 -9
- data/app/views/beetle_reporter/reports/_report.html.haml +9 -20
- data/lib/beetle_reporter/version.rb +1 -1
- data/lib/beetle_reporter.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd4664c26bd5a899fc6000d4bfc6ff601bbb797621639b3da7a72e120995ec64
|
4
|
+
data.tar.gz: 1ce9dd17994c831c23cd4950da60e0de5a7968f8216b889054f1efabd7476db8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76f8fccbeac3b4905d74dc29a08cbc8d15aa8d88a74d731f37ed351406b9a00a288612c9e754fe7be5a7f83452baa9901566644e1c6853e740f114161f55327f
|
7
|
+
data.tar.gz: 44d7d828b78dfd4975c1a913e60f6982618776a84ee297450f2cadeba3e7a0c655ef2b0ff815789257f2a34243aae6e6239c8a308dbd89cb4e4e11fcb7962ad0
|
data/README.md
CHANGED
@@ -135,11 +135,12 @@ module BeetleReporter
|
|
135
135
|
def load_reports
|
136
136
|
builder = report_scope.includes(:record)
|
137
137
|
builder = builder.where("reason ilike ?", "%#{params[:q]}%") if params[:q].present?
|
138
|
+
|
138
139
|
if params[:filter] != 'all'
|
139
140
|
builder = builder.pending
|
140
141
|
builder = builder.unscope(where: :aasm_state).where(aasm_state: params[:state]) if params[:state].present?
|
141
142
|
end
|
142
|
-
builder = builder.where(record_type: params[:type]&.classify) if params[:type]
|
143
|
+
builder = builder.where(record_type: params[:type]&.classify) if params[:type].present?
|
143
144
|
|
144
145
|
builder = builder.order(id: :desc, reported_count: :desc)
|
145
146
|
builder = builder.reorder(updated_at: :desc) if params[:order] == 'last_updated'
|
@@ -90,6 +90,10 @@ module BeetleReporter
|
|
90
90
|
record.beetle_record_path
|
91
91
|
end
|
92
92
|
|
93
|
+
def record_partial_path
|
94
|
+
record.beetle_record_partial_path
|
95
|
+
end
|
96
|
+
|
93
97
|
def undo_callback
|
94
98
|
if hidden?
|
95
99
|
ret = record.beetle_undo_hide
|
@@ -108,15 +112,6 @@ module BeetleReporter
|
|
108
112
|
end
|
109
113
|
end
|
110
114
|
|
111
|
-
def images
|
112
|
-
return [] if record.blank?
|
113
|
-
|
114
|
-
raise NoMethodError, 'undefined beetle_images for record' unless record.respond_to?(:beetle_images)
|
115
|
-
|
116
|
-
record.beetle_images
|
117
|
-
end
|
118
|
-
|
119
|
-
|
120
115
|
def set_reason(reason)
|
121
116
|
update_columns(reason: reason)
|
122
117
|
end
|
@@ -5,7 +5,10 @@
|
|
5
5
|
- unless report.record.blank?
|
6
6
|
= link_to report.record_path, data: { turbo: false }, target: "_blank" do
|
7
7
|
%span{class: "bg-indigo-100 text-indigo-600 py-1 px-2 rounded-lg"}="#{report.record_type.upcase}##{report.record_id}"
|
8
|
-
|
8
|
+
%span{class: "bg-yellow-100 text-yellow-600 rounded-md p-1"}=t("beetle_reporter.aasm_state.#{report.aasm_state}")
|
9
|
+
- unless report.reasons.blank?
|
10
|
+
- report.reasons.each do |reason|
|
11
|
+
%span{class: "border border-red-600 text-red-600 rounded-lg text-xs p-0.5"}= reason
|
9
12
|
%span{class: "flex space-x-2 items-center text-sm"}
|
10
13
|
- if report.reason
|
11
14
|
%span{class: "bg-red-100 text-red-600 p-1 rounded-lg"}= "处置原因:#{report.reason}"
|
@@ -20,26 +23,12 @@
|
|
20
23
|
= button_to '删除', report, method: :delete, data: { confirm: 'Are you sure?'}, class: "bg-red-600 text-white rounded-md px-2 py-0.5 cursor-pointer"
|
21
24
|
%div{class: "flex justify-between items-center py-2 w-full"}
|
22
25
|
%div{class: "flex flex-col rounded-lg bg-gray-50 p-3 text-sm space-y-4 w-full"}
|
23
|
-
-unless report.record
|
24
|
-
%h3{class: "text-2xl text-red-600"}
|
26
|
+
- unless report.record
|
27
|
+
%h3{class: "text-2xl text-red-600 flex items-center"}
|
28
|
+
对应条目已被永久删除,当前审核请求已无效
|
29
|
+
=button_to "点我删除", report, method: :delete, class: "ml-2 bg-yellow-500 text-white rounded-lg px-2 py-0.5 cursor-pointer"
|
25
30
|
- else
|
26
|
-
|
27
|
-
%span{class: "#{report.record.is_private ? 'bg-black text-white' : 'border border-black text-black' } rounded-lg text-xs p-0.5 px-1"}=report.record.is_private ? "🙈 隐私" : "🙉 公开"
|
28
|
-
%span{class: "border border-blue-600 text-blue-600 rounded-lg text-xs p-0.5"}=report.record.is_approved ? "审核通过" : "审核中..."
|
29
|
-
- unless report.reasons.blank?
|
30
|
-
- report.reasons.each do |reason|
|
31
|
-
%span{class: "border border-red-600 text-red-600 rounded-lg text-xs p-0.5"}= reason
|
32
|
-
- unless report&.record&.user_id&.blank?
|
33
|
-
= link_to main_app.send(CensorBear.config.main_app_user_path_method.to_sym, report.record.user_id), data: {turbo: false} do
|
34
|
-
%span{class: "text-sm bg-gray-100 text-gray-600 py-1 px-2 rounded-lg font-bold"}="✍️ ##{report.record.user_id}"
|
35
|
-
- if report.record.discarded?
|
36
|
-
%div{class: "text-gray-900 leading-relaxed"}
|
37
|
-
%del= report.record.content
|
38
|
-
- else
|
39
|
-
%div{class: "text-gray-900 leading-relaxed"}= report.record.content
|
40
|
-
%div
|
41
|
-
- report.images.each do |img|
|
42
|
-
= image_tag img[:src], class: "w-16 rounded-md"
|
31
|
+
= render report.record_partial_path, record: report.record
|
43
32
|
%div{class: "flex flex-col space-y-2"}
|
44
33
|
- if report.may_ignore?
|
45
34
|
= button_to "无效举报", report_ignore_path(report), class: "text-yellow-600 cursor-pointer px-2 py-0.5 bg-gray-100 rounded-lg"
|
data/lib/beetle_reporter.rb
CHANGED
@@ -28,7 +28,7 @@ module BeetleReporter
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def add(record, user_id, reason)
|
31
|
-
report = BeetleReporter::Report.find_by(record: record)
|
31
|
+
report = BeetleReporter::Report.pending.kept.find_by(record: record)
|
32
32
|
if report
|
33
33
|
report.user_ids << user_id unless report.user_ids.include?(user_id)
|
34
34
|
report.reasons << reason unless report.reasons.include?(reason)
|