mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: automatically close a poll on a given date and time
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user