summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Mathiesen <marius@shortcut.no>2009-12-07 11:09:52 +0100
committerMarius Mathiesen <marius@shortcut.no>2009-12-07 11:18:46 +0100
commit1c6e4636c41fffb990fb78e694bda58eb0d02831 (patch)
tree77b8f0b45ac1c841e9ce6c1ef82d9a009a1bc327
parent5d844fbe493ce48a9fd0a5b8a7befccc96424f1a (diff)
downloadgitorious-mainline-outdated-1c6e4636c41fffb990fb78e694bda58eb0d02831.zip
gitorious-mainline-outdated-1c6e4636c41fffb990fb78e694bda58eb0d02831.tar.gz
gitorious-mainline-outdated-1c6e4636c41fffb990fb78e694bda58eb0d02831.tar.bz2
Do not use Ajax for loading events, deleting now obsolete code
-rw-r--r--app/controllers/users_controller.rb35
-rw-r--r--app/views/events/_events.html.erb2
-rw-r--r--app/views/users/show.html.erb12
-rw-r--r--public/javascripts/application.js29
-rw-r--r--test/functional/users_controller_test.rb26
5 files changed, 11 insertions, 93 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 1060b8f..78f24f0 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -25,9 +25,9 @@ class UsersController < ApplicationController
:pending_activation, :activate, :forgot_password, :forgot_password_create, :reset_password
]
before_filter :require_not_logged_in, :only => [:pending_activation]
- before_filter :login_required, :only => [:edit, :update, :password, :update_password, :avatar, :watched_activities]
- before_filter :find_user, :only => [:show, :edit, :update, :password, :update_password, :avatar, :activities, :watched_activities]
- before_filter :require_current_user, :only => [:edit, :update, :password, :update_password, :avatar, :watched_activities]
+ before_filter :login_required, :only => [:edit, :update, :password, :update_password, :avatar]
+ before_filter :find_user, :only => [:show, :edit, :update, :password, :update_password, :avatar]
+ before_filter :require_current_user, :only => [:edit, :update, :password, :update_password, :avatar]
before_filter :require_identity_url_in_session, :only => [:openid_build, :openid_create]
before_filter :require_public_user, :only => :show
renders_in_global_context
@@ -38,35 +38,6 @@ class UsersController < ApplicationController
def new
end
- def activities
- respond_to do |wants|
- wants.js do
- @event_pagination_params = {:action => "show"}
- render(:partial => "events/events", :locals => {
- :events => @user.events.paginate({
- :page => params[:page],
- :order => "events.created_at desc",
- :include => [:user, :project]
- })
- })
- end
- end
- end
-
- def watched_activities
- @events = @user.events_in_watchlist.paginate(:page => params[:page],
- :include => [:user, :project])
- respond_to do |wants|
- wants.js do
- @event_pagination_params = {:action => "show", :events => "watched"}
- render(:partial => "events/events", :locals => {
- :events => @events
- })
- render :partial => "events/events", :locals => {:events => @events}
- end
- end
- end
-
def show
@projects = @user.projects.find(:all, :include => [:tags, { :repositories => :project }])
@repositories = @user.commit_repositories
diff --git a/app/views/events/_events.html.erb b/app/views/events/_events.html.erb
index 8cfaeb6..8b009f0 100644
--- a/app/views/events/_events.html.erb
+++ b/app/views/events/_events.html.erb
@@ -32,5 +32,5 @@
</li>
<% end -%>
</ul>
-<%= will_paginate events, :params => @event_pagination_params -%>
+<%= will_paginate events -%>
<% end -%>
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index 359514f..c891354 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -88,11 +88,13 @@
</h2>
<% if is_current_user?(@user) %>
<ul class="tab-bar">
- <li class="toggle_event_selection_for_user mine on">
- <%= link_to("Your activities", activities_user_path(@user)) -%></li>
- <li class="toggle_event_selection_for_user watched off">
- <%= link_to("Watched activitites", watched_activities_user_path(@user)) -%>
- </li>
+ <% [["Your activities", params[:events].blank?, {}],
+ ["Watched activities", params[:events] == "watched", {:events => "watched"}]]
+ .each do |label, on_display, event_params| -%>
+ <li class="<%= on_display ? 'on' : 'off' -%>">
+ <%= link_to(label, user_path(@user, event_params)) -%>
+ </li>
+ <% end -%>
</ul>
<% end %>
<div id="user_events">
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 7b8717a..5b2e138 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -188,35 +188,6 @@ $(document).ready(function() {
// :method => whatever is used in link_to etc.
jQuery("a[data-request-method]").replaceRailsGeneratedForm();
- // Toggle between my activitites/watched activities on ~username
- jQuery(".toggle_event_selection_for_user a").live("click", function (){
- var onComplete = function (payload, parentElement){
- jQuery("#user_events").html(payload);
- jQuery(".toggle_event_selection_for_user.mine").toggleClass("on").toggleClass("off");
- jQuery(".toggle_event_selection_for_user.watched").toggleClass("off").toggleClass("on");
- parentElement.removeClass("waiting");
- }
-
- if ($(this).parent().hasClass("off")) { // User clicked something else
- var tabBar = $(this).parents(".tab-bar");
- var url = $(this).attr("href")
- var cacheKey = "cached_" + url;
- tabBar.addClass("waiting");
- if (cachedData = tabBar.data(cacheKey)) {
- onComplete(cachedData, tabBar)
- } else {
- jQuery.ajax({
- url: url,
- type: "get",
- success: function (d,t) {
- tabBar.data(cacheKey, d);
- onComplete(d, tabBar)
- }
- });
- }
- }
- return false;
- });
});
if (!Gitorious)
diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb
index 71ec709..358630b 100644
--- a/test/functional/users_controller_test.rb
+++ b/test/functional/users_controller_test.rb
@@ -535,30 +535,4 @@ class UsersControllerTest < ActionController::TestCase
end
end
- context "Events viewing" do
- setup {
- @userid = users(:johan).to_param
- }
- should "not require login" do
- get :activities, :id => @userid, :format => "js"
- assert_response :success
- end
-
- should "render the watched activities for the user only" do
- get :watched_activities, :id => @userid, :format => "js"
- assert_response 406
- end
-
- should "allow access to ones own watched activities" do
- login_as(@userid)
- get :watched_activities, :id => @userid, :format => "js"
- assert_response :success
- end
-
- should "render my activities for anyone" do
- get :activities, :id => @userid, :format => "js"
- assert_response :success
- end
- end
-
end