fixed language files, added rails cache counter for poll answer, fixed bug with same poll input for form

This commit is contained in:
Jannik Streek 2014-03-30 16:48:15 +02:00
parent 4174b88987
commit 6f3844b73b
6 changed files with 33 additions and 13 deletions

View file

@ -333,6 +333,9 @@ app.views.Publisher = Backbone.View.extend({
// clear location
this.destroyLocation();
// clear poll form
this.clearPollForm();
// force textchange plugin to update lastValue
this.el_input.data('lastValue', '');
this.el_hiddenInput.data('lastValue', '');
@ -340,6 +343,11 @@ app.views.Publisher = Backbone.View.extend({
return this;
},
clearPollForm : function(){
this.$('#poll_question').val('');
this.$('.poll_answer_input').val('');
},
tryClose : function(){
// if it is not submittable, close it.
if( !this._submittable() ){

View file

@ -10,9 +10,4 @@ class PollAnswer < ActiveRecord::Base
self.include_root_in_json = false
def update_vote_counter
self.vote_count += 1
self.save!
end
end

View file

@ -5,19 +5,13 @@ class PollParticipation < ActiveRecord::Base
include Diaspora::Guid
include Diaspora::Relayable
belongs_to :poll
belongs_to :poll_answer
belongs_to :poll_answer, counter_cache: :vote_count
belongs_to :author, :class_name => 'Person', :foreign_key => :author_id
xml_attr :diaspora_handle
xml_attr :poll_answer_guid
xml_convention :underscore
validate :not_already_participated
after_commit :update_vote_counter, :on => :create
def update_vote_counter
self.poll_answer.update_vote_counter
end
def parent_class
Poll
end

View file

@ -26,3 +26,11 @@
attributes:
from_id:
taken: "is a duplicate of a pre-existing request."
poll:
attributes:
poll_answers:
not_enough_poll_answers: "Not enough poll options provided."
poll_participation:
attributes:
poll:
already_participated: "You've already participated in this poll!"

View file

@ -26,3 +26,11 @@
attributes:
from_id:
taken: "is a duplicate of a pre-existing request."
poll:
attributes:
poll_answers:
not_enough_poll_answers: "Not enough poll options provided."
poll_participation:
attributes:
poll:
already_participated: "You've already participated in this poll!"

View file

@ -26,4 +26,11 @@
attributes:
from_id:
taken: "is a duplicate of a pre-existing request."
poll:
attributes:
poll_answers:
not_enough_poll_answers: "Not enough poll options provided."
poll_participation:
attributes:
poll:
already_participated: "You've already participated in this poll!"