tournament 2.2.2 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,6 @@
1
+ == 2.3.0 / 2009-03-20
2
+ * Add ability for admin to send emails to participants. Needs work.
3
+
1
4
  == 2.2.1 / 2009-03-19
2
5
  * Bug fixes and minor display enhancement.
3
6
 
data/Manifest.txt CHANGED
@@ -62,6 +62,7 @@ webgui/app/views/admin/bracket.html.erb
62
62
  webgui/app/views/admin/entries.html.erb
63
63
  webgui/app/views/admin/index.html.erb
64
64
  webgui/app/views/admin/pool.html.erb
65
+ webgui/app/views/admin/recap.html.erb
65
66
  webgui/app/views/entry/index.html.erb
66
67
  webgui/app/views/entry/print.erb
67
68
  webgui/app/views/entry/print.html.erb
@@ -79,6 +80,7 @@ webgui/app/views/shared/_admins.html.erb
79
80
  webgui/app/views/shared/_bracket.html.erb
80
81
  webgui/app/views/teams/choose.html.erb
81
82
  webgui/app/views/user_mailer/activation.erb
83
+ webgui/app/views/user_mailer/recap.erb
82
84
  webgui/app/views/user_mailer/signup_notification.erb
83
85
  webgui/app/views/users/_user_bar.html.erb
84
86
  webgui/app/views/users/new.html.erb
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ PROJ.authors = 'Douglas A. Seifert'
20
20
  PROJ.email = 'doug+rubyforge@dseifert.net'
21
21
  PROJ.url = 'http://www.dseifert.net/code/tournament'
22
22
  PROJ.rubyforge.name = 'tournament'
23
- PROJ.version = '2.2.2'
23
+ PROJ.version = '2.3.0'
24
24
  PROJ.group_id = 5863
25
25
 
26
26
  PROJ.spec.opts << '--color'
@@ -30,6 +30,19 @@ class AdminController < ApplicationController
30
30
  @pools = Pool.find(:all)
31
31
  end
32
32
 
33
+ def recap
34
+ if request.post?
35
+ begin
36
+ UserMailer.deliver_recap(User.find(:all) - [current_user], params[:subject], params[:content], root_path(:only_path => false))
37
+ flash[:notice] = "Email was delivered."
38
+ rescue Exception => e
39
+ flash[:error] = "Email could not be delivered: #{e}"
40
+ logger.error "Could not send recap email: #{e}"
41
+ e.backtrace.each{|b| logger.error(b)}
42
+ end
43
+ end
44
+ end
45
+
33
46
  def pool
34
47
  @available_scoring_strategies = Tournament::ScoringStrategy.available_strategies.map{|n| Tournament::ScoringStrategy.strategy_for_name(n)}
35
48
  @pool = params[:id] ? Pool.find(params[:id]) : Pool.new
@@ -1,25 +1,32 @@
1
1
  class UserMailer < ActionMailer::Base
2
2
  def signup_notification(user, activation_url)
3
3
  setup_email(user)
4
+ @body[:user] = user
4
5
  @subject += 'Please activate your new account'
5
-
6
- #@body[:url] = "#{TOURNAMENT_FQ_WEBROOT}/activate/#{user.activation_code}"
7
6
  @body[:url] = activation_url
8
-
9
7
  end
10
8
 
11
9
  def activation(user, home_url)
12
10
  setup_email(user)
11
+ @body[:user] = user
13
12
  @subject += 'Your account has been activated!'
14
13
  @body[:url] = home_url
15
14
  end
15
+
16
+ def recap(users, subject, content, home_url)
17
+ setup_email(users[0])
18
+ @recipients = ADMIN_EMAIL
19
+ @bcc = users.map{|u| u.email}
20
+ @subject << subject
21
+ @body[:content] = content
22
+ @body[:url] = home_url
23
+ end
16
24
 
17
25
  protected
18
26
  def setup_email(user)
19
- @recipients = "#{user.email}"
27
+ @recipients = user.email
20
28
  @from = ADMIN_EMAIL
21
29
  @subject = "[#{TOURNAMENT_TITLE}] "
22
30
  @sent_on = Time.now
23
- @body[:user] = user
24
31
  end
25
32
  end
