mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 11:11:13 +08:00
introduce Enum
This commit is contained in:
@ -21,7 +21,7 @@ join (
|
||||
limit 100
|
||||
"
|
||||
|
||||
sql.where2 "post_action_type_id in (:flag_types)", flag_types: PostActionType.FlagTypes
|
||||
sql.where2 "post_action_type_id in (:flag_types)", flag_types: PostActionType.flag_types.values
|
||||
|
||||
|
||||
# it may make sense to add a view that shows flags on deleted posts,
|
||||
@ -62,7 +62,7 @@ limit 100
|
||||
from post_actions a
|
||||
/*where*/
|
||||
"
|
||||
sql.where("post_action_type_id in (:flag_types)", flag_types: PostActionType.FlagTypes)
|
||||
sql.where("post_action_type_id in (:flag_types)", flag_types: PostActionType.flag_types.values)
|
||||
sql.where("post_id in (:posts)", posts: posts.map{|p| p["id"].to_i})
|
||||
|
||||
if params[:filter] == 'old'
|
||||
|
@ -8,7 +8,7 @@ class PostActionsController < ApplicationController
|
||||
def create
|
||||
id = params[:post_action_type_id].to_i
|
||||
if action = PostActionType.where(id: id).first
|
||||
guardian.ensure_post_can_act!(@post, PostActionType.Types.invert[id])
|
||||
guardian.ensure_post_can_act!(@post, PostActionType.types[id])
|
||||
|
||||
post_action = PostAction.act(current_user, @post, action.id, params[:message])
|
||||
|
||||
|
@ -134,9 +134,9 @@ class PostsController < ApplicationController
|
||||
post = find_post_from_params
|
||||
if current_user
|
||||
if params[:bookmarked] == "true"
|
||||
PostAction.act(current_user, post, PostActionType.Types[:bookmark])
|
||||
PostAction.act(current_user, post, PostActionType.types[:bookmark])
|
||||
else
|
||||
PostAction.remove_act(current_user, post, PostActionType.Types[:bookmark])
|
||||
PostAction.remove_act(current_user, post, PostActionType.types[:bookmark])
|
||||
end
|
||||
end
|
||||
render :nothing => true
|
||||
|
Reference in New Issue
Block a user