beetle_reporter 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d11171951d3f41267ff60f38549fe8448cba2bbd139f5c2e94a2a811ef59b8b0
4
- data.tar.gz: db309e98c5fc8b773341534950a3180373624f79f0237a7e788cd59b5c4ebb53
3
+ metadata.gz: dd4664c26bd5a899fc6000d4bfc6ff601bbb797621639b3da7a72e120995ec64
4
+ data.tar.gz: 1ce9dd17994c831c23cd4950da60e0de5a7968f8216b889054f1efabd7476db8
5
5
  SHA512:
6
- metadata.gz: 190aff907f7d2a7c6c91454661f1005d6a259e51571ec39b0aece2f48f63c9ebf6b417dda9d8b9e87703946a97ec139f48850ecab1e18b9a715a88f81c9e3d5a
7
- data.tar.gz: 94416c640937569fa17af54e45cf57636329fcae93ffbaaa7ace994a8602865bd54ece19ab0ed371aff79d4994cc81e371f640c409adb69b76cf9c99882e3bab
6
+ metadata.gz: 76f8fccbeac3b4905d74dc29a08cbc8d15aa8d88a74d731f37ed351406b9a00a288612c9e754fe7be5a7f83452baa9901566644e1c6853e740f114161f55327f
7
+ data.tar.gz: 44d7d828b78dfd4975c1a913e60f6982618776a84ee297450f2cadeba3e7a0c655ef2b0ff815789257f2a34243aae6e6239c8a308dbd89cb4e4e11fcb7962ad0
data/README.md CHANGED
@@ -76,8 +76,8 @@ class Diary
76
76
  true
77
77
  end
78
78
 
79
- def beetle_images
80
- pictures.map{|pic| {src: pic.full_url} }
79
+ def beetle_record_partial_path
80
+ "admins/diaries/beetle"
81
81
  end
82
82
  end
83
83
  ```
@@ -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
- %span{class: "bg-yellow-100 text-yellow-600 rounded-md p-1"}=t("beetle_reporter.aasm_state.#{report.aasm_state}")
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
- %div
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"
@@ -1,3 +1,3 @@
1
1
  module BeetleReporter
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -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)
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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - 42up