tournament 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (264) hide show
  1. data/History.txt +15 -0
  2. data/Manifest.txt +241 -2
  3. data/README.txt +152 -12
  4. data/Rakefile +9 -6
  5. data/bin/benchmark_pool +0 -0
  6. data/bin/gui.rb +3 -1
  7. data/bin/picker +0 -0
  8. data/bin/pool +139 -15
  9. data/lib/tournament/bracket.rb +33 -50
  10. data/lib/tournament/entry.rb +3 -0
  11. data/lib/tournament/pool.rb +144 -93
  12. data/lib/tournament/scoring_strategy.rb +69 -0
  13. data/lib/tournament/webgui_installer.rb +109 -0
  14. data/tasks/ann.rake +19 -14
  15. data/tasks/bones.rake +6 -25
  16. data/tasks/gem.rake +46 -36
  17. data/tasks/git.rake +41 -0
  18. data/tasks/jamis.rb +589 -0
  19. data/tasks/notes.rake +28 -0
  20. data/tasks/post_load.rake +18 -11
  21. data/tasks/{doc.rake → rdoc.rake} +12 -9
  22. data/tasks/rubyforge.rake +12 -12
  23. data/tasks/setup.rb +121 -80
  24. data/tasks/spec.rake +12 -13
  25. data/tasks/svn.rake +15 -11
  26. data/tasks/test.rake +6 -6
  27. data/test/test_tournament.rb +8 -0
  28. data/test/test_webgui_installer.rb +64 -0
  29. data/webgui/README +256 -0
  30. data/webgui/Rakefile +10 -0
  31. data/webgui/app/controllers/admin_controller.rb +61 -0
  32. data/webgui/app/controllers/application.rb +25 -0
  33. data/webgui/app/controllers/entry_controller.rb +97 -0
  34. data/webgui/app/controllers/pool_controller.rb +4 -0
  35. data/webgui/app/controllers/reports_controller.rb +7 -0
  36. data/webgui/app/controllers/sessions_controller.rb +43 -0
  37. data/webgui/app/controllers/teams_controller.rb +75 -0
  38. data/webgui/app/controllers/users_controller.rb +57 -0
  39. data/webgui/app/helpers/admin_helper.rb +2 -0
  40. data/webgui/app/helpers/application_helper.rb +3 -0
  41. data/webgui/app/helpers/entry_helper.rb +2 -0
  42. data/webgui/app/helpers/pool_helper.rb +2 -0
  43. data/webgui/app/helpers/reports_helper.rb +2 -0
  44. data/webgui/app/helpers/sessions_helper.rb +2 -0
  45. data/webgui/app/helpers/teams_helper.rb +2 -0
  46. data/webgui/app/helpers/users_helper.rb +93 -0
  47. data/webgui/app/models/entry.rb +42 -0
  48. data/webgui/app/models/pool.rb +141 -0
  49. data/webgui/app/models/region.rb +3 -0
  50. data/webgui/app/models/role.rb +4 -0
  51. data/webgui/app/models/seeding.rb +4 -0
  52. data/webgui/app/models/team.rb +6 -0
  53. data/webgui/app/models/user.rb +98 -0
  54. data/webgui/app/models/user_mailer.rb +25 -0
  55. data/webgui/app/views/admin/bracket.html.erb +3 -0
  56. data/webgui/app/views/admin/entries.html.erb +25 -0
  57. data/webgui/app/views/admin/index.html.erb +17 -0
  58. data/webgui/app/views/admin/pool.html.erb +53 -0
  59. data/webgui/app/views/entry/index.html.erb +16 -0
  60. data/webgui/app/views/entry/print.erb +1 -0
  61. data/webgui/app/views/entry/print.html.erb +1 -0
  62. data/webgui/app/views/entry/show.html.erb +1 -0
  63. data/webgui/app/views/layouts/bracket.html.erb +37 -0
  64. data/webgui/app/views/layouts/default.html.erb +62 -0
  65. data/webgui/app/views/layouts/print.html.erb +12 -0
  66. data/webgui/app/views/layouts/report.html.erb +38 -0
  67. data/webgui/app/views/pool/index.html.erb +36 -0
  68. data/webgui/app/views/reports/_report.html.erb +11 -0
  69. data/webgui/app/views/reports/show.html.erb +12 -0
  70. data/webgui/app/views/sessions/new.html.erb +21 -0
  71. data/webgui/app/views/shared/_admins.html.erb +8 -0
  72. data/webgui/app/views/shared/_bracket.html.erb +1296 -0
  73. data/webgui/app/views/teams/choose.html.erb +57 -0
  74. data/webgui/app/views/user_mailer/activation.erb +3 -0
  75. data/webgui/app/views/user_mailer/signup_notification.erb +8 -0
  76. data/webgui/app/views/users/_user_bar.html.erb +8 -0
  77. data/webgui/app/views/users/new.html.erb +19 -0
  78. data/webgui/config/boot.rb +109 -0
  79. data/webgui/config/database.yml +22 -0
  80. data/webgui/config/environment.rb +78 -0
  81. data/webgui/config/environments/development.rb +29 -0
  82. data/webgui/config/environments/production.rb +24 -0
  83. data/webgui/config/environments/test.rb +22 -0
  84. data/webgui/config/initializers/inflections.rb +10 -0
  85. data/webgui/config/initializers/mime_types.rb +5 -0
  86. data/webgui/config/initializers/new_rails_defaults.rb +17 -0
  87. data/webgui/config/initializers/pool.rb +33 -0
  88. data/webgui/config/initializers/site_keys.rb +38 -0
  89. data/webgui/config/locales/en.yml +5 -0
  90. data/webgui/config/routes.rb +56 -0
  91. data/webgui/db/development.sqlite3 +0 -0
  92. data/webgui/db/migrate/20090216015836_create_entries.rb +13 -0
  93. data/webgui/db/migrate/20090217001611_add_tie_break_to_entry.rb +9 -0
  94. data/webgui/db/migrate/20090217004039_create_users.rb +23 -0
  95. data/webgui/db/migrate/20090217014940_relate_entry_and_user.rb +10 -0
  96. data/webgui/db/migrate/20090218024350_create_roles.rb +17 -0
  97. data/webgui/db/migrate/20090218024657_add_postition_to_roles.rb +9 -0
  98. data/webgui/db/migrate/20090218025240_add_admin_role.rb +10 -0
  99. data/webgui/db/migrate/20090225022928_create_pools.rb +16 -0
  100. data/webgui/db/migrate/20090225030346_associate_pool_and_entry.rb +9 -0
  101. data/webgui/db/migrate/20090225072358_change_pool_data_column.rb +9 -0
  102. data/webgui/db/migrate/20090225072849_add_completed_to_entries.rb +9 -0
  103. data/webgui/db/migrate/20090225074149_add_pool_id_index_to_entries.rb +9 -0
  104. data/webgui/db/migrate/20090225084414_add_user_id_to_pool.rb +9 -0
  105. data/webgui/db/migrate/20090226021913_add_active_to_pools.rb +9 -0
  106. data/webgui/db/migrate/20090226142240_rename_bracket_column_to_data.rb +9 -0
  107. data/webgui/db/migrate/20090301014710_create_teams.rb +84 -0
  108. data/webgui/db/migrate/20090301025902_add_more_teams.rb +16 -0
  109. data/webgui/db/migrate/20090301041526_create_seedings.rb +16 -0
  110. data/webgui/db/migrate/20090301090511_create_regions.rb +14 -0
  111. data/webgui/db/migrate/teams.txt +347 -0
  112. data/webgui/db/pool.yml +408 -0
  113. data/webgui/db/schema.rb +91 -0
  114. data/webgui/db/test.sqlite3 +0 -0
  115. data/webgui/doc/README_FOR_APP +5 -0
  116. data/webgui/lib/authenticated_system.rb +189 -0
  117. data/webgui/lib/authenticated_test_helper.rb +11 -0
  118. data/webgui/lib/form_object.rb +70 -0
  119. data/webgui/lib/pdf_helper.rb +47 -0
  120. data/webgui/lib/prince.rb +74 -0
  121. data/webgui/lib/saves_picks.rb +23 -0
  122. data/webgui/lib/tasks/admin.rake +10 -0
  123. data/webgui/public/404.html +30 -0
  124. data/webgui/public/422.html +30 -0
  125. data/webgui/public/500.html +33 -0
  126. data/webgui/public/dispatch.cgi +10 -0
  127. data/webgui/public/dispatch.fcgi +24 -0
  128. data/webgui/public/dispatch.rb +10 -0
  129. data/webgui/public/favicon.ico +0 -0
  130. data/webgui/public/images/2009FinalFour.png +0 -0
  131. data/webgui/public/images/rails.png +0 -0
  132. data/webgui/public/javascripts/application.js +2 -0
  133. data/webgui/public/javascripts/bracket.js +73 -0
  134. data/webgui/public/javascripts/controls.js +963 -0
  135. data/webgui/public/javascripts/dragdrop.js +973 -0
  136. data/webgui/public/javascripts/effects.js +1128 -0
  137. data/webgui/public/javascripts/prototype.js +4320 -0
  138. data/webgui/public/robots.txt +5 -0
  139. data/webgui/public/stylesheets/bracket-print.css +39 -0
  140. data/webgui/public/stylesheets/bracket.css +125 -0
  141. data/webgui/public/stylesheets/main.css +144 -0
  142. data/webgui/public/stylesheets/prince.css +6 -0
  143. data/webgui/public/stylesheets/prince_landscape.css +1 -0
  144. data/webgui/script/about +4 -0
  145. data/webgui/script/console +3 -0
  146. data/webgui/script/dbconsole +3 -0
  147. data/webgui/script/destroy +3 -0
  148. data/webgui/script/generate +3 -0
  149. data/webgui/script/performance/benchmarker +3 -0
  150. data/webgui/script/performance/profiler +3 -0
  151. data/webgui/script/performance/request +3 -0
  152. data/webgui/script/plugin +3 -0
  153. data/webgui/script/process/inspector +3 -0
  154. data/webgui/script/process/reaper +3 -0
  155. data/webgui/script/process/spawner +3 -0
  156. data/webgui/script/runner +3 -0
  157. data/webgui/script/server +3 -0
  158. data/webgui/test/fixtures/entries.yml +10 -0
  159. data/webgui/test/fixtures/pools.yml +14 -0
  160. data/webgui/test/fixtures/regions.yml +11 -0
  161. data/webgui/test/fixtures/roles.yml +11 -0
  162. data/webgui/test/fixtures/roles_users.yml +3 -0
  163. data/webgui/test/fixtures/seedings.yml +12 -0
  164. data/webgui/test/fixtures/teams.yml +3051 -0
  165. data/webgui/test/fixtures/users.yml +44 -0
  166. data/webgui/test/functional/admin_controller_test.rb +8 -0
  167. data/webgui/test/functional/entry_controller_test.rb +27 -0
  168. data/webgui/test/functional/pool_controller_test.rb +8 -0
  169. data/webgui/test/functional/reports_controller_test.rb +8 -0
  170. data/webgui/test/functional/sessions_controller_test.rb +82 -0
  171. data/webgui/test/functional/teams_controller_test.rb +216 -0
  172. data/webgui/test/functional/users_controller_test.rb +88 -0
  173. data/webgui/test/performance/browsing_test.rb +9 -0
  174. data/webgui/test/test_helper.rb +38 -0
  175. data/webgui/test/unit/entry_test.rb +8 -0
  176. data/webgui/test/unit/pool_test.rb +8 -0
  177. data/webgui/test/unit/region_test.rb +8 -0
  178. data/webgui/test/unit/role_test.rb +8 -0
  179. data/webgui/test/unit/seeding_test.rb +8 -0
  180. data/webgui/test/unit/team_test.rb +10 -0
  181. data/webgui/test/unit/user_mailer_test.rb +31 -0
  182. data/webgui/test/unit/user_test.rb +109 -0
  183. data/webgui/vendor/plugins/auto_complete/README +23 -0
  184. data/webgui/vendor/plugins/auto_complete/Rakefile +22 -0
  185. data/webgui/vendor/plugins/auto_complete/init.rb +2 -0
  186. data/webgui/vendor/plugins/auto_complete/lib/auto_complete.rb +47 -0
  187. data/webgui/vendor/plugins/auto_complete/lib/auto_complete_macros_helper.rb +143 -0
  188. data/webgui/vendor/plugins/auto_complete/test/auto_complete_test.rb +67 -0
  189. data/webgui/vendor/plugins/enumerations_mixin/ATTENTION +15 -0
  190. data/webgui/vendor/plugins/enumerations_mixin/LICENSE +20 -0
  191. data/webgui/vendor/plugins/enumerations_mixin/README_ENUMERATIONS +163 -0
  192. data/webgui/vendor/plugins/enumerations_mixin/init.rb +21 -0
  193. data/webgui/vendor/plugins/enumerations_mixin/lib/active_record/acts/enumerated.rb +177 -0
  194. data/webgui/vendor/plugins/enumerations_mixin/lib/active_record/aggregations/has_enumerated.rb +60 -0
  195. data/webgui/vendor/plugins/enumerations_mixin/lib/active_record/virtual_enumerations.rb +68 -0
  196. data/webgui/vendor/plugins/enumerations_mixin/virtual_enumerations_sample.rb +76 -0
  197. data/webgui/vendor/plugins/restful_authentication/.gitignore +21 -0
  198. data/webgui/vendor/plugins/restful_authentication/CHANGELOG +68 -0
  199. data/webgui/vendor/plugins/restful_authentication/README.textile +224 -0
  200. data/webgui/vendor/plugins/restful_authentication/Rakefile +32 -0
  201. data/webgui/vendor/plugins/restful_authentication/TODO +15 -0
  202. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/USAGE +1 -0
  203. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/authenticated_generator.rb +478 -0
  204. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/lib/insert_routes.rb +54 -0
  205. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/_model_partial.html.erb +8 -0
  206. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/activation.erb +3 -0
  207. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_system.rb +189 -0
  208. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb +22 -0
  209. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/controller.rb +43 -0
  210. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/helper.rb +2 -0
  211. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/login.html.erb +16 -0
  212. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/mailer.rb +25 -0
  213. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/migration.rb +26 -0
  214. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/model.rb +83 -0
  215. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/model_controller.rb +85 -0
  216. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/model_helper.rb +93 -0
  217. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/model_helper_spec.rb +158 -0
  218. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/observer.rb +11 -0
  219. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/signup.html.erb +19 -0
  220. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/signup_notification.erb +8 -0
  221. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/site_keys.rb +38 -0
  222. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/spec/controllers/access_control_spec.rb +90 -0
  223. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/spec/controllers/authenticated_system_spec.rb +102 -0
  224. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/spec/controllers/sessions_controller_spec.rb +139 -0
  225. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/spec/controllers/users_controller_spec.rb +198 -0
  226. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/spec/fixtures/users.yml +60 -0
  227. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/spec/helpers/users_helper_spec.rb +141 -0
  228. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/spec/models/user_spec.rb +290 -0
  229. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/rest_auth_stories.rb +22 -0
  230. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/rest_auth_stories_helper.rb +81 -0
  231. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb +49 -0
  232. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_resource_steps.rb +179 -0
  233. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_response_steps.rb +171 -0
  234. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/user_steps.rb +153 -0
  235. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/users/accounts.story +186 -0
  236. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/users/sessions.story +134 -0
  237. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/test/functional_test.rb +82 -0
  238. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/test/mailer_test.rb +31 -0
  239. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/test/model_functional_test.rb +93 -0
  240. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/test/unit_test.rb +164 -0
  241. data/webgui/vendor/plugins/restful_authentication/init.rb +1 -0
  242. data/webgui/vendor/plugins/restful_authentication/install.rb +1 -0
  243. data/webgui/vendor/plugins/restful_authentication/lib/authentication/by_cookie_token.rb +82 -0
  244. data/webgui/vendor/plugins/restful_authentication/lib/authentication/by_password.rb +64 -0
  245. data/webgui/vendor/plugins/restful_authentication/lib/authentication.rb +40 -0
  246. data/webgui/vendor/plugins/restful_authentication/lib/authorization/aasm_roles.rb +63 -0
  247. data/webgui/vendor/plugins/restful_authentication/lib/authorization/stateful_roles.rb +62 -0
  248. data/webgui/vendor/plugins/restful_authentication/lib/authorization.rb +14 -0
  249. data/webgui/vendor/plugins/restful_authentication/lib/trustification/email_validation.rb +20 -0
  250. data/webgui/vendor/plugins/restful_authentication/lib/trustification.rb +14 -0
  251. data/webgui/vendor/plugins/restful_authentication/notes/AccessControl.txt +2 -0
  252. data/webgui/vendor/plugins/restful_authentication/notes/Authentication.txt +5 -0
  253. data/webgui/vendor/plugins/restful_authentication/notes/Authorization.txt +154 -0
  254. data/webgui/vendor/plugins/restful_authentication/notes/RailsPlugins.txt +78 -0
  255. data/webgui/vendor/plugins/restful_authentication/notes/SecurityFramework.graffle +0 -0
  256. data/webgui/vendor/plugins/restful_authentication/notes/SecurityFramework.png +0 -0
  257. data/webgui/vendor/plugins/restful_authentication/notes/SecurityPatterns.txt +163 -0
  258. data/webgui/vendor/plugins/restful_authentication/notes/Tradeoffs.txt +126 -0
  259. data/webgui/vendor/plugins/restful_authentication/notes/Trustification.txt +49 -0
  260. data/webgui/vendor/plugins/restful_authentication/rails/init.rb +3 -0
  261. data/webgui/vendor/plugins/restful_authentication/restful-authentication.gemspec +33 -0
  262. data/webgui/vendor/plugins/restful_authentication/tasks/auth.rake +33 -0
  263. metadata +288 -8
  264. data/tasks/annotations.rake +0 -22
