Permalink
Browse files

Fixed a few issues and added roles to users. Next will be limiting us…

…ers access based on roles.
  • Loading branch information...
0 parents commit dbfddf08f270b5eef2be894a357f8b4d717e5d81 @glenv glenv committed Jun 26, 2010
Showing with 22,330 additions and 0 deletions.
  1. +6 −0 .gitignore
  2. +10 −0 README
  3. +10 −0 Rakefile
  4. +21 −0 app/controllers/application_controller.rb
  5. +44 −0 app/controllers/roles_controller.rb
  6. +87 −0 app/controllers/suppliers_controller.rb
  7. +24 −0 app/controllers/user_sessions_controller.rb
  8. +58 −0 app/controllers/users_controller.rb
  9. +3 −0 app/helpers/application_helper.rb
  10. +2 −0 app/helpers/roles_helper.rb
  11. +2 −0 app/helpers/suppliers_helper.rb
  12. +2 −0 app/helpers/user_sessions_helper.rb
  13. +2 −0 app/helpers/users_helper.rb
  14. +4 −0 app/models/assignment.rb
  15. +4 −0 app/models/role.rb
  16. +13 −0 app/models/supplier.rb
  17. +18 −0 app/models/user.rb
  18. +2 −0 app/models/user_session.rb
  19. +49 −0 app/views/layouts/application.html.erb
  20. +15 −0 app/views/roles/edit.html.erb
  21. +22 −0 app/views/roles/index.html.erb
  22. +2 −0 app/views/roles/new.html.erb
  23. +2 −0 app/views/roles/show.html.erb
  24. +66 −0 app/views/suppliers/edit.html.erb
  25. +36 −0 app/views/suppliers/index.html.erb
  26. +131 −0 app/views/suppliers/new.html.erb
  27. +83 −0 app/views/suppliers/show.html.erb
  28. +20 −0 app/views/user_sessions/edit.html.erb
  29. 0 app/views/user_sessions/index.html.erb
  30. +17 −0 app/views/user_sessions/new.html.erb
  31. +13 −0 app/views/user_sessions/show.html.erb
  32. +37 −0 app/views/users/edit.html.erb
  33. +27 −0 app/views/users/index.html.erb
  34. +34 −0 app/views/users/new.html.erb
  35. +21 −0 app/views/users/show.html.erb
  36. +32 −0 config/authorization_rules.rb
  37. +110 −0 config/boot.rb
  38. +41 −0 config/environment.rb
  39. +17 −0 config/environments/development.rb
  40. +28 −0 config/environments/production.rb
  41. +28 −0 config/environments/test.rb
  42. +7 −0 config/initializers/backtrace_silencers.rb
  43. +10 −0 config/initializers/inflections.rb
  44. +5 −0 config/initializers/mime_types.rb
  45. +21 −0 config/initializers/new_rails_defaults.rb
  46. +15 −0 config/initializers/session_store.rb
  47. +89 −0 config/locales/en.yml
  48. +55 −0 config/routes.rb
  49. +34 −0 database.yml
  50. +30 −0 db/migrate/001_create_suppliers.rb
  51. +41 −0 db/migrate/002_create_users.rb
  52. +12 −0 db/migrate/20100621043120_create_user_sessions.rb
  53. +22 −0 db/migrate/20100623055058_create_roles.rb
  54. +16 −0 db/migrate/20100623061304_create_assignments.rb
  55. +79 −0 db/schema.rb
  56. +7 −0 db/seeds.rb
  57. +10 −0 dispatch.cgi.example
  58. +24 −0 dispatch.fcgi.example
  59. +10 −0 dispatch.rb.example
  60. +2 −0 doc/README_FOR_APP
  61. +55 −0 lib/authentication.rb
  62. 0 log/server.log
  63. +68 −0 mongrel.log
  64. +30 −0 public/404.html
  65. +30 −0 public/422.html
  66. +30 −0 public/500.html
  67. 0 public/favicon.ico
  68. BIN public/images/add.png
  69. BIN public/images/delete.png
  70. BIN public/images/edit.png
  71. BIN public/images/rails.png
  72. BIN public/images/view.png
  73. +2 −0 public/javascripts/application.js
  74. +963 −0 public/javascripts/controls.js
  75. +973 −0 public/javascripts/dragdrop.js
  76. +1,128 −0 public/javascripts/effects.js
  77. +4,320 −0 public/javascripts/prototype.js
  78. +5 −0 public/robots.txt
  79. +152 −0 public/stylesheets/application.css
  80. +54 −0 public/stylesheets/scaffold.css
  81. +4 −0 script/about
  82. +3 −0 script/console
  83. +3 −0 script/dbconsole
  84. +3 −0 script/destroy
  85. +3 −0 script/generate
  86. +3 −0 script/performance/benchmarker
  87. +3 −0 script/performance/profiler
  88. +3 −0 script/plugin
  89. +3 −0 script/runner
  90. +3 −0 script/server
  91. +9 −0 vendor/plugins/authlogic/.gitignore
  92. +345 −0 vendor/plugins/authlogic/CHANGELOG.rdoc
  93. +20 −0 vendor/plugins/authlogic/LICENSE
  94. +246 −0 vendor/plugins/authlogic/README.rdoc
  95. +41 −0 vendor/plugins/authlogic/Rakefile
  96. +5 −0 vendor/plugins/authlogic/VERSION.yml
  97. +216 −0 vendor/plugins/authlogic/authlogic.gemspec
  98. +9 −0 vendor/plugins/authlogic/generators/session/session_generator.rb
  99. +2 −0 vendor/plugins/authlogic/generators/session/templates/session.rb
  100. +1 −0 vendor/plugins/authlogic/init.rb
  101. +64 −0 vendor/plugins/authlogic/lib/authlogic.rb
  102. +107 −0 vendor/plugins/authlogic/lib/authlogic/acts_as_authentic/base.rb
  103. +110 −0 vendor/plugins/authlogic/lib/authlogic/acts_as_authentic/email.rb
  104. +60 −0 vendor/plugins/authlogic/lib/authlogic/acts_as_authentic/logged_in_status.rb
  105. +141 −0 vendor/plugins/authlogic/lib/authlogic/acts_as_authentic/login.rb
  106. +24 −0 vendor/plugins/authlogic/lib/authlogic/acts_as_authentic/magic_columns.rb
  107. +355 −0 vendor/plugins/authlogic/lib/authlogic/acts_as_authentic/password.rb
  108. +105 −0 vendor/plugins/authlogic/lib/authlogic/acts_as_authentic/perishable_token.rb
  109. +68 −0 vendor/plugins/authlogic/lib/authlogic/acts_as_authentic/persistence_token.rb
  110. +61 −0 vendor/plugins/authlogic/lib/authlogic/acts_as_authentic/restful_authentication.rb
  111. +139 −0 vendor/plugins/authlogic/lib/authlogic/acts_as_authentic/session_maintenance.rb
  112. +65 −0 vendor/plugins/authlogic/lib/authlogic/acts_as_authentic/single_access_token.rb
  113. +32 −0 vendor/plugins/authlogic/lib/authlogic/acts_as_authentic/validations_scope.rb
  114. +42 −0 vendor/plugins/authlogic/lib/authlogic/authenticates_many/association.rb
  115. +55 −0 vendor/plugins/authlogic/lib/authlogic/authenticates_many/base.rb
  116. +67 −0 vendor/plugins/authlogic/lib/authlogic/controller_adapters/abstract_adapter.rb
  117. +30 −0 vendor/plugins/authlogic/lib/authlogic/controller_adapters/merb_adapter.rb
  118. +48 −0 vendor/plugins/authlogic/lib/authlogic/controller_adapters/rails_adapter.rb
  119. +61 −0 vendor/plugins/authlogic/lib/authlogic/controller_adapters/sinatra_adapter.rb
  120. +43 −0 vendor/plugins/authlogic/lib/authlogic/crypto_providers/aes256.rb
  121. +90 −0 vendor/plugins/authlogic/lib/authlogic/crypto_providers/bcrypt.rb
  122. +34 −0 vendor/plugins/authlogic/lib/authlogic/crypto_providers/md5.rb
  123. +35 −0 vendor/plugins/authlogic/lib/authlogic/crypto_providers/sha1.rb
  124. +50 −0 vendor/plugins/authlogic/lib/authlogic/crypto_providers/sha256.rb
  125. +50 −0 vendor/plugins/authlogic/lib/authlogic/crypto_providers/sha512.rb
  126. +43 −0 vendor/plugins/authlogic/lib/authlogic/crypto_providers/wordpress.rb
  127. +83 −0 vendor/plugins/authlogic/lib/authlogic/i18n.rb
  128. +15 −0 vendor/plugins/authlogic/lib/authlogic/i18n/translator.rb
  129. +33 −0 vendor/plugins/authlogic/lib/authlogic/random.rb
  130. +25 −0 vendor/plugins/authlogic/lib/authlogic/regex.rb
  131. +58 −0 vendor/plugins/authlogic/lib/authlogic/session/activation.rb
  132. +64 −0 vendor/plugins/authlogic/lib/authlogic/session/active_record_trickery.rb
  133. +37 −0 vendor/plugins/authlogic/lib/authlogic/session/base.rb
  134. +96 −0 vendor/plugins/authlogic/lib/authlogic/session/brute_force_protection.rb
  135. +99 −0 vendor/plugins/authlogic/lib/authlogic/session/callbacks.rb
  136. +130 −0 vendor/plugins/authlogic/lib/authlogic/session/cookies.rb
  137. +93 −0 vendor/plugins/authlogic/lib/authlogic/session/existence.rb
  138. +63 −0 vendor/plugins/authlogic/lib/authlogic/session/foundation.rb
  139. +58 −0 vendor/plugins/authlogic/lib/authlogic/session/http_auth.rb
  140. +41 −0 vendor/plugins/authlogic/lib/authlogic/session/id.rb
  141. +78 −0 vendor/plugins/authlogic/lib/authlogic/session/klass.rb
  142. +95 −0 vendor/plugins/authlogic/lib/authlogic/session/magic_columns.rb
  143. +59 −0 vendor/plugins/authlogic/lib/authlogic/session/magic_states.rb
  144. +101 −0 vendor/plugins/authlogic/lib/authlogic/session/params.rb
  145. +240 −0 vendor/plugins/authlogic/lib/authlogic/session/password.rb
  146. +18 −0 vendor/plugins/authlogic/lib/authlogic/session/perishable_token.rb
  147. +70 −0 vendor/plugins/authlogic/lib/authlogic/session/persistence.rb
  148. +34 −0 vendor/plugins/authlogic/lib/authlogic/session/priority_record.rb
  149. +101 −0 vendor/plugins/authlogic/lib/authlogic/session/scopes.rb
  150. +62 −0 vendor/plugins/authlogic/lib/authlogic/session/session.rb
  151. +82 −0 vendor/plugins/authlogic/lib/authlogic/session/timeout.rb
  152. +50 −0 vendor/plugins/authlogic/lib/authlogic/session/unauthorized_record.rb
  153. +82 −0 vendor/plugins/authlogic/lib/authlogic/session/validation.rb
  154. +120 −0 vendor/plugins/authlogic/lib/authlogic/test_case.rb
  155. +45 −0 vendor/plugins/authlogic/lib/authlogic/test_case/mock_controller.rb
  156. +14 −0 vendor/plugins/authlogic/lib/authlogic/test_case/mock_cookie_jar.rb
  157. +10 −0 vendor/plugins/authlogic/lib/authlogic/test_case/mock_logger.rb
  158. +19 −0 vendor/plugins/authlogic/lib/authlogic/test_case/mock_request.rb
  159. +30 −0 vendor/plugins/authlogic/lib/authlogic/test_case/rails_request_adapter.rb
  160. +1 −0 vendor/plugins/authlogic/rails/init.rb
  161. +69 −0 vendor/plugins/authlogic/shoulda_macros/authlogic.rb
  162. +139 −0 vendor/plugins/declarative_authorization/CHANGELOG
  163. +20 −0 vendor/plugins/declarative_authorization/MIT-LICENSE
  164. +504 −0 vendor/plugins/declarative_authorization/README.rdoc
  165. +35 −0 vendor/plugins/declarative_authorization/Rakefile
  166. +259 −0 vendor/plugins/declarative_authorization/app/controllers/authorization_rules_controller.rb
  167. +23 −0 vendor/plugins/declarative_authorization/app/controllers/authorization_usages_controller.rb
  168. +218 −0 vendor/plugins/declarative_authorization/app/helpers/authorization_rules_helper.rb
  169. +58 −0 vendor/plugins/declarative_authorization/app/views/authorization_rules/_change.erb
  170. +37 −0 vendor/plugins/declarative_authorization/app/views/authorization_rules/_show_graph.erb
  171. +48 −0 vendor/plugins/declarative_authorization/app/views/authorization_rules/_suggestions.erb
  172. +169 −0 vendor/plugins/declarative_authorization/app/views/authorization_rules/change.html.erb
  173. +68 −0 vendor/plugins/declarative_authorization/app/views/authorization_rules/graph.dot.erb
  174. +40 −0 vendor/plugins/declarative_authorization/app/views/authorization_rules/graph.html.erb
  175. +17 −0 vendor/plugins/declarative_authorization/app/views/authorization_rules/index.html.erb
  176. +36 −0 vendor/plugins/declarative_authorization/app/views/authorization_usages/index.html.erb
  177. +20 −0 vendor/plugins/declarative_authorization/authorization_rules.dist.rb
  178. +10 −0 vendor/plugins/declarative_authorization/config/routes.rb
  179. +17 −0 vendor/plugins/declarative_authorization/declarative_authorization.gemspec
  180. +20 −0 vendor/plugins/declarative_authorization/garlic_example.rb
  181. +5 −0 vendor/plugins/declarative_authorization/init.rb
  182. +17 −0 vendor/plugins/declarative_authorization/lib/declarative_authorization.rb
  183. +678 −0 vendor/plugins/declarative_authorization/lib/declarative_authorization/authorization.rb
  184. +252 −0 ...r/plugins/declarative_authorization/lib/declarative_authorization/development_support/analyzer.rb
  185. +253 −0 ...ns/declarative_authorization/lib/declarative_authorization/development_support/change_analyzer.rb
  186. +620 −0 ...s/declarative_authorization/lib/declarative_authorization/development_support/change_supporter.rb
  187. +243 −0 ...eclarative_authorization/lib/declarative_authorization/development_support/development_support.rb
  188. +60 −0 vendor/plugins/declarative_authorization/lib/declarative_authorization/helper.rb
  189. +623 −0 vendor/plugins/declarative_authorization/lib/declarative_authorization/in_controller.rb
  190. +162 −0 vendor/plugins/declarative_authorization/lib/declarative_authorization/in_model.rb
  191. +198 −0 vendor/plugins/declarative_authorization/lib/declarative_authorization/maintenance.rb
  192. +349 −0 vendor/plugins/declarative_authorization/lib/declarative_authorization/obligation_scope.rb
  193. +22 −0 vendor/plugins/declarative_authorization/lib/declarative_authorization/rails_legacy.rb
  194. +6 −0 vendor/plugins/declarative_authorization/lib/declarative_authorization/railsengine.rb
  195. +496 −0 vendor/plugins/declarative_authorization/lib/declarative_authorization/reader.rb
  196. +82 −0 vendor/plugins/declarative_authorization/tasks/authorization_tasks.rake
  197. +43 −0 vendor/plugins/will_paginate/.manifest
  198. +139 −0 vendor/plugins/will_paginate/CHANGELOG.rdoc
  199. +18 −0 vendor/plugins/will_paginate/LICENSE
  200. +107 −0 vendor/plugins/will_paginate/README.rdoc
  201. +53 −0 vendor/plugins/will_paginate/Rakefile
  202. BIN vendor/plugins/will_paginate/examples/apple-circle.gif
  203. +69 −0 vendor/plugins/will_paginate/examples/index.haml
  204. +92 −0 vendor/plugins/will_paginate/examples/index.html
  205. +90 −0 vendor/plugins/will_paginate/examples/pagination.css
  206. +91 −0 vendor/plugins/will_paginate/examples/pagination.sass
  207. +1 −0 vendor/plugins/will_paginate/init.rb
  208. +90 −0 vendor/plugins/will_paginate/lib/will_paginate.rb
  209. +16 −0 vendor/plugins/will_paginate/lib/will_paginate/array.rb
  210. +144 −0 vendor/plugins/will_paginate/lib/will_paginate/collection.rb
  211. +43 −0 vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb
  212. +264 −0 vendor/plugins/will_paginate/lib/will_paginate/finder.rb
  213. +170 −0 vendor/plugins/will_paginate/lib/will_paginate/named_scope.rb
  214. +37 −0 vendor/plugins/will_paginate/lib/will_paginate/named_scope_patch.rb
  215. +9 −0 vendor/plugins/will_paginate/lib/will_paginate/version.rb
  216. +408 −0 vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb
  217. +21 −0 vendor/plugins/will_paginate/will_paginate.gemspec
