From 202d27454e2569f2226e65b64ce3ec499b9af669 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Wed, 25 Jul 2007 23:06:01 +0000 Subject: [PATCH] ActionItem8: moving things away: broke several things --- app/controllers/account_controller.rb | 15 +++++---------- app/controllers/application.rb | 11 ++++++++--- app/helpers/application_helper.rb | 13 +++++++++++++ app/views/edit_template/index.rhtml | 7 +++++++ app/views/layouts/account.rhtml | 18 ------------------ app/views/layouts/application.rhtml | 41 +++++++++++++---------------------------- app/views/layouts/virtual_community_admin.rhtml | 23 ----------------------- test/integration/login_to_the_application_test.rb | 19 +++++++++++++++++++ 8 files changed, 65 insertions(+), 82 deletions(-) delete mode 100644 app/views/layouts/account.rhtml delete mode 100644 app/views/layouts/virtual_community_admin.rhtml create mode 100644 test/integration/login_to_the_application_test.rb diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 4e9ed16..26de1ca 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -1,14 +1,7 @@ class AccountController < ApplicationController - - uses_flexible_template :owner => 'owner' - # Be sure to include AuthenticationSystem in Application Controller instead - include AuthenticatedSystem - # If you want "remember me" functionality, add this before_filter to Application Controller - before_filter :login_from_cookie - # say something nice, you goof! something sweet. def index unless logged_in? @@ -25,7 +18,9 @@ class AccountController < ApplicationController cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at } end redirect_back_or_default(:controller => '/account', :action => 'index') - flash[:notice] = "Logged in successfully" + flash[:notice] = _("Logged in successfully") + else + flash[:notice] = _('Incorrect username or password') end end @@ -35,7 +30,7 @@ class AccountController < ApplicationController @user.save! self.current_user = @user redirect_back_or_default(:controller => '/account', :action => 'index') - flash[:notice] = "Thanks for signing up!" + flash[:notice] = _("Thanks for signing up!") rescue ActiveRecord::RecordInvalid render :action => 'signup' end @@ -44,7 +39,7 @@ class AccountController < ApplicationController self.current_user.forget_me if logged_in? cookies.delete :auth_token reset_session - flash[:notice] = "You have been logged out." + flash[:notice] = _("You have been logged out.") redirect_back_or_default(:controller => '/account', :action => 'index') end diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 334707a..9481a1c 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -1,11 +1,13 @@ -# This is the application's main controller. Features defined here are +# his is the application's main controller. Features defined here are # available in all controllers. class ApplicationController < ActionController::Base + # Be sure to include AuthenticationSystem in Application Controller instead + include AuthenticatedSystem + before_filter :detect_stuff_by_domain attr_reader :virtual_community - before_filter :load_owner # Load the owner def load_owner @@ -15,7 +17,6 @@ class ApplicationController < ActionController::Base end end - protected # TODO: move this logic somewhere else (Domain class?) @@ -29,6 +30,10 @@ class ApplicationController < ActionController::Base end end + def flexible_template_onwer + @virtual_community_admin || @profile + end + def self.acts_as_virtual_community_admin_controller before_filter :load_admin_controller layout 'virtual_community_admin' diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5ad70b7..51f8d0f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -90,4 +90,17 @@ module ApplicationHelper content_tag('div', links, :id => 'user_links') end + def header + virtual_community_identification + (logged_in? ? user_links : login_box) + end + + def login_box + link_to _('Login'), :controller => 'account', :action => 'login' + end + + # FIXME + def footer + 'nothing in the footer yet' + end + end diff --git a/app/views/edit_template/index.rhtml b/app/views/edit_template/index.rhtml index e69de29..ddfa21b 100644 --- a/app/views/edit_template/index.rhtml +++ b/app/views/edit_template/index.rhtml @@ -0,0 +1,7 @@ +<%= link_to _('Show Layout'), :controller => 'home' %> +<%= link_to _('Edit Layout'), :controller => 'edit_template' %> + +<%= select_template %> +<%= select_theme %> +<%= select_icons_theme %> +<%= display_icon('back')%> diff --git a/app/views/layouts/account.rhtml b/app/views/layouts/account.rhtml deleted file mode 100644 index 4bc2fde..0000000 --- a/app/views/layouts/account.rhtml +++ /dev/null @@ -1,18 +0,0 @@ - - - <%= javascript_include_tag :defaults %> - <%= javascript_include_tag_template %> - <%= stylesheet_link_tag_template %> - - - - <%= virtual_community_identification %> - <%= user_links %> - -
- <%= yield %> -
- - - - diff --git a/app/views/layouts/application.rhtml b/app/views/layouts/application.rhtml index 5385d13..52e80dd 100644 --- a/app/views/layouts/application.rhtml +++ b/app/views/layouts/application.rhtml @@ -10,44 +10,29 @@ <%= image_tag 'loading.gif', :id => 'spinner', :style => "display:none; float:right;" %>
-
+
+ - <%= link_to _('Show Layout'), :controller => 'home' %> - <%= link_to _('Edit Layout'), :controller => 'edit_template' %> - - <%= select_template %> - <%= select_theme %> - <%= select_icons_theme %> - - <%= display_icon('back')%> - - <%= flash[:notice] %> +
+ <%= flash[:notice] %> +
+ <%= display_boxes(yield) %> -
diff --git a/app/views/layouts/virtual_community_admin.rhtml b/app/views/layouts/virtual_community_admin.rhtml deleted file mode 100644 index 1d93d0c..0000000 --- a/app/views/layouts/virtual_community_admin.rhtml +++ /dev/null @@ -1,23 +0,0 @@ - - - <%= javascript_include_tag :defaults %> - <%= javascript_include_tag_template %> - <%= stylesheet_link_tag_template %> - - - - - <%= virtual_community_identification %> - <%= user_links %> - -
- <%= yield %> -
- - - - - - diff --git a/test/integration/login_to_the_application_test.rb b/test/integration/login_to_the_application_test.rb new file mode 100644 index 0000000..c6e730c --- /dev/null +++ b/test/integration/login_to_the_application_test.rb @@ -0,0 +1,19 @@ +require "#{File.dirname(__FILE__)}/../test_helper" + +class LoginToTheApplicationTest < ActionController::IntegrationTest + fixtures :users, :virtual_communities, :profiles + + def test_anonymous_sees_login_box + get '/' + assert_tag :tag => 'div', :attributes => { :id => 'login_box' } + assert_no_tag :tag => 'div', :attributes => { :id => 'user_links' } + end + + def test_logged_in_does_not_see_login_box + login('ze', 'test') + get '/' + assert_no_tag :tag => 'div', :attributes => { :id => 'login_box' } + assert_tag :tag => 'div', :attributes => { :id => 'user_links' } + end + +end -- libgit2 0.21.2