File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -202,6 +202,10 @@ def is_admin?
202
202
signed_in? && current_user . role == 'admin'
203
203
end
204
204
205
+ def is_moderator?
206
+ signed_in? && current_user . role . in? ( %w( admin moderator ) )
207
+ end
208
+
205
209
def iphone_user_agent?
206
210
request . env [ "HTTP_USER_AGENT" ] && request . env [ "HTTP_USER_AGENT" ] [ /(Mobile\/ .+Safari)/ ]
207
211
end
Original file line number Diff line number Diff line change @@ -241,11 +241,12 @@ def report_inappropriate
241
241
end
242
242
end
243
243
244
- def flag
245
- times_to_flag = is_admin ? ? Protip::MIN_FLAG_THRESHOLD : 1
244
+ def flag
245
+ times_to_flag = is_moderator ? ? Protip::MIN_FLAG_THRESHOLD : 1
246
246
times_to_flag.times do
247
247
@protip.flag
248
248
end
249
+ @protip.mark_as_spam
249
250
respond_to do |format|
250
251
if @protip.save
251
252
format.json { head :ok }
@@ -256,7 +257,7 @@ def flag
256
257
end
257
258
258
259
def unflag
259
- times_to_flag = is_admin ? ? Protip::MIN_FLAG_THRESHOLD : 1
260
+ times_to_flag = is_moderator ? ? Protip::MIN_FLAG_THRESHOLD : 1
260
261
times_to_flag.times do
261
262
@protip.unflag
262
263
end
You can’t perform that action at this time.
0 commit comments