data/webgui/README ADDED
@@ -0,0 +1,256 @@
1
+ == Welcome to Rails
2
+
3
+ Rails is a web-application framework that includes everything needed to create
4
+ database-backed web applications according to the Model-View-Control pattern.
5
+
6
+ This pattern splits the view (also called the presentation) into "dumb" templates
7
+ that are primarily responsible for inserting pre-built data in between HTML tags.
8
+ The model contains the "smart" domain objects (such as Account, Product, Person,
9
+ Post) that holds all the business logic and knows how to persist themselves to
10
+ a database. The controller handles the incoming requests (such as Save New Account,
11
+ Update Product, Show Post) by manipulating the model and directing data to the view.
12
+
13
+ In Rails, the model is handled by what's called an object-relational mapping
14
+ layer entitled Active Record. This layer allows you to present the data from
15
+ database rows as objects and embellish these data objects with business logic
16
+ methods. You can read more about Active Record in
17
+ link:files/vendor/rails/activerecord/README.html.
18
+
19
+ The controller and view are handled by the Action Pack, which handles both
20
+ layers by its two parts: Action View and Action Controller. These two layers
21
+ are bundled in a single package due to their heavy interdependence. This is
22
+ unlike the relationship between the Active Record and Action Pack that is much
23
+ more separate. Each of these packages can be used independently outside of
24
+ Rails. You can read more about Action Pack in
25
+ link:files/vendor/rails/actionpack/README.html.
26
+
27
+
28
+ == Getting Started
29
+
30
+ 1. At the command prompt, start a new Rails application using the <tt>rails</tt> command
31
+ and your application name. Ex: rails myapp
32
+ 2. Change directory into myapp and start the web server: <tt>script/server</tt> (run with --help for options)
33
+ 3. Go to http://localhost:3000/ and get "Welcome aboard: You're riding the Rails!"
34
+ 4. Follow the guidelines to start developing your application
35
+
36
+
37
+ == Web Servers
38
+
39
+ By default, Rails will try to use Mongrel and lighttpd if they are installed, otherwise
40
+ Rails will use WEBrick, the webserver that ships with Ruby. When you run script/server,
41
+ Rails will check if Mongrel exists, then lighttpd and finally fall back to WEBrick. This ensures
42
+ that you can always get up and running quickly.
43
+
44
+ Mongrel is a Ruby-based webserver with a C component (which requires compilation) that is
45
+ suitable for development and deployment of Rails applications. If you have Ruby Gems installed,
46
+ getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>.
47
+ More info at: http://mongrel.rubyforge.org
48
+
49
+ If Mongrel is not installed, Rails will look for lighttpd. It's considerably faster than
50
+ Mongrel and WEBrick and also suited for production use, but requires additional
51
+ installation and currently only works well on OS X/Unix (Windows users are encouraged
52
+ to start with Mongrel). We recommend version 1.4.11 and higher. You can download it from
53
+ http://www.lighttpd.net.
54
+
55
+ And finally, if neither Mongrel or lighttpd are installed, Rails will use the built-in Ruby
56
+ web server, WEBrick. WEBrick is a small Ruby web server suitable for development, but not
57
+ for production.
58
+
59
+ But of course its also possible to run Rails on any platform that supports FCGI.
60
+ Apache, LiteSpeed, IIS are just a few. For more information on FCGI,
61
+ please visit: http://wiki.rubyonrails.com/rails/pages/FastCGI
62
+
63
+
64
+ == Apache .htaccess example
65
+
66
+ # General Apache options
67
+ AddHandler fastcgi-script .fcgi
68
+ AddHandler cgi-script .cgi
69
+ Options +FollowSymLinks +ExecCGI
70
+
71
+ # If you don't want Rails to look in certain directories,
72
+ # use the following rewrite rules so that Apache won't rewrite certain requests
73
+ #
74
+ # Example:
75
+ # RewriteCond %{REQUEST_URI} ^/notrails.*
76
+ # RewriteRule .* - [L]
77
+
78
+ # Redirect all requests not available on the filesystem to Rails
79
+ # By default the cgi dispatcher is used which is very slow
80
+ #
81
+ # For better performance replace the dispatcher with the fastcgi one
82
+ #
83
+ # Example:
84
+ # RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
85
+ RewriteEngine On
86
+
87
+ # If your Rails application is accessed via an Alias directive,
88
+ # then you MUST also set the RewriteBase in this htaccess file.
89
+ #
90
+ # Example:
91
+ # Alias /myrailsapp /path/to/myrailsapp/public
92
+ # RewriteBase /myrailsapp
93
+
94
+ RewriteRule ^$ index.html [QSA]
95
+ RewriteRule ^([^.]+)$ $1.html [QSA]
96
+ RewriteCond %{REQUEST_FILENAME} !-f
97
+ RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
98
+
99
+ # In case Rails experiences terminal errors
100
+ # Instead of displaying this message you can supply a file here which will be rendered instead
101
+ #
102
+ # Example:
103
+ # ErrorDocument 500 /500.html
104
+
105
+ ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
106
+
107
+
108
+ == Debugging Rails
109
+
110
+ Sometimes your application goes wrong. Fortunately there are a lot of tools that
111
+ will help you debug it and get it back on the rails.
112
+
113
+ First area to check is the application log files. Have "tail -f" commands running
114
+ on the server.log and development.log. Rails will automatically display debugging
115
+ and runtime information to these files. Debugging info will also be shown in the
116
+ browser on requests from 127.0.0.1.
117
+
118
+ You can also log your own messages directly into the log file from your code using
119
+ the Ruby logger class from inside your controllers. Example:
120
+
121
+ class WeblogController < ActionController::Base
122
+ def destroy
123
+ @weblog = Weblog.find(params[:id])
124
+ @weblog.destroy
125
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
126
+ end
127
+ end
128
+
129
+ The result will be a message in your log file along the lines of:
130
+
131
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1
132
+
133
+ More information on how to use the logger is at http://www.ruby-doc.org/core/
134
+
135
+ Also, Ruby documentation can be found at http://www.ruby-lang.org/ including:
136
+
137
+ * The Learning Ruby (Pickaxe) Book: http://www.ruby-doc.org/docs/ProgrammingRuby/
138
+ * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
139
+
140
+ These two online (and free) books will bring you up to speed on the Ruby language
141
+ and also on programming in general.
142
+
143
+
144
+ == Debugger
145
+
146
+ Debugger support is available through the debugger command when you start your Mongrel or
147
+ Webrick server with --debugger. This means that you can break out of execution at any point
148
+ in the code, investigate and change the model, AND then resume execution!
149
+ You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'
150
+ Example:
151
+
152
+ class WeblogController < ActionController::Base
153
+ def index
154
+ @posts = Post.find(:all)
155
+ debugger
156
+ end
157
+ end
158
+
159
+ So the controller will accept the action, run the first line, then present you
160
+ with a IRB prompt in the server window. Here you can do things like:
161
+
162
+ >> @posts.inspect
163
+ => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
164
+ #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
165
+ >> @posts.first.title = "hello from a debugger"
166
+ => "hello from a debugger"
167
+
168
+ ...and even better is that you can examine how your runtime objects actually work:
169
+
170
+ >> f = @posts.first
171
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
172
+ >> f.
173
+ Display all 152 possibilities? (y or n)
174
+
175
+ Finally, when you're ready to resume execution, you enter "cont"
176
+
177
+
178
+ == Console
179
+
180
+ You can interact with the domain model by starting the console through <tt>script/console</tt>.
181
+ Here you'll have all parts of the application configured, just like it is when the
182
+ application is running. You can inspect domain models, change values, and save to the
183
+ database. Starting the script without arguments will launch it in the development environment.
184
+ Passing an argument will specify a different environment, like <tt>script/console production</tt>.
185
+
186
+ To reload your controllers and models after launching the console run <tt>reload!</tt>
187
+
188
+ == dbconsole
189
+
190
+ You can go to the command line of your database directly through <tt>script/dbconsole</tt>.
191
+ You would be connected to the database with the credentials defined in database.yml.
192
+ Starting the script without arguments will connect you to the development database. Passing an
193
+ argument will connect you to a different database, like <tt>script/dbconsole production</tt>.
194
+ Currently works for mysql, postgresql and sqlite.
195
+
196
+ == Description of Contents
197
+
198
+ app
199
+ Holds all the code that's specific to this particular application.
200
+
201
+ app/controllers
202
+ Holds controllers that should be named like weblogs_controller.rb for
203
+ automated URL mapping. All controllers should descend from ApplicationController
204
+ which itself descends from ActionController::Base.
205
+
206
+ app/models
207
+ Holds models that should be named like post.rb.
208
+ Most models will descend from ActiveRecord::Base.
209
+
210
+ app/views
211
+ Holds the template files for the view that should be named like
212
+ weblogs/index.html.erb for the WeblogsController#index action. All views use eRuby
213
+ syntax.
214
+
215
+ app/views/layouts
216
+ Holds the template files for layouts to be used with views. This models the common
217
+ header/footer method of wrapping views. In your views, define a layout using the
218
+ <tt>layout :default</tt> and create a file named default.html.erb. Inside default.html.erb,
219
+ call <% yield %> to render the view using this layout.
220
+
221
+ app/helpers
222
+ Holds view helpers that should be named like weblogs_helper.rb. These are generated
223
+ for you automatically when using script/generate for controllers. Helpers can be used to
224
+ wrap functionality for your views into methods.
225
+
226
+ config
227
+ Configuration files for the Rails environment, the routing map, the database, and other dependencies.
228
+
229
+ db
230
+ Contains the database schema in schema.rb. db/migrate contains all
231
+ the sequence of Migrations for your schema.
232
+
233
+ doc
234
+ This directory is where your application documentation will be stored when generated
235
+ using <tt>rake doc:app</tt>
236
+
237
+ lib
238
+ Application specific libraries. Basically, any kind of custom code that doesn't
239
+ belong under controllers, models, or helpers. This directory is in the load path.
240
+
241
+ public
242
+ The directory available for the web server. Contains subdirectories for images, stylesheets,
243
+ and javascripts. Also contains the dispatchers and the default HTML files. This should be
244
+ set as the DOCUMENT_ROOT of your web server.
245
+
246
+ script
247
+ Helper scripts for automation and generation.
248
+
249
+ test
250
+ Unit and functional tests along with fixtures. When using the script/generate scripts, template
251
+ test files will be generated for you and placed in this directory.
252
+
253
+ vendor
254
+ External libraries that the application depends on. Also includes the plugins subdirectory.
255
+ If the app has frozen rails, those gems also go here, under vendor/rails/.
256
+ This directory is in the load path.
data/webgui/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require(File.join(File.dirname(__FILE__), 'config', 'boot'))
5
+
6
+ require 'rake'
7
+ require 'rake/testtask'
8
+ require 'rake/rdoctask'
9
+
10
+ require 'tasks/rails'
@@ -0,0 +1,61 @@
1
+ class AdminController < ApplicationController
2
+ before_filter :login_required
3
+ include SavesPicks
4
+
5
+ def edit
6
+ @entry = Entry.find_by_user_id(current_user.id)
7
+ if @entry
8
+ @pool = @entry.pool
9
+ save_picks(@entry)
10
+ if @entry.save
11
+ @pool.pool.tournament_entry = @entry.tournament_entry
12
+ @pool.save
13
+ flash[:info] = "Tournament bracket updated."
14
+ redirect_to :action => 'bracket', :id => @pool.id
15
+ else
16
+ flash[:error] = "Could not save entry."
17
+ render :action => 'bracket', :layout => 'bracket'
18
+ end
19
+ else
20
+ flash[:error] = "Tournament bracket has not yet been initialized."
21
+ end
22
+ end
23
+
24
+ def entries
25
+ @pool = Pool.find(params[:id])
26
+ end
27
+
28
+ def index
29
+ @pools = Pool.find(:all)
30
+ end
31
+
32
+ def pool
33
+ @available_scoring_strategies = Tournament::ScoringStrategy.available_strategies.map{|n| Tournament::ScoringStrategy.strategy_for_name(n)}
34
+ @pool = params[:id] ? Pool.find(params[:id]) : Pool.new
35
+ if request.post?
36
+ @pool.attributes = params[:pool]
37
+ @pool.user_id ||= current_user.id
38
+ if @pool.valid?
39
+ @pool.save!
40
+ # reload it
41
+ @pool = Pool.find(@pool.id)
42
+ end
43
+ end
44
+ end
45
+
46
+ def bracket
47
+ pool = Pool.find(params[:id])
48
+ # This is confusing ...
49
+ @pool = pool.pool
50
+ @entry = Entry.find_or_initialize_by_user_id(:user_id => current_user.id, :pool_id => pool.id, :tie_break => 0, :name => 'Tournament Bracket')
51
+ @entry.bracket
52
+ @entry.save!
53
+
54
+ render :layout => 'bracket'
55
+ end
56
+
57
+ def authorized?(action = action_name, resource = nil)
58
+ return super && admin_authorized?(action_name, resource)
59
+ end
60
+
61
+ end
@@ -0,0 +1,25 @@
1
+ # Filters added to this controller apply to all controllers in the application.
2
+ # Likewise, all the methods added will be available for all controllers.
3
+
4
+ class ApplicationController < ActionController::Base
5
+ layout 'default'
6
+ include AuthenticatedSystem
7
+ #helper :all # include all helpers, all the time
8
+
9
+ # See ActionController::RequestForgeryProtection for details
10
+ # Uncomment the :secret if you're not using the cookie session store
11
+ protect_from_forgery # :secret => '24a18931c02e0d07b788d1298b19f7b7'
12
+
13
+ # See ActionController::Base for details
14
+ # Uncomment this to filter the contents of submitted sensitive data parameters
15
+ # from your application log (in this case, all fields with names like "password").
16
+ # filter_parameter_logging :password
17
+
18
+ def admin_authorized?(action = action_name, resource = nil)
19
+ unless current_user.roles.include?(Role[:admin])
20
+ flash[:info] = "You are not authorized to perform that action."
21
+ return false
22
+ end
23
+ return true
24
+ end
25
+ end
@@ -0,0 +1,97 @@
1
+ class EntryController < ApplicationController
2
+ layout 'bracket'
3
+ before_filter :login_required
4
+ before_filter :check_access, :only => [:show, :edit, :print, :pdf]
5
+ before_filter :pool_taking_edits, :only => [:edit]
6
+ include SavesPicks
7
+ include PdfHelper
8
+
9
+ def check_access
10
+ # Resolve the entry
11
+ @entry = params[:id] ? Entry.find(params[:id]) : Entry.new({:user_id => current_user.id, :pool_id => params[:pool_id]})
12
+
13
+ # Admin user
14
+ return true if current_user.has_role?(:admin)
15
+
16
+ # Check if entry being viewed belongs to current user
17
+ if current_user != @entry.user
18
+ flash[:info] = "You don't have access to that entry."
19
+ redirect_to root_path
20
+ return false
21
+ end
22
+ return true
23
+ end
24
+
25
+ def pool_taking_edits
26
+ # Admin user can do anything
27
+ return true if current_user.has_role?(:admin)
28
+
29
+ if Time.now > @entry.pool.starts_at
30
+ flash[:error] = "You can't make changes to your entry, the pool has already started."
31
+ redirect_to :action => 'show'
32
+ return false
33
+ end
34
+
35
+ return true
36
+ end
37
+
38
+ def new
39
+ @entry = Entry.new(:pool_id => params[:id])
40
+ @pool = @entry.pool.pool
41
+ render :action => 'show'
42
+ end
43
+
44
+ def index
45
+ @pool = Pool.find(params[:id])
46
+ @entries = Entry.find_all_by_user_id_and_pool_id(current_user.id, @pool.id)
47
+ render :action => 'index', :layout => 'default'
48
+ end
49
+
50
+ def show
51
+ @pool = @entry.pool.pool
52
+ end
53
+
54
+ def print
55
+ @pool = @entry.pool.pool
56
+ render :layout => 'print'
57
+ end
58
+
59
+ def pdf
60
+ @pool = @entry.pool.pool
61
+ make_and_send_pdf("/entry/print", 'entry.pdf', true)
62
+ end
63
+
64
+ def edit
65
+ if params[:reset] == 'Reset Picks'
66
+ @entry.reset
67
+ if @entry.new_record?
68
+ redirect_to :action => 'new', :id => params[:pool_id]
69
+ return
70
+ end
71
+ elsif params[:cancel] == 'Cancel Changes'
72
+ flash[:info] = "Changes were <b>canceled</b>."
73
+ if @entry.new_record?
74
+ redirect_to :action => 'index', :id => params[:pool_id]
75
+ else
76
+ redirect_to :action => 'show', :id => @entry.id
77
+ end
78
+ return
79
+ else
80
+ save_picks(@entry)
81
+ end
82
+ logger.debug("SAVING ENTRY")
83
+ if @entry.save
84
+ logger.debug("DONE SAVING ENTRY")
85
+ flash[:info] = "Changes were saved."
86
+ if !@entry.completed
87
+ flash[:notice] = "You still have remaining games in this entry to pick."
88
+ else
89
+ flash[:notice] = "You have made all picks in this entry."
90
+ end
91
+ redirect_to :action => 'show', :id => @entry.id
92
+ else
93
+ flash[:error] = "Could not save entry."
94
+ render :action => 'show', :id => @entry.id
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,4 @@
1
+ class PoolController < ApplicationController
2
+ def index
3
+ end
4
+ end
@@ -0,0 +1,7 @@
1
+ class ReportsController < ApplicationController
2
+ layout 'report'
3
+ def show
4
+ @pool = Pool.find(params[:id])
5
+ end
6
+
7
+ end
@@ -0,0 +1,43 @@
1
+ # This controller handles the login/logout function of the site.
2
+ class SessionsController < ApplicationController
3
+ # Be sure to include AuthenticationSystem in Application Controller instead
4
+ include AuthenticatedSystem
5
+
6
+ # render new.rhtml
7
+ def new
8
+ end
9
+
10
+ def create
11
+ logout_keeping_session!
12
+ user = User.authenticate(params[:login], params[:password])
13
+ if user
14
+ # Protects against session fixation attacks, causes request forgery
15
+ # protection if user resubmits an earlier form using back
16
+ # button. Uncomment if you understand the tradeoffs.
17
+ # reset_session
18
+ self.current_user = user
19
+ new_cookie_flag = (params[:remember_me] == "1")
20
+ handle_remember_cookie! new_cookie_flag
21
+ redirect_back_or_default(root_path)
22
+ flash[:notice] = "Logged in successfully"
23
+ else
24
+ note_failed_signin
25
+ @login = params[:login]
26
+ @remember_me = params[:remember_me]
27
+ render :action => 'new'
28
+ end
29
+ end
30
+
31
+ def destroy
32
+ logout_killing_session!
33
+ flash[:notice] = "You have been logged out."
34
+ redirect_back_or_default(root_path)
35
+ end
36
+
37
+ protected
38
+ # Track failed login attempts
39
+ def note_failed_signin
40
+ flash[:error] = "Couldn't log you in as '#{params[:login]}'"
41
+ logger.warn "Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}"
42
+ end
43
+ end
@@ -0,0 +1,75 @@
1
+ class TeamsController < ApplicationController
2
+ before_filter :login_required
3
+ skip_before_filter :verify_authenticity_token, :only => [:auto_complete_for_team_name, :auto_complete_for_short_name]
4
+
5
+ def choose
6
+ @pool = Pool.find(params[:id])
7
+ end
8
+
9
+ def auto_complete_for_team_name
10
+ region_hash = params[:region0] || params[:region1] || params[:region2] || params[:region3]
11
+ name_like = region_hash[:seedings][0][:name]
12
+ @teams_like = Team.find(:all, :conditions => ['name like ?', "#{name_like}%"], :order => 'name asc')
13
+ render :inline => "<%= content_tag(:ul, @teams_like.map{|t| content_tag(:li, h(t.name), :short => t.short_name)}) %>"
14
+ end
15
+
16
+ def auto_complete_for_short_name
17
+ region_hash = params[:region0] || params[:region1] || params[:region2] || params[:region3]
18
+ name_like = region_hash[:seedings][0][:short_name]
19
+ @teams_like = Team.find(:all, :conditions => ['short_name like ?', "#{name_like}%"], :order => 'short_name asc')
20
+ render :inline => "<%= content_tag(:ul, @teams_like.map{|t| content_tag(:li, h(t.short_name), :name => t.name)}) %>"
21
+ end
22
+
23
+ def change
24
+ @pool = Pool.find(params[:id])
25
+ [0,1,2,3].each do |region_idx|
26
+ region_hash = params["region#{region_idx}".to_sym]
27
+ next unless region_hash
28
+ region_name = region_hash[:name]
29
+ next if region_name.blank? || region_hash[:seedings].blank?
30
+ raise "Illegal input, seedings array contains more than 16 elements" if region_hash[:seedings].length > 16
31
+ region = Region.find_by_pool_id_and_position(@pool.id, region_idx)
32
+ if !region
33
+ region = Region.create(:name => region_name, :pool_id => @pool.id, :position => region_idx)
34
+ else
35
+ if region_name != region.name
36
+ region.name = region_name
37
+ region.save!
38
+ end
39
+ end
40
+ logger.debug("SAVING SEEDINGS: #{region_hash[:seedings].inspect}")
41
+ region_hash[:seedings].each do |seeding_hash|
42
+ next if seeding_hash[:name].blank? || seeding_hash[:short_name].blank?
43
+ team = Team.find_or_create_by_short_name(seeding_hash[:short_name], :name => seeding_hash[:name])
44
+ existing_region = @pool.region_seedings.find{|rn, rs| rn == region_name}
45
+ existing_team = nil
46
+ if existing_region
47
+ existing_team = existing_region[1][seeding_hash[:seed].to_i - 1]
48
+ end
49
+ if existing_team
50
+ logger.debug "COMPARING existing team #{existing_team.inspect} with new team #{team.inspect}"
51
+ if existing_team != team
52
+ # Change team ...
53
+ existing_seeding = @pool.seedings.find(:first, :conditions => {:team_id => existing_team.id, :region => region_name})
54
+ logger.debug " ==> TEAMS ARE DIFF, CHANGING SEEDING: #{existing_seeding.inspect}"
55
+ existing_seeding.team_id = team.id
56
+ existing_seeding.save!
57
+ end
58
+ else
59
+ @pool.seedings.create(:team_id => team.id, :region => region_name, :seed => seeding_hash[:seed])
60
+ end
61
+ end
62
+ @pool.save
63
+ if @pool.ready?
64
+ @pool.initialize_tournament_pool
65
+ @pool.save
66
+ end
67
+ end
68
+ redirect_to :action => 'choose', :id => @pool.id
69
+ end
70
+
71
+ def authorized?(action = action_name, resource = nil)
72
+ return super && admin_authorized?(action_name, resource)
73
+ end
74
+
75
+ end
@@ -0,0 +1,57 @@
1
+ class UsersController < ApplicationController
2
+ # Be sure to include AuthenticationSystem in Application Controller instead
3
+ # include AuthenticatedSystem
4
+
5
+
6
+ # render new.rhtml
7
+ def new
8
+ @user = User.new
9
+ end
10
+
11
+ def create
12
+ logout_keeping_session!
13
+ @user = User.new(params[:user])
14
+ success = @user && @user.save
15
+ if success && @user.errors.empty?
16
+ email_error = false
17
+ begin
18
+ UserMailer.deliver_signup_notification(@user, activate_path(:activation_code => @user.activation_code, :only_path => false))
19
+ rescue Exception => e
20
+ logger.error("ERROR: Could not deliver activation request email, user account will remain unactive: #{e}")
21
+ email_error = true
22
+ end
23
+ redirect_back_or_default(root_path)
24
+ flash[:notice] = "Thanks for signing up! "
25
+ unless email_error
26
+ flash[:notice] << " We're sending you an email with your activation code."
27
+ else
28
+ flash[:error] = "We were unable to send you an activation email, please contact the pool administrator to get your account activated."
29
+ end
30
+ else
31
+ flash[:error] = "We couldn't set up that account, sorry. Please try again, or contact an admin."
32
+ render :action => 'new'
33
+ end
34
+ end
35
+
36
+ def activate
37
+ logout_keeping_session!
38
+ user = User.find_by_activation_code(params[:activation_code]) unless params[:activation_code].blank?
39
+ case
40
+ when (!params[:activation_code].blank?) && user && !user.active?
41
+ user.activate!
42
+ begin
43
+ UserMailer.deliver_activation(user, root_path(:only_path => false)) if user.recently_activated?
44
+ rescue Exception => e
45
+ logger.error("Could not deliver post-activation email: #{e}")
46
+ end
47
+ flash[:notice] = "Signup complete! Please sign in to continue."
48
+ redirect_to login_path
49
+ when params[:activation_code].blank?
50
+ flash[:error] = "The activation code was missing. Please follow the URL from your email."
51
+ redirect_back_or_default(root_path)
52
+ else
53
+ flash[:error] = "We couldn't find a user with that activation code -- check your email? Or maybe you've already activated -- try signing in."
54
+ redirect_back_or_default(root_path)
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,2 @@
1
+ module AdminHelper
2
+ end
@@ -0,0 +1,3 @@
1
+ # Methods added to this helper will be available to all templates in the application.
2
+ module ApplicationHelper
3
+ end
@@ -0,0 +1,2 @@
1
+ module EntryHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module PoolHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module ReportsHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module SessionsHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module TeamsHelper
2
+ end