@@ -0,0 +1,6 @@
+config/database.yml
+log/development.log
+log/test.log
+log/production.log
+.idea
+test
10 README
@@ -0,0 +1,10 @@
+== Welcome to MyIT CRM Ruby On Rails Addition ==
+
+This is a relatively new project which I have been coding for over 16 months
+in php and mysql but there was a bunch of code to be written. Then I looked into Ruby and
+I was very satisfied after the first use of it. Thinking how this will speed up process cycles.
+
+
+
+Anyways more to come but in the meantime check out http://team.myitcrm.com for more details
+and the current version of MyIT CRM.
@@ -0,0 +1,10 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require(File.join(File.dirname(__FILE__), 'config', 'boot'))
+
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+require 'tasks/rails'
@@ -0,0 +1,21 @@
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+class ApplicationController < ActionController::Base
+ include Authentication
+ helper :all # include all helpers, all the time
+ protect_from_forgery # See ActionController::RequestForgeryProtection for details
+ before_filter { |c| Authorization.current_user = c.current_user }
+
+ # Scrub sensitive parameters from your log
+ filter_parameter_logging :password
+
+
+ protected
+
+def permission_denied
+ flash[:error] = t "global.restricted"
+ redirect_to root_url
+ end
+
+end
@@ -0,0 +1,44 @@
+class RolesController < ApplicationController
+ # filter_resource_access
+ def new
+ @title = t "role.t_new"
+
+ respond_to do |format|
+ format.html # new.html.erb
+ end
+ end
+
+ def edit
+ @title = t "role.t_new"
+ @role = Role.find(params[:id])
+ end
+
+ def update
+ @role = Role.find(params[:id])
+ if @role.update_attributes(params[:role])
+ flash[:notice] = 'Role was successfully updated.'
+ redirect_to roles_path
+ else
+ render :action => "edit"
+ render :xml => @role.errors, :status => :unprocessable_entity
+ end
+ end
+
+ def show
+ @title = t "role.t_view"
+
+ respond_to do |format|
+ format.html # show.html.erb
+ end
+ end
+
+ def index
+ @title = t "role.t_title"
+ @roles = Role.find(:all)
+
+ respond_to do |format|
+ format.html # index.html.erb
+ end
+ end
+
+end
@@ -0,0 +1,87 @@
+class SuppliersController < ApplicationController
+ filter_resource_access
+
+ def index
+ @title = t "supplier.t_title"
+ @suppliers = Supplier.find(:all)
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @supplier }
+ end
+ end
+
+ # GET /suppliers/1
+ # GET /suppliers/1.xml
+ def show
+ @title = t "supplier.t_view"
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @supplier }
+ end
+ end
+
+ # GET /suppliers/new
+ # GET /suppliers/new.xml
+ def new
+ @title = t "supplier.t_new"
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @supplier }
+ end
+ end
+
+ # GET /suppliers/1/edit
+ def edit
+ end
+
+ # POST /suppliers
+ # POST /suppliers.xml
+ def create
+ @title = t "supplier.t_new"
+
+ respond_to do |format|
+ if @supplier.save
+ @title = t "supplier.t_new"
+ flash[:notice] = 'Supplier was successfully created.'
+ format.html { redirect_to(@supplier) }
+ format.xml { render :xml => @supplier, :status => :created, :location => @supplier }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @supplier.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /suppliers/1
+ # PUT /suppliers/1.xml
+ def update
+ @title = t "supplier.t_new"
+
+ respond_to do |format|
+ if @supplier.update_attributes(params[:supplier])
+ flash[:notice] = 'Supplier was successfully updated.'
+ format.html { redirect_to(@supplier) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @supplier.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /suppliers/1
+ # DELETE /suppliers/1.xml
+ def destroy
+ @title = t "supplier.t_new"
+ @supplier.destroy
+
+ respond_to do |format|
+ flash[:notice] = 'Supplier was successfully deleted.'
+ format.html { redirect_to(suppliers_url) }
+ format.xml { head :ok }
+ end
+ end
+end
@@ -0,0 +1,24 @@
+class UserSessionsController < ApplicationController
+ def new
+ @user_session = UserSession.new
+
+ end
+
+ def create
+ @title = t "global.login"
+ @user_session = UserSession.new(params[:user_session])
+ if @user_session.save
+ flash[:notice] = t "user.login_success"
+ redirect_to root_url
+ else
+ render :action => "new"
+ end
+ end
+ def destroy
+ @title = t "global.logout"
+ @user_session = UserSession.find(params[:id])
+ @user_session.destroy
+ flash[:notice] = t "user.logout_success"
+ redirect_to root_url
+ end
+ end
@@ -0,0 +1,58 @@
+class UsersController < ApplicationController
+
+ def new
+ @title = t "user.t_new_user"
+ @user = User.new
+ end
+
+ def index
+ @title = t "user.t_title"
+ @user = User.all
+ end
+
+ def show
+ @title = t "user.t_view"
+ @user = User.find(params[:id])
+ end
+
+ def edit
+ @title = t "user.t_edit_user"
+ @user = User.find(params[:id])
+
+ end
+
+ def create
+ @title = t "user.t_new_user"
+ @user = User.new(params[:user])
+ if @user.save
+ flash[:notice] = t "user.flash_new_success"
+ redirect_to root_url
+ else
+ render :action => "new"
+ end
+ end
+
+ def update
+ @title = t "user.t_update_user"
+ @user = User.find(params[:id])
+ if @user.update_attributes(params[:user])
+ flash[:notice] = t "user.flash_update_user"
+ redirect_to users_path
+
+ else
+ render :action => "edit"
+ end
+ end
+
+ def destroy
+ @title = t "user.t_delete_user"
+ @user = User.find(params[:id])
+ @user.destroy
+
+ respond_to do |format|
+ flash[:notice] = t "user.flash_delete_user"
+ format.html { redirect_to(users_url) }
+
+ end
+ end
+end
@@ -0,0 +1,3 @@
+# Methods added to this helper will be available to all templates in the application.
+module ApplicationHelper
+end
@@ -0,0 +1,2 @@
+module RolesHelper
+end
@@ -0,0 +1,2 @@
+module SuppliersHelper
+end
@@ -0,0 +1,2 @@
+module UserSessionsHelper
+end
@@ -0,0 +1,2 @@
+module UsersHelper
+end
@@ -0,0 +1,4 @@
+class Assignment < ActiveRecord::Base
+ belongs_to :user
+ belongs_to :role
+end
@@ -0,0 +1,4 @@
+class Role < ActiveRecord::Base
+ has_many :assignments
+ has_many :users, :through => :assignments
+end
@@ -0,0 +1,13 @@
+class Supplier < ActiveRecord::Base
+ def before_create
+self.date_created ||= Time.now
+self.active ||= "1"
+end
+def before_update
+self.date_updated = Time.now
+end
+ def before_edit
+ self.date_updated = Time.now
+ end
+
+end
@@ -0,0 +1,18 @@
+class User < ActiveRecord::Base
+ acts_as_authentic
+ # Used to set New Users to default to active
+ def before_create
+ self.active ||= "1"
+ end
+
+ has_many :suppliers
+ has_many :assignments
+ has_many :roles, :through => :assignments
+
+
+ def role_symbols
+ roles.map do |role|
+ role.name.underscore.to_sym
+ end
+ end
+end
@@ -0,0 +1,2 @@
+class UserSession < Authlogic::Session::Base
+end
@@ -0,0 +1,49 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title> <%= t "global.program_name" %> | <%= @title %></title>
+ <%= stylesheet_link_tag 'application' %>
+</head>
+<body>
+
+<div id="container" >
+ <%= image_tag 'rails.png', :height => 100%>
+ <%- flash.each do |name, msg| -%>
+ <%= content_tag :div, msg, :id => "flash_#{name}" %>
+ <%- end -%>
+
+ <div id="user_nav">
+ <% if current_user %>
+ <%= link_to "Home", root_url %> |
+ <% if permitted_to? :create, @user %>
+ <%= link_to "New User", new_user_path %> |
+ <% end %>
+ <% if permitted_to? :index, @user %>
+ <%= link_to "List Users", users_path %> |
+ <% end %>
+ <% if permitted_to? :show, @supplier %>
+ <%= link_to "Suppliers", suppliers_path %> |
+ <% end %>
+ <%= link_to "Edit Profile", edit_user_path(:id => current_user.id) %> |
+ <%= link_to (t "global.logout"), logout_path %>
+ <% else %>
+ <%= link_to "Home", root_url %> |
+ <%= link_to "Register", signup_path %> |
+ <%= link_to "Login", login_path %>
+ <% end %>
+ </div>
+
+ <%= yield %>
+
+</div>
+<div id="footer" >
+<p > MyIT CRM Version 2.0.0</p>
+
+</div>
+
+
+
+</body>
+
+</html>
@@ -0,0 +1,15 @@
+<h1><%= (t "user_t_edit_user") %></h1>
+
+<% form_for(@role) do |f| %>
+ <%= f.error_messages %>
+
+ <p>
+ <%= f.label t "user.username" %><br />
+ <%= f.text_field :name %>
+ </p>
+ <p>
+ <%= f.submit t "global.submit" %>
+ </p>
+<% end %>
+
+<%= link_to (t "global.back"), roles_path %>
Oops, something went wrong.

0 comments on commit dbfddf0

Please sign in to comment.