This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def update | |
| @question = current_user.questions.find(params[:id]) | |
| message = "Your question needs to be between 10 and 255 characters" | |
| if @question.update_attributes(params[:question]) | |
| flash[:notice] = message = "Got it! Thanks for updating your question." | |
| status = 200 | |
| end | |
| respond_to do |format| | |
| format.html { redirect_to @question } | |
| format.json { render :json => { :message => message, :status => status, :body => @question.body } ; flash.discard } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(".editable_question").each(function(){ | |
| //setup editing of owned questions | |
| var args = {data: function(value, settings) { | |
| // Unescape HTML | |
| var retval = value | |
| .replace(/&/gi, '&') | |
| .replace(/>/gi, '>') | |
| .replace(/</gi, '<') | |
| .replace(/"/gi, "\""); | |
| return retval; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe "fetch_accounts" do | |
| context "when token does not exist or is expired" do | |
| it "returns the google analytics object from the api using creds in the yml" do | |
| @ga = Gattica.stub_chain(:new, {:email => GoogleAnalytics.config[:email], :password => GoogleAnalytics.config[:password], :profile_id => GoogleAnalytics.config[:profile_id] }).and_return(:auth_token => "DQAAAN4AAABQD6mcU0By5D8asC_zHKAGsGHS8x6npk8Z2N8rnBJao2HsnKWYfZq4xhCudhnhi9rf5SxJ3hMjO3l5AJapphS0grTxKyD9ydtcEP-KXsyF50ptyoq9obtZ3Fxoz6iEYzbP9SiPmV5DOhZ3Qv-oYt9hvCNUOtUBi5mCQXUH-mtWEUhdi3-7CvK6vwusvfhW3_FgQoKX48HwSkf5EnWNTUeF28s6Xgra4jPvY") | |
| Analytics.fetch_accounts(nil).should eq @ga | |
| end | |
| end | |
| context "when token exists" do | |
| it "returns the google analytics object from the api using the token" do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def self.fetch_accounts(token) | |
| results = nil | |
| results = Gattica.new({ :token => token, | |
| :profile_id => GoogleAnalytics.config[:profile_id], | |
| :timeout => 500 }) if token.present? | |
| if results.blank? | |
| results = Gattica.new({ :email => GoogleAnalytics.config[:email], | |
| :password => GoogleAnalytics.config[:password], | |
| :profile_id => GoogleAnalytics.config[:profile_id], | |
| :timeout => 500 }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| begin | |
| SystemTimer.timeout_after(5, MyCustomTimeoutException) do | |
| profile_pic = Koala::Facebook::GraphAPI.new.get_picture(fb_uid, :type => "large") | |
| end | |
| rescue MyCustomTimeoutException => e | |
| ENV['BTS_HOST'] + "/images/missing.png" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if profile_route.nil? || !profile_route.respond_to?(profile.to_sym) | |
| self.profile_route = {profile.to_sym => panda_video.encodings.find_by_profile_name('h264').url} | |
| panda_url = profile.to_sym => panda_video.encodings.find_by_profile_name(profile).url | |
| self.profile_route = {profile.to_sym => panda_url} if panda_url.present? | |
| self.save | |
| else profile_route.has_key?(profile.to_sym) && profile_route[profile.to_sym].blank? | |
| self.update_attribute(profile_route[profile.to_sym], panda_video.encodings.find_by_profile_name(profile).url) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if resource.state_is?("suspended") | |
| scoped = Devise::Mapping.find_scope!(resource) | |
| Devise.sign_out_all_scopes ? sign_out : sign_out(scoped) | |
| flash[:alert] = "You're suspended!" | |
| redirect_to root_path and return | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def self.destroy_and_remove_events(params) | |
| question = Question.find params[:question_id] | |
| transaction do | |
| answers_to_del, comments_to_del = [], [] | |
| answers = question.answers; | |
| comments = []; answers.each {|a| comments << a.comments; answers_to_del << a.id}; comments.flatten! | |
| comments.each{|c| comments_to_del = c.id} | |
| TimelineEvent.delete_all(["subject_type = 'Answer' AND ( subject_id IN (?) )", answers_to_del.to_a.join(',')]) if answers_to_del.present? | |
| TimelineEvent.delete_all(["subject_type = 'Comment' AND ( subject_id IN (?) )", comments_to_del.to_a.join(',')]) if comments_to_del.present? | |
| TimelineEvent.delete_all(["subject_type = 'Question' AND ( subject_id = ? )", question.id]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $number_h: 157px; | |
| #money_amount span { | |
| background-image: url(numbers.png); | |
| background-repeat:no-repeat; | |
| height:$number_h; | |
| width:94px; | |
| display:block; | |
| float:none; | |
| margin:0 auto; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ////in questions#create action | |
| if filter_profanity( @question.body, I18n.t(:bad_words).split( /, */ ) ).present? | |
| redirect_to @question, :alert => I18n.t(:bad_words_warning) and return | |
| end | |
| ///in the application controller |
OlderNewer