From 0f0321d0012f0fa088b599433b2e94b08aca460a Mon Sep 17 00:00:00 2001
From: Pavel
Date: Sun, 4 Apr 2010 13:52:13 +0300
Subject: [PATCH] Major changes after Nina discussions
---
online/app/controllers/admin_controller.rb | 2 +-
online/app/controllers/user_controller.rb | 69 +++++++++++++++++-------------
online/app/views/stages/new.html.erb | 5 ++-
online/app/views/user/_question.fbml.erb | 14 ++++++
online/app/views/user/greetings.fbml.erb | 8 ++--
online/app/views/user/question1.fbml.erb | 15 +------
online/app/views/user/question2.fbml.erb | 15 +------
online/app/views/user/question3.fbml.erb | 15 +------
8 files changed, 66 insertions(+), 77 deletions(-)
create mode 100644 online/app/views/user/_question.fbml.erb
diff --git a/online/app/controllers/admin_controller.rb b/online/app/controllers/admin_controller.rb
index d6b12b4..614273b 100644
--- a/online/app/controllers/admin_controller.rb
+++ b/online/app/controllers/admin_controller.rb
@@ -69,7 +69,7 @@ require 'csv'
cookies[:auth] = "ok"
flash[:notice] = 'Successfully logged in'
respond_to do |format|
- format.html { redirect_to "/admin" }
+ format.html { redirect_to admin_url }
end
else
flash[:notice] = 'Incorrect login and/or password'
diff --git a/online/app/controllers/user_controller.rb b/online/app/controllers/user_controller.rb
index 0fed242..1d1bb82 100644
--- a/online/app/controllers/user_controller.rb
+++ b/online/app/controllers/user_controller.rb
@@ -3,9 +3,11 @@ class UserController < ApplicationController
ensure_application_is_installed_by_facebook_user
before_filter :source_statistic
before_filter :loading_static
- Feed_action = "Know better your friends"
+ Feed_action = "Take the Nokia E72 Friendship Challenge"
def source_statistic
+ @time_counter = Time.now
+ @time_counter0 = Time.now
if (params[:f]) && (params[:f].to_i != 0)
add_stat(0, VISITED, params[:f] ? params[:f].to_i : 0)
end
@@ -18,8 +20,6 @@ class UserController < ApplicationController
end
end
- "Example '{owner_name}, I chat with you the most. I also picked {friends_names}. Let's stay in touch'"
-
def processing_phraze (text_to_process, owner_name, friends_names,gender = "",number_of_friends = 0)
text = text_to_process
text = text.gsub("{owner_name}",owner_name)
@@ -96,18 +96,20 @@ class UserController < ApplicationController
end
#end if @fbuser == nil
end
- today_question_select
- render :action => "question1"
+ today_question_select 0
+ @question_number = "question1"
+ render :action => @question_number
end
end
- def today_question_select
+ def today_question_select number
today_now = Time.now
today = Date.new(today_now.year,today_now.month,today_now.day)
- @today_question = Stage.find(:first, :conditions => ["date = ?", today ] )
-
- if @today_question.blank?
- @today_question = Stage.find(:first, :order => "id DESC" )
+ today_questions = Stage.find(:all, :conditions => ["date = ?", today ] )
+ @today_question = today_questions[number]
+ if @today_question[number].blank?
+ today_questions = Stage.find(:all, :order => "date DESC" )
+ @today_question = today_questions[number]
if @today_question.blank?
render :facebook_error
end
@@ -115,32 +117,35 @@ class UserController < ApplicationController
end
def question1
- @time_counter = Time.now
- @time_counter0 = Time.now
- today_question_select
+
+
+ today_question_select 0
user_has_published_once = false
user_has_published_once = question_processor 1
if user_has_published_once == true
+ @next_step = "question2"
render :action => "greetings"
end
- p " > > >FULL TIME: #{Time.now - @time_counter0}"
end
def question2
+
+ today_question_select 1
user_has_published_once = false
user_has_published_once = question_processor 2
if user_has_published_once == true
- render :action => "question3"
-
+ @next_step = "question3"
+ render :action => "greetings"
end
end
def question3
+
+ today_question_select 2
user_has_published_once = false
user_has_published_once = question_processor 3
if user_has_published_once == true
- session_new = Facebooker::Session.create
- @userFB = Facebooker::User.new(session[:facebook_session].user.uid, session_new)
+ @next_step = "question1"
render :action => "greetings"
end
end
@@ -262,7 +267,7 @@ class UserController < ApplicationController
session_new.batch do
feeds_to_publish.each {|one|
- publishing(one[:user_from],one[:user_to],one[:main_message],Feed_action,FB_app_link + "?f=#{FROM_FEEDS}",processing_phraze(@today_question.feedtext1, @user_local.first_name, self_publishing,@user_local.gender,user_names.size ) ,FB_app_link + "?f=#{FROM_FEEDS}",processing_phraze(@today_question.feedtext2, @user_local.first_name, self_publishing,@user_local.gender,user_names.size ),'image',Current_site + @today_question.feedpic.url(:normal),FB_app_link + "?f=#{FROM_FEEDS}")
+ #publishing(one[:user_from],one[:user_to],one[:main_message],Feed_action,FB_app_link + "?f=#{FROM_FEEDS}",processing_phraze(@today_question.feedtext1, @user_local.first_name, self_publishing,@user_local.gender,user_names.size ) ,FB_app_link + "?f=#{FROM_FEEDS}",processing_phraze(@today_question.feedtext2, @user_local.first_name, self_publishing,@user_local.gender,user_names.size ),'image',Current_site + @today_question.feedpic.url(:normal),FB_app_link + "?f=#{FROM_FEEDS}")
}
end
time_counter ("Session batch")
@@ -275,18 +280,24 @@ class UserController < ApplicationController
def greetings
debug_message "Now session[:self_publishing] = '#{session[:self_publishing]}'"
+ if params[:fanbutton] != nil
+ redirect_to "http://www.facebook.com/pages/Chatting-and-Emailing-with-Nokia/10150115816675015"
+ end
+
if params[:mybutton] != nil
- if params[:mybutton] == "Publish"
- session_new = Facebooker::Session.create
- @userFB = Facebooker::User.new(session[:facebook_session].user.uid, session_new)
- random_friend_num = rand(@userFB.friends.size)
- @userFB2 = Facebooker::User.new(@userFB.friends[random_friend_num].uid, session_new)
-
- scenario_themself = "#{@userFB2.first_name}, I picked up #{params[:self_publishing]} as my top friends to win Nokia E72. Sorry I didn't pick you, but you can try your luck here."
- debug_message scenario_themself
+ p "params[:next_step] = #{params[:next_step]}"
+ @question_number = params[:next_step]
+ case @question_number
+ when "question1"
+ today_question_select 0
+ when "question2"
+ today_question_select 1
+ when "question3"
+ today_question_select 2
end
- redirect_to "http://facebook.com"
- end
+
+ render :action => @question_number
+ end
end
def product
diff --git a/online/app/views/stages/new.html.erb b/online/app/views/stages/new.html.erb
index 1ac5a21..c25f8ae 100644
--- a/online/app/views/stages/new.html.erb
+++ b/online/app/views/stages/new.html.erb
@@ -12,13 +12,14 @@
<%= f.text_area :question, :size => "60x2" %>
- <%=ApplicationController::Feed_useraction_instruction %>
<%= f.label :feed_useraction %>
+ <%=ApplicationController::Feed_useraction_instruction %>
<%= f.text_area :feed_useraction, :size => "60x4" %>
- <%=ApplicationController::Feed_selfaction_instruction %>
<%= f.label :feed_selfaction %>
+ <%=ApplicationController::Feed_selfaction_instruction %>
+
<%= f.text_area :feed_selfaction, :size => "60x4" %>
diff --git a/online/app/views/user/_question.fbml.erb b/online/app/views/user/_question.fbml.erb
new file mode 100644
index 0000000..ade5481
--- /dev/null
+++ b/online/app/views/user/_question.fbml.erb
@@ -0,0 +1,14 @@
+
+
+
+ <%=@today_question.question%>
+
+
+
+
+
+ <% form_tag "#{@question_number}", {:id=>"testForm" ,:method => :put, :style => "font-size:14px;"} do%>
+ <%=fiveQuestions %>
+ <%= submit_tag 'Submit to start conversations with them' %>
+ <%end%>
+
diff --git a/online/app/views/user/greetings.fbml.erb b/online/app/views/user/greetings.fbml.erb
index 98f66df..d01d1bf 100644
--- a/online/app/views/user/greetings.fbml.erb
+++ b/online/app/views/user/greetings.fbml.erb
@@ -21,11 +21,13 @@
<%=@statics.greetings %>
-
-
+
<% form_tag({:controller => "user", :action => "greetings"}, :method => "get") do %>
-
+
+
+
+
<% end %>
diff --git a/online/app/views/user/question1.fbml.erb b/online/app/views/user/question1.fbml.erb
index 9afe956..8c72eab 100644
--- a/online/app/views/user/question1.fbml.erb
+++ b/online/app/views/user/question1.fbml.erb
@@ -1,14 +1 @@
-
-
-
- <%=@today_question.question%>
-
-
-
-
-
- <% form_tag "question1", {:id=>"testForm" ,:method => :put, :style => "font-size:14px;"} do%>
- <%=fiveQuestions %>
- <%= submit_tag 'Submit to start conversations' %>
- <%end%>
-
+ <%= render :partial => "question" %>
diff --git a/online/app/views/user/question2.fbml.erb b/online/app/views/user/question2.fbml.erb
index e6360da..ae1bfbb 100644
--- a/online/app/views/user/question2.fbml.erb
+++ b/online/app/views/user/question2.fbml.erb
@@ -1,14 +1 @@
-
-
-
- Which of your 5 friends would you invite on your Birthay in the first raw?
-
-
-
-
-
- <% form_tag "question2", {:id=>"testForm" ,:method => :put, :style => "font-size:14px;"} do%>
- <%=fiveQuestions %>
- <%= submit_tag 'Submit to start conversations' %>
- <%end%>
-
+<%= render :partial => "question" %>
diff --git a/online/app/views/user/question3.fbml.erb b/online/app/views/user/question3.fbml.erb
index d6efb7c..ae1bfbb 100644
--- a/online/app/views/user/question3.fbml.erb
+++ b/online/app/views/user/question3.fbml.erb
@@ -1,14 +1 @@
-
-
-
- Which of your 5 friends do you find most sporty?
-
-
-
-
-
- <% form_tag "question3", {:id=>"testForm" ,:method => :put, :style => "font-size:14px;"} do%>
- <%=fiveQuestions %>
- <%= submit_tag 'Submit to start conversations' %>
- <%end%>
-
+<%= render :partial => "question" %>
--
2.11.4.GIT