@@ -0,0 +1,15 @@
1
+ <h1>Send a Recap Email</h1>
2
+ <form action="<%=url_for :action => 'recap'%>" method="POST">
3
+ <table border="0">
4
+ <tr>
5
+ <td>Subject</td>
6
+ <td><%= text_field_tag 'subject', '', :size => 50%></td>
7
+ </tr>
8
+ <tr>
9
+ <td>Body</td>
10
+ <td><%= text_area_tag 'content', '', :rows => 15, :cols => 70%></td>
11
+ </tr>
12
+ </table>
13
+ <%= token_tag %>
14
+ <input type="submit" value="Send" name="Send"/>
15
+ </form>
@@ -7,9 +7,10 @@
7
7
  <small>
8
8
  <% if current_user && pool.user_id == current_user.id %>
9
9
  &nbsp;
10
+ <%= link_to '[Bracket]', :controller => 'admin', :action => 'bracket', :id => pool.id %>
11
+ <%= link_to '[Recap]', :controller => 'admin', :action => 'recap'%>
10
12
  <%= link_to '[Edit]', :controller => 'admin', :action => 'pool', :id => pool.id %>
11
13
  <%= link_to '[Entries]', :controller => 'admin', :action => 'entries', :id => pool.id %>
12
- <%= link_to '[Bracket]', :controller => 'admin', :action => 'bracket', :id => pool.id %>
13
14
  <% end %>
14
15
  <%= link_to '[Leader Board]', :controller => 'reports', :action => 'show', :id => pool.id, :report => 'leader' %>
15
16
  <%= link_to '[Reports]', :controller => 'reports', :action => 'show', :id => pool.id %>
@@ -0,0 +1,4 @@
1
+ <%= @content %>
2
+
3
+ To check the latest results, as always, go here:
4
+ <%=h @url %>
@@ -44,7 +44,7 @@ Rails::Initializer.run do |config|
44
44
  # Make Time.zone default to the specified zone, and make Active Record store time values
45
45
  # in the database in UTC, and return them converted to the specified local zone.
46
46
  # Run "rake -D time" for a list of tasks for finding time zone names. Comment line to use default local time.
47
- config.time_zone = 'UTC'
47
+ config.time_zone = 'Pacific Time (US & Canada)'
48
48
 
49
49
  # The internationalization framework can be changed to have another default locale (standard is :en) or more load paths.
50
50
  # All files from config/locales/*.rb,yml are added automatically.
Binary file
@@ -1,8 +1,19 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class AdminControllerTest < ActionController::TestCase
4
+ include AuthenticatedTestHelper
5
+ fixtures :users, :roles, :roles_users
4
6
  # Replace this with your real tests.
5
- test "the truth" do
6
- assert true
7
+ test "send recap" do
8
+ login_as :admin
9
+ post(:recap, {:subject => 'subject', :content => 'content'})
10
+ assert_response :success
11
+ assert_equal 1, ActionMailer::Base.deliveries.size, "There should have been an email sent."
12
+ mail = ActionMailer::Base.deliveries.first
13
+ assert_equal [ADMIN_EMAIL], mail.to
14
+ recips = User.find(:all).delete_if{|u| u.has_role?(:admin)}.map{|u| u.email}
15
+ assert_equal recips, mail.bcc
16
+ assert_equal "[#{TOURNAMENT_TITLE}] subject", mail.subject
17
+ assert_match /content/, mail.body
7
18
  end
8
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tournament
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Douglas A. Seifert
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-19 00:00:00 -07:00
12
+ date: 2009-03-20 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -141,6 +141,7 @@ files:
141
141
  - webgui/app/views/admin/entries.html.erb
142
142
  - webgui/app/views/admin/index.html.erb
143
143
  - webgui/app/views/admin/pool.html.erb
144
+ - webgui/app/views/admin/recap.html.erb
144
145
  - webgui/app/views/entry/index.html.erb
145
146
  - webgui/app/views/entry/print.erb
146
147
  - webgui/app/views/entry/print.html.erb
@@ -158,6 +159,7 @@ files:
158
159
  - webgui/app/views/shared/_bracket.html.erb
159
160
  - webgui/app/views/teams/choose.html.erb
160
161
  - webgui/app/views/user_mailer/activation.erb
162
+ - webgui/app/views/user_mailer/recap.erb
161
163
  - webgui/app/views/user_mailer/signup_notification.erb
162
164
  - webgui/app/views/users/_user_bar.html.erb
163
165
  - webgui/app/views/users/new.html.erb