Changeset 1720
- Timestamp:
- 07/30/08 17:24:43 (4 months ago)
- Files:
-
- community_hive/trunk/community_hive_web/TODO.txt (added)
- community_hive/trunk/community_hive_web/app/controllers/account_controller.rb (modified) (2 diffs)
- community_hive/trunk/community_hive_web/app/controllers/urls_controller.rb (modified) (2 diffs)
- community_hive/trunk/community_hive_web/app/controllers/users_controller.rb (modified) (5 diffs)
- community_hive/trunk/community_hive_web/app/helpers/application_helper.rb (modified) (2 diffs)
- community_hive/trunk/community_hive_web/app/views/account/login.html.erb (modified) (1 diff)
- community_hive/trunk/community_hive_web/app/views/layouts/application.html.erb (modified) (1 diff)
- community_hive/trunk/community_hive_web/app/views/main/index.html.erb (modified) (1 diff)
- community_hive/trunk/community_hive_web/app/views/myaccount/index.html.erb (modified) (1 diff)
- community_hive/trunk/community_hive_web/app/views/urls/search.html.erb (modified) (1 diff)
- community_hive/trunk/community_hive_web/app/views/urls/show.html.erb (added)
- community_hive/trunk/community_hive_web/app/views/users/edit.html.erb (modified) (2 diffs)
- community_hive/trunk/community_hive_web/app/views/users/edit_my_profile.html.erb (added)
- community_hive/trunk/community_hive_web/app/views/users/myprofile.html.erb (added)
- community_hive/trunk/community_hive_web/public/stylesheets/style.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
community_hive/trunk/community_hive_web/app/controllers/account_controller.rb
r1717 r1720 7 7 if logged_in? 8 8 redirect_back_or_default(:controller => '/main', :action => 'index') 9 flash[: notice] = "Logged in successfully"9 flash[:message] = "Logged in successfully" 10 10 else 11 flash[: notice] = "Bad Username or Password. Please try again."11 flash[:error] = "Bad Username or Password. Please try again." 12 12 end 13 13 end … … 16 16 def logout 17 17 reset_session 18 flash[: notice] = "You have been logged out."18 flash[:message] = "You have been logged out." 19 19 redirect_back_or_default(:controller => '/account', :action => 'login') 20 20 end community_hive/trunk/community_hive_web/app/controllers/urls_controller.rb
r1719 r1720 1 1 class UrlsController < ApplicationController 2 2 before_filter :login_required, :only => [:show] 3 3 def index 4 4 end … … 15 15 16 16 def show 17 @u = HistoryUrl.find(params[:id]) 18 @count = HistoryUrl.count(:conditions => ["url = ?",@u.url]) 17 19 end 18 20 end community_hive/trunk/community_hive_web/app/controllers/users_controller.rb
r1719 r1720 1 1 class UsersController < ApplicationController 2 2 before_filter :login_required 3 before_filter :check_for_admin 3 before_filter :check_for_admin, :except => [:myprofile,:edit_my_profile] 4 4 5 verify :method => :post, :only => [ :destroy, :create, :update ], 6 :redirect_to => { :action => :index } 7 5 8 6 def index 9 7 @users = User.paginate(:order => 'login DESC',:page => params[:page], :per_page => 10) 10 8 end 11 9 10 # Show the users profile so they may edit it 11 def myprofile 12 @user = current_user 13 end 14 12 15 def show 13 16 @user = User.find(params[:id]) … … 21 24 @user = User.new(params[:user]) 22 25 if @user.save 23 flash[: notice] = 'User was successfully created.'26 flash[:message] = 'User was successfully created.' 24 27 redirect_to :action => 'index' 25 28 else … … 30 33 def edit 31 34 @user = User.find(params[:id]) 35 end 36 37 def edit_my_profile 38 @user = current_user 32 39 end 33 40 … … 43 50 # destroy all heartbeats for old key 44 51 logger.info("Changing BEE KEY") 45 flash[: notice] = 'Bee access key was successfully changed.'52 flash[:message] = 'Bee access key was successfully changed.' 46 53 redirect_to :action => 'show', :id => @user 47 54 end … … 50 57 @user = User.find(params[:id]) 51 58 if @user.update_attributes(params[:user]) 52 flash[: notice] = 'User was successfully updated.'59 flash[:message] = 'User was successfully updated.' 53 60 redirect_to :action => 'show', :id => @user 54 61 else community_hive/trunk/community_hive_web/app/helpers/application_helper.rb
r1719 r1720 2 2 module ApplicationHelper 3 3 4 def nav_bar (user)4 def nav_bar 5 5 b = "" 6 6 b << "<li>#{link_to("Check a URL", :controller => 'main', :action => 'index')}</li>" … … 8 8 b << "<li>#{link_to("Stats", :controller => 'statistics', :action => 'index')}</li>" 9 9 b << "<li>#{link_to("About", :controller => 'about', :action => 'index')}</li>" 10 if user11 b << "<li>#{link_to("My Account", :controller => ' myaccount', :action => 'index')}</li>"10 if logged_in? 11 b << "<li>#{link_to("My Account", :controller => 'users', :action => 'myprofile')}</li>" 12 12 b << "<li>#{link_to("Logout", :controller => 'account', :action => 'logout')}</li>" 13 if user.admin14 b << "<li>#{link_to("Admin", :controller => ' accounts', :action => 'index')}</li>"13 if current_user.admin 14 b << "<li>#{link_to("Admin", :controller => 'users', :action => 'index')}</li>" 15 15 end 16 16 else community_hive/trunk/community_hive_web/app/views/account/login.html.erb
r1620 r1720 1 1 <h2>Please login</h2> 2 <%= show_message %> 2 3 <% form_tag do -%> 3 4 <p><label for="login">Username</label> community_hive/trunk/community_hive_web/app/views/layouts/application.html.erb
r1717 r1720 15 15 <div id="navbar"> 16 16 <ul id="nav"> 17 <%= nav_bar (@current_user)%>17 <%= nav_bar %> 18 18 </ul> 19 19 </div> community_hive/trunk/community_hive_web/app/views/main/index.html.erb
r1717 r1720 3 3 Send us a Url of a site you would like to check for malicious software. 4 4 </p> 5 <%= show_message %> 5 6 <% form_tag '/main/create' do -%> 6 <%= show_message %>7 7 Url: <%= text_field_tag 'url', '', :size => '50' %> 8 8 <p style="font-size: small; color: #444; padding-left: 35px; padding-top: 5px; margin: 0;"> community_hive/trunk/community_hive_web/app/views/myaccount/index.html.erb
r1620 r1720 40 40 </tr> 41 41 </table> 42 43 <community_hive/trunk/community_hive_web/app/views/urls/search.html.erb
r1719 r1720 18 18 <table class="search"> 19 19 <tbody> 20 <tr> 21 <td>rating</td> 22 <td>top level domain</td> 23 </tr> 20 24 <%= render :partial => 'results', :collection => @list %> 21 25 </tbody> community_hive/trunk/community_hive_web/app/views/users/edit.html.erb
r1620 r1720 13 13 <tr> 14 14 <td>Admin permission?:</td> 15 <td><%= select :user, :admin, [[' True',1],['False',0] ] %></td>15 <td><%= select :user, :admin, [['False',0],['True',1] ] %></td> 16 16 </tr> 17 17 <tr> … … 31 31 <br/> 32 32 <%= submit_tag 'Edit Account' %> | 33 <%= link_to 'Cancel', :action => ' index' %>33 <%= link_to 'Cancel', :action => 'myprofile' %> 34 34 </td> 35 35 </tr> community_hive/trunk/community_hive_web/public/stylesheets/style.css
r1719 r1720 12 12 border-left: 2px solid #ccc; 13 13 border-right: 2px solid #ccc; 14 border-bottom: 2px solid #ccc; 14 15 } 15 16
