beetle_reporter 0.1.2 → 0.1.6

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: 24b6563a2096ba4ca3eb345d77e54cea2a943094593dda9bcd92b618c401e7f0
4
+ data.tar.gz: 0a870def812d3a4a859d52a048aa1446441bdf7bbc17777bc1f8a3f960151321
5
5
  SHA512:
6
- metadata.gz: 190aff907f7d2a7c6c91454661f1005d6a259e51571ec39b0aece2f48f63c9ebf6b417dda9d8b9e87703946a97ec139f48850ecab1e18b9a715a88f81c9e3d5a
7
- data.tar.gz: 94416c640937569fa17af54e45cf57636329fcae93ffbaaa7ace994a8602865bd54ece19ab0ed371aff79d4994cc81e371f640c409adb69b76cf9c99882e3bab
6
+ metadata.gz: 6ad09509f95b58aef57b4b49369da7728bb67dd314b249e90c870087e8b5ef83ed92bcc29e2ef21b5424c500193c96fbd49fb7f40e602371eb4476d77ea1e0c8
7
+ data.tar.gz: ee6fa6748f925ca7ad340e717017a5de2686c355c950e700cf9400ad263f475d1cf8bcc865082c8915ce11c1eeb2e6d54578013efd23257413d70cd514b8e40d
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'
@@ -62,16 +62,7 @@ module BeetleReporter
62
62
  return if record&.user.blank?
63
63
  raise NoMethodError unless record.respond_to?(:beetle_mute)
64
64
 
65
- ret = record.beetle_mute
66
- mute!(reason) if ret
67
- end
68
-
69
- def beetle_mute(reason)
70
- return if record.blank?
71
- return if record&.user.blank?
72
- raise NoMethodError unless record.respond_to?(:beetle_mute)
73
-
74
- ret = record.beetle_mute
65
+ ret = record.beetle_mute(reason)
75
66
  mute!(reason) if ret
76
67
  end
77
68
 
@@ -80,7 +71,7 @@ module BeetleReporter
80
71
  return if record&.user.blank?
81
72
  raise NoMethodError unless record.respond_to?(:beetle_forbid)
82
73
 
83
- ret = record.beetle_forbid
74
+ ret = record.beetle_forbid(reason)
84
75
  forbid!(reason) if ret
85
76
  end
86
77
 
@@ -90,6 +81,10 @@ module BeetleReporter
90
81
  record.beetle_record_path
91
82
  end
92
83
 
84
+ def record_partial_path
85
+ record.beetle_record_partial_path
86
+ end
87
+
93
88
  def undo_callback
94
89
  if hidden?
95
90
  ret = record.beetle_undo_hide
@@ -108,15 +103,6 @@ module BeetleReporter
108
103
  end
109
104
  end
110
105
 
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
106
  def set_reason(reason)
121
107
  update_columns(reason: reason)
122
108
  end
@@ -5,12 +5,15 @@
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}"
12
15
  %span{class: "space-x-1"}
13
- - report.user_ids.each do |uid|
16
+ - report.user_ids.compact.uniq.each do |uid|
14
17
  = link_to main_app.send(BeetleReporter.config.main_app_user_path_method.to_sym, uid), data: {turbo: false} do
15
18
  %span{class: "bg-blue-100 rounded-lg px-1 py-0.5"}= "#{uid}"
16
19
  %span{class: "bg-red-600 text-white rounded-full w-5 h-5 flex justify-center items-center"}= "#{report.reported_count}"
@@ -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"
@@ -14,7 +14,7 @@
14
14
  %span 举报中心
15
15
 
16
16
  %ul{class: "flex justify-end items-center space-x-2 text-blue-600"}
17
- %li= link_to "待处理(#{BeetleReporter::Report.pending.count})", reports_path
17
+ %li= link_to "待处理(#{BeetleReporter::Report.kept.pending.count})", reports_path
18
18
  %li= link_to "控制台", main_app.send(BeetleReporter.config.main_app_root_path_method.to_sym)
19
19
  %li= current_user.email
20
20
 
@@ -1,3 +1,3 @@
1
1
  module BeetleReporter
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.6'
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,14 +1,14 @@
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.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - 42up
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-17 00:00:00.000000000 Z
11
+ date: 2021-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails