Commit 202d27454e2569f2226e65b64ce3ec499b9af669
1 parent
9fa8bffb
Exists in
master
and in
22 other branches
ActionItem8: moving things away: broke several things
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@162 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
8 changed files
with
65 additions
and
82 deletions
Show diff stats
app/controllers/account_controller.rb
| 1 | 1 | class AccountController < ApplicationController |
| 2 | 2 | |
| 3 | - | |
| 4 | - | |
| 5 | 3 | uses_flexible_template :owner => 'owner' |
| 6 | 4 | |
| 7 | - # Be sure to include AuthenticationSystem in Application Controller instead | |
| 8 | - include AuthenticatedSystem | |
| 9 | - # If you want "remember me" functionality, add this before_filter to Application Controller | |
| 10 | - before_filter :login_from_cookie | |
| 11 | - | |
| 12 | 5 | # say something nice, you goof! something sweet. |
| 13 | 6 | def index |
| 14 | 7 | unless logged_in? |
| ... | ... | @@ -25,7 +18,9 @@ class AccountController < ApplicationController |
| 25 | 18 | cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at } |
| 26 | 19 | end |
| 27 | 20 | redirect_back_or_default(:controller => '/account', :action => 'index') |
| 28 | - flash[:notice] = "Logged in successfully" | |
| 21 | + flash[:notice] = _("Logged in successfully") | |
| 22 | + else | |
| 23 | + flash[:notice] = _('Incorrect username or password') | |
| 29 | 24 | end |
| 30 | 25 | end |
| 31 | 26 | |
| ... | ... | @@ -35,7 +30,7 @@ class AccountController < ApplicationController |
| 35 | 30 | @user.save! |
| 36 | 31 | self.current_user = @user |
| 37 | 32 | redirect_back_or_default(:controller => '/account', :action => 'index') |
| 38 | - flash[:notice] = "Thanks for signing up!" | |
| 33 | + flash[:notice] = _("Thanks for signing up!") | |
| 39 | 34 | rescue ActiveRecord::RecordInvalid |
| 40 | 35 | render :action => 'signup' |
| 41 | 36 | end |
| ... | ... | @@ -44,7 +39,7 @@ class AccountController < ApplicationController |
| 44 | 39 | self.current_user.forget_me if logged_in? |
| 45 | 40 | cookies.delete :auth_token |
| 46 | 41 | reset_session |
| 47 | - flash[:notice] = "You have been logged out." | |
| 42 | + flash[:notice] = _("You have been logged out.") | |
| 48 | 43 | redirect_back_or_default(:controller => '/account', :action => 'index') |
| 49 | 44 | end |
| 50 | 45 | ... | ... |
app/controllers/application.rb
| 1 | -# This is the application's main controller. Features defined here are | |
| 1 | +# his is the application's main controller. Features defined here are | |
| 2 | 2 | # available in all controllers. |
| 3 | 3 | class ApplicationController < ActionController::Base |
| 4 | 4 | |
| 5 | + # Be sure to include AuthenticationSystem in Application Controller instead | |
| 6 | + include AuthenticatedSystem | |
| 7 | + | |
| 5 | 8 | before_filter :detect_stuff_by_domain |
| 6 | 9 | attr_reader :virtual_community |
| 7 | 10 | |
| 8 | - | |
| 9 | 11 | before_filter :load_owner |
| 10 | 12 | # Load the owner |
| 11 | 13 | def load_owner |
| ... | ... | @@ -15,7 +17,6 @@ class ApplicationController < ActionController::Base |
| 15 | 17 | end |
| 16 | 18 | end |
| 17 | 19 | |
| 18 | - | |
| 19 | 20 | protected |
| 20 | 21 | |
| 21 | 22 | # TODO: move this logic somewhere else (Domain class?) |
| ... | ... | @@ -29,6 +30,10 @@ class ApplicationController < ActionController::Base |
| 29 | 30 | end |
| 30 | 31 | end |
| 31 | 32 | |
| 33 | + def flexible_template_onwer | |
| 34 | + @virtual_community_admin || @profile | |
| 35 | + end | |
| 36 | + | |
| 32 | 37 | def self.acts_as_virtual_community_admin_controller |
| 33 | 38 | before_filter :load_admin_controller |
| 34 | 39 | layout 'virtual_community_admin' | ... | ... |
app/helpers/application_helper.rb
| ... | ... | @@ -90,4 +90,17 @@ module ApplicationHelper |
| 90 | 90 | content_tag('div', links, :id => 'user_links') |
| 91 | 91 | end |
| 92 | 92 | |
| 93 | + def header | |
| 94 | + virtual_community_identification + (logged_in? ? user_links : login_box) | |
| 95 | + end | |
| 96 | + | |
| 97 | + def login_box | |
| 98 | + link_to _('Login'), :controller => 'account', :action => 'login' | |
| 99 | + end | |
| 100 | + | |
| 101 | + # FIXME | |
| 102 | + def footer | |
| 103 | + 'nothing in the footer yet' | |
| 104 | + end | |
| 105 | + | |
| 93 | 106 | end | ... | ... |
app/views/edit_template/index.rhtml
app/views/layouts/account.rhtml
| ... | ... | @@ -1,18 +0,0 @@ |
| 1 | -<html> | |
| 2 | - <head> | |
| 3 | - <%= javascript_include_tag :defaults %> | |
| 4 | - <%= javascript_include_tag_template %> | |
| 5 | - <%= stylesheet_link_tag_template %> | |
| 6 | - | |
| 7 | - </head> | |
| 8 | - <body> | |
| 9 | - <%= virtual_community_identification %> | |
| 10 | - <%= user_links %> | |
| 11 | - | |
| 12 | - <div id='main'> | |
| 13 | - <%= yield %> | |
| 14 | - </div> | |
| 15 | - | |
| 16 | - </body> | |
| 17 | - | |
| 18 | -</html> |
app/views/layouts/application.rhtml
| ... | ... | @@ -10,44 +10,29 @@ |
| 10 | 10 | <body> |
| 11 | 11 | <%= image_tag 'loading.gif', :id => 'spinner', :style => "display:none; float:right;" %> |
| 12 | 12 | <div id="wrap"> |
| 13 | - <div id="box"> | |
| 13 | + <div id="frame"> | |
| 14 | + | |
| 14 | 15 | <div id="menu"> |
| 15 | - Skip to: | |
| 16 | - <a href="#content">Content</a> | | |
| 17 | - <a href="#sidebar">Navigation</a> | | |
| 18 | - <a href="#footer">Footer</a> | |
| 16 | + <%= _('Skip to:') %> | |
| 17 | + <a href="#main_content"><%= _('Content') %></a> | | |
| 18 | + <a href="#sidebar"><%= _('Navigation') %></a> | | |
| 19 | + <a href="#footer"><%= _('Footer') %></a> | |
| 19 | 20 | </div> |
| 20 | 21 | |
| 21 | 22 | <div id="header"> |
| 22 | - <h1> | |
| 23 | - <a href="index.html">1024<span class="fade">px</span></a> | |
| 24 | - </h1> | |
| 25 | - <p id="slogan">when 800px just isn't enough...</p> | |
| 23 | + <%= header %> | |
| 26 | 24 | </div> |
| 27 | 25 | |
| 28 | - <%= link_to _('Show Layout'), :controller => 'home' %> | |
| 29 | - <%= link_to _('Edit Layout'), :controller => 'edit_template' %> | |
| 30 | - | |
| 31 | - <%= select_template %> | |
| 32 | - <%= select_theme %> | |
| 33 | - <%= select_icons_theme %> | |
| 34 | - | |
| 35 | - <%= display_icon('back')%> | |
| 36 | - | |
| 37 | - <%= flash[:notice] %> | |
| 26 | + <div id='notice'> | |
| 27 | + <%= flash[:notice] %> | |
| 28 | + </div> | |
| 38 | 29 | |
| 30 | + <a name='main_content'/> | |
| 39 | 31 | <%= display_boxes(yield) %> |
| 40 | - <div class="clearfix"></div> | |
| 41 | 32 | |
| 42 | 33 | <div id="footer"> |
| 43 | - <p> | |
| 44 | - <a href="#">Contact us</a> | | |
| 45 | - <a href="#">Privacy policy</a> | | |
| 46 | - <a href="#">Sitemap</a> | | |
| 47 | - <a href="#">RSS</a> | | |
| 48 | - <a href="#header">Back to top</a><br /> | |
| 49 | - © 2007 <a href="#">Your Name</a> | Design by <a href="http://andreasviklund.com/">Andreas Viklund</a> | |
| 50 | - </p> | |
| 34 | + <a name='footer'/> | |
| 35 | + <%= footer %> | |
| 51 | 36 | </div> |
| 52 | 37 | </div> |
| 53 | 38 | </div> | ... | ... |
app/views/layouts/virtual_community_admin.rhtml
| ... | ... | @@ -1,23 +0,0 @@ |
| 1 | -<html> | |
| 2 | - <head> | |
| 3 | - <%= javascript_include_tag :defaults %> | |
| 4 | - <%= javascript_include_tag_template %> | |
| 5 | - <%= stylesheet_link_tag_template %> | |
| 6 | - | |
| 7 | - </head> | |
| 8 | - <body> | |
| 9 | - | |
| 10 | - <%= virtual_community_identification %> | |
| 11 | - <%= user_links %> | |
| 12 | - | |
| 13 | - <div id='main'> | |
| 14 | - <%= yield %> | |
| 15 | - </div> | |
| 16 | - | |
| 17 | - <div id="footer"> | |
| 18 | - footer content | |
| 19 | - </div> | |
| 20 | - | |
| 21 | - </body> | |
| 22 | - | |
| 23 | -</html> |
| ... | ... | @@ -0,0 +1,19 @@ |
| 1 | +require "#{File.dirname(__FILE__)}/../test_helper" | |
| 2 | + | |
| 3 | +class LoginToTheApplicationTest < ActionController::IntegrationTest | |
| 4 | + fixtures :users, :virtual_communities, :profiles | |
| 5 | + | |
| 6 | + def test_anonymous_sees_login_box | |
| 7 | + get '/' | |
| 8 | + assert_tag :tag => 'div', :attributes => { :id => 'login_box' } | |
| 9 | + assert_no_tag :tag => 'div', :attributes => { :id => 'user_links' } | |
| 10 | + end | |
| 11 | + | |
| 12 | + def test_logged_in_does_not_see_login_box | |
| 13 | + login('ze', 'test') | |
| 14 | + get '/' | |
| 15 | + assert_no_tag :tag => 'div', :attributes => { :id => 'login_box' } | |
| 16 | + assert_tag :tag => 'div', :attributes => { :id => 'user_links' } | |
| 17 | + end | |
| 18 | + | |
| 19 | +end | ... | ... |