flags/appeals: replace is_resolved flag with statuses.

Replace references to the `is_resolved` field with the `status` field.
Post flags were marked as resolved when a post was approved (but not
when the post was deleted because it went unapproved). The status field
supercedes the resolved field.
This commit is contained in:
evazion
2020-08-07 18:53:25 -05:00
parent 2b0cd3c90b
commit 3a17b5a13e
14 changed files with 33 additions and 54 deletions

View File

@@ -30,10 +30,6 @@ class PostEvent
event.try(:reason) || ""
end
def is_resolved
event.try(:is_resolved) || false
end
def creator_id
event.try(:creator_id) || event.try(:user_id)
end
@@ -42,6 +38,18 @@ class PostEvent
event.try(:creator) || event.try(:user)
end
def status
if event.is_a?(PostApproval)
"approved"
elsif (event.is_a?(PostAppeal) && event.succeeded?) || (event.is_a?(PostFlag) && event.rejected?)
"approved"
elsif (event.is_a?(PostAppeal) && event.rejected?) || (event.is_a?(PostFlag) && event.succeeded?)
"deleted"
else
"pending"
end
end
def is_creator_visible?(user = CurrentUser.user)
case event
when PostAppeal, PostApproval
@@ -57,7 +65,7 @@ class PostEvent
"creator_id": nil,
"created_at": nil,
"reason": nil,
"is_resolved": nil,
"status": nil,
"type": nil
}
end