FEATURE: automatically close a poll on a given date and time

This commit is contained in:
Régis Hanol
2018-05-03 02:12:19 +02:00
parent de6dd2dc02
commit ba14c80b9c
15 changed files with 204 additions and 217 deletions

View File

@@ -6,17 +6,13 @@ module DiscoursePoll
def validate_post
min_trust_level = SiteSetting.poll_minimum_trust_level_to_create
trusted = @post&.user&.staff? ||
@post&.user&.trust_level >= TrustLevel[min_trust_level]
if !trusted
message = I18n.t("poll.insufficient_rights_to_create")
@post.errors.add(:base, message)
return false
if @post&.user&.staff? || @post&.user&.trust_level >= TrustLevel[min_trust_level]
true
else
@post.errors.add(:base, I18n.t("poll.insufficient_rights_to_create"))
false
end
true
end
end
end