Merge pull request #2240 from bmamlin/closed-poll

allow polls to be closed independently of topic
This commit is contained in:
Sam 2014-04-09 12:10:46 +10:00
commit 90a26ddbb5
6 changed files with 12 additions and 4 deletions

View File

@ -38,7 +38,7 @@ var PollController = Discourse.Controller.extend({
poll: null, poll: null,
showResults: false, showResults: false,
disableRadio: Em.computed.any('poll.post.topic.closed', 'loading'), disableRadio: Em.computed.any('poll.post.poll_details.closed', 'loading'),
actions: { actions: {
selectOption: function(option) { selectOption: function(option) {

View File

@ -14,3 +14,4 @@ en:
cannot_have_modified_options: "cannot be modified after the first five minutes. Contact a moderator if you need to change them." cannot_have_modified_options: "cannot be modified after the first five minutes. Contact a moderator if you need to change them."
cannot_add_or_remove_options: "can only be edited, not added or removed. If you need to add or remove options you should lock this topic and create a new one." cannot_add_or_remove_options: "can only be edited, not added or removed. If you need to add or remove options you should lock this topic and create a new one."
prefix: "Poll:" prefix: "Poll:"
closed_prefix: "Closed Poll:"

View File

@ -14,3 +14,4 @@ es:
cannot_have_modified_options: "no se pueden modificar las respuestas de la encuesta pasados 5 minutos" cannot_have_modified_options: "no se pueden modificar las respuestas de la encuesta pasados 5 minutos"
cannot_add_or_remove_options: "solo se puede modificar, no se pueden añadir o quitar. Si necesitas añadir o quitar respuestas debes bloquear este tema y crear una encuesta nueva." cannot_add_or_remove_options: "solo se puede modificar, no se pueden añadir o quitar. Si necesitas añadir o quitar respuestas debes bloquear este tema y crear una encuesta nueva."
prefix: "Encuesta:" prefix: "Encuesta:"
closed_prefix: "Encuesta Cerrada:"

View File

@ -20,3 +20,4 @@ fr:
cannot_have_modified_options: "ne peuvent pas être modifiés après 5 minutes. Merci de contacter un moderateur, si vous souhaitez les modifier" cannot_have_modified_options: "ne peuvent pas être modifiés après 5 minutes. Merci de contacter un moderateur, si vous souhaitez les modifier"
cannot_add_or_remove_options: "peuvent seulement être modifiés. Si vous souhaitez en supprimer ou en ajouter, veuillez créer un nouveau sujet." cannot_add_or_remove_options: "peuvent seulement être modifiés. Si vous souhaitez en supprimer ou en ajouter, veuillez créer un nouveau sujet."
prefix: "Sondage\\s?:" prefix: "Sondage\\s?:"
closed_prefix: "Sondage\\s? Fermé:"

View File

@ -14,3 +14,4 @@ it:
cannot_have_modified_options: "non possono essere modificate dopo i primi cinque minuti. Contatta un moderatore se hai bisogno di cambiarle." cannot_have_modified_options: "non possono essere modificate dopo i primi cinque minuti. Contatta un moderatore se hai bisogno di cambiarle."
cannot_add_or_remove_options: "non possono essere modificate, aggiunte o rimosse. Se vuoi aggiungere o rimuovere opzioni al sondaggio, devi bloccare questo topice crearne uno nuovo." cannot_add_or_remove_options: "non possono essere modificate, aggiunte o rimosse. Se vuoi aggiungere o rimuovere opzioni al sondaggio, devi bloccare questo topice crearne uno nuovo."
prefix: "Sondaggio:" prefix: "Sondaggio:"
closed_prefix: "Sondaggio Chiuso:"

View File

@ -21,7 +21,7 @@ module ::PollPlugin
return false return false
end end
topic.title =~ /^#{I18n.t('poll.prefix')}/i topic.title =~ /^(#{I18n.t('poll.prefix')}|#{I18n.t('poll.closed_prefix')})/i
end end
def has_poll_details? def has_poll_details?
@ -59,6 +59,10 @@ module ::PollPlugin
end end
end end
def is_closed?
@post.topic.closed? || (@post.topic.title =~ /^#{I18n.t('poll.closed_prefix')}/i) === 0
end
def options def options
cooked = PrettyText.cook(@post.raw, topic_id: @post.topic_id) cooked = PrettyText.cook(@post.raw, topic_id: @post.topic_id)
parsed = Nokogiri::HTML(cooked) parsed = Nokogiri::HTML(cooked)
@ -136,7 +140,7 @@ module ::PollPlugin
end end
def set_vote!(user, option) def set_vote!(user, option)
return if @post.topic.closed? return if is_closed?
# Get the user's current vote. # Get the user's current vote.
vote = get_vote(user) vote = get_vote(user)
@ -152,7 +156,7 @@ module ::PollPlugin
def serialize(user) def serialize(user)
return nil if details.nil? return nil if details.nil?
{options: details, selected: get_vote(user)} {options: details, selected: get_vote(user), closed: is_closed?}
end end
private private