summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/assets/stylesheets/matches.css.scss11
-rw-r--r--app/controllers/pms_controller.rb12
-rw-r--r--app/models/pm.rb1
-rw-r--r--app/views/pms/_form.html.erb12
-rw-r--r--app/views/pms/index.html.erb65
-rw-r--r--app/views/pms/index.json.jbuilder2
-rw-r--r--app/views/pms/show.html.erb13
-rw-r--r--app/views/pms/show.json.jbuilder2
-rw-r--r--app/views/tournaments/show.html.erb1
-rw-r--r--db/migrate/20140424190540_create_simple_captcha_data.rb (renamed from db/migrate/20140424162546_create_simple_captcha_data.rb)0
-rw-r--r--db/migrate/20140424230536_create_mailboxer.mailboxer_engine.rb (renamed from db/migrate/20140424202542_create_mailboxer.mailboxer_engine.rb)0
-rw-r--r--db/migrate/20140424230537_add_notified_object.mailboxer_engine.rb (renamed from db/migrate/20140424202543_add_notified_object.mailboxer_engine.rb)0
-rw-r--r--db/migrate/20140424230538_add_notification_code.mailboxer_engine.rb (renamed from db/migrate/20140424202544_add_notification_code.mailboxer_engine.rb)0
-rw-r--r--db/migrate/20140424230539_add_attachments.mailboxer_engine.rb (renamed from db/migrate/20140424202545_add_attachments.mailboxer_engine.rb)0
-rw-r--r--db/migrate/20140424230540_rename_receipts_read.mailboxer_engine.rb (renamed from db/migrate/20140424202546_rename_receipts_read.mailboxer_engine.rb)0
-rw-r--r--db/migrate/20140424230541_add_global_notification_support.mailboxer_engine.rb (renamed from db/migrate/20140424202547_add_global_notification_support.mailboxer_engine.rb)0
-rw-r--r--db/migrate/20140424230543_create_delayed_jobs.rb (renamed from db/migrate/20140424202549_create_delayed_jobs.rb)0
-rw-r--r--db/migrate/20140424230547_create_servers.rb (renamed from db/migrate/20140424202553_create_servers.rb)0
-rw-r--r--db/migrate/20140424230550_create_matches.rb (renamed from db/migrate/20140424202557_create_matches.rb)0
-rw-r--r--db/migrate/20140424230554_create_teams.rb (renamed from db/migrate/20140424202600_create_teams.rb)0
-rw-r--r--db/migrate/20140424230558_create_alerts.rb (renamed from db/migrate/20140424202604_create_alerts.rb)0
-rw-r--r--db/migrate/20140424230602_create_pms.rb (renamed from db/migrate/20140424202608_create_pms.rb)2
-rw-r--r--db/migrate/20140424230605_create_tournaments.rb (renamed from db/migrate/20140424202611_create_tournaments.rb)0
-rw-r--r--db/migrate/20140424230609_create_games.rb (renamed from db/migrate/20140424202615_create_games.rb)0
-rw-r--r--db/migrate/20140424230613_create_users.rb (renamed from db/migrate/20140424202619_create_users.rb)0
-rw-r--r--db/migrate/20140424230617_create_sessions.rb (renamed from db/migrate/20140424202623_create_sessions.rb)0
-rw-r--r--db/migrate/20140424230620_create_brackets.rb (renamed from db/migrate/20140424202626_create_brackets.rb)0
-rw-r--r--db/migrate/20140424230624_create_game_settings.rb (renamed from db/migrate/20140424202630_create_game_settings.rb)0
-rw-r--r--db/migrate/20140424230628_create_tournament_settings.rb (renamed from db/migrate/20140424202634_create_tournament_settings.rb)0
-rw-r--r--db/migrate/20140424230632_create_tournament_stages.rb (renamed from db/migrate/20140424202638_create_tournament_stages.rb)0
-rw-r--r--db/migrate/20140424230635_create_statistics.rb (renamed from db/migrate/20140424202641_create_statistics.rb)0
-rw-r--r--db/migrate/20140424230639_create_remote_usernames.rb (renamed from db/migrate/20140424202645_create_remote_usernames.rb)0
-rw-r--r--db/migrate/20140424230643_create_bracket_matches.rb (renamed from db/migrate/20140424202649_create_bracket_matches.rb)0
-rw-r--r--db/migrate/20140424230646_create_api_requests.rb (renamed from db/migrate/20140424202652_create_api_requests.rb)0
-rw-r--r--db/migrate/20140424230650_create_tournament_players_join_table.rb (renamed from db/migrate/20140424202656_create_tournament_players_join_table.rb)0
-rw-r--r--db/migrate/20140424230654_create_tournament_hosts_join_table.rb (renamed from db/migrate/20140424202659_create_tournament_hosts_join_table.rb)0
-rw-r--r--db/migrate/20140424230657_create_team_user_join_table.rb (renamed from db/migrate/20140424202703_create_team_user_join_table.rb)0
-rw-r--r--db/migrate/20140424230701_create_match_team_join_table.rb (renamed from db/migrate/20140424202706_create_match_team_join_table.rb)0
-rw-r--r--db/migrate/20140424230712_add_hidden_attrs_to_user.rb (renamed from db/migrate/20140424202717_add_hidden_attrs_to_user.rb)0
-rw-r--r--db/schema.rb5
-rwxr-xr-xgenerate.sh2
-rw-r--r--lib/scheduling/elimination.rb18
-rw-r--r--test/controllers/pms_controller_test.rb4
-rw-r--r--test/fixtures/pms.yml4
44 files changed, 66 insertions, 88 deletions
diff --git a/app/assets/stylesheets/matches.css.scss b/app/assets/stylesheets/matches.css.scss
index ee43ab4..64d0ca9 100644
--- a/app/assets/stylesheets/matches.css.scss
+++ b/app/assets/stylesheets/matches.css.scss
@@ -56,14 +56,3 @@
svg {
min-width: 600px;
}
-
-@media (max-width: 900px) {
- svg text {
- font-size: 200%;
- }
-}
-@media (max-width: 700px) {
- svg text {
- font-size: 150%;
- }
-} \ No newline at end of file
diff --git a/app/controllers/pms_controller.rb b/app/controllers/pms_controller.rb
index 1d6540d..c83d2ae 100644
--- a/app/controllers/pms_controller.rb
+++ b/app/controllers/pms_controller.rb
@@ -24,11 +24,11 @@ class PmsController < ApplicationController
def create
@pm = Pm.new(pm_params)
@pm.author = current_user
- require 'pp'
- pp @pm.message
+ #require 'pp'
+ #pp @pm.message
@pm.recipient = User.find_by_user_name(pm_params['recipient_id'])
- @pm.author.send_message(@pm.recipient, @pm.message, 'Default')
+ @pm.conversation = @pm.author.send_message(@pm.recipient, @pm.message, @pm.subject).conversation
respond_to do |format|
if @pm.save
@@ -41,6 +41,10 @@ class PmsController < ApplicationController
end
end
+ #def reply
+ # current_user.reply_to_conversation(conversation, message)
+ #end
+
# PATCH/PUT /pms/1
# PATCH/PUT /pms/1.json
def update
@@ -73,6 +77,6 @@ class PmsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def pm_params
- params.require(:pm).permit(:author_id, :recipient_id, :message)
+ params.require(:pm).permit(:author_id, :recipient_id, :message, :subject, :conversation_id)
end
end
diff --git a/app/models/pm.rb b/app/models/pm.rb
index 3ebb69d..8b06181 100644
--- a/app/models/pm.rb
+++ b/app/models/pm.rb
@@ -1,6 +1,7 @@
class Pm < ActiveRecord::Base
belongs_to :author, class_name: "User"
belongs_to :recipient, class_name: "User"
+ belongs_to :conversation
def name
return current_user.name
diff --git a/app/views/pms/_form.html.erb b/app/views/pms/_form.html.erb
index e9a7c08..a885e27 100644
--- a/app/views/pms/_form.html.erb
+++ b/app/views/pms/_form.html.erb
@@ -15,10 +15,22 @@
<%= f.label :recipient_id %><br>
<%= f.text_field :recipient_id %>
</div>
+ <div class="field">
+ <%= f.label :subject %><br>
+ <%= f.text_field :subject %>
+ </div>
<div class="field">
<%= f.label :message %><br>
<%= f.text_area :message %>
</div>
+ <div class="field">
+ <%= f.label :subject %><br>
+ <%= f.text_area :subject %>
+ </div>
+ <div class="field">
+ <%= f.label :conversation_id %><br>
+ <%= f.text_field :conversation_id %>
+ </div>
<div class="actions">
<%= f.submit %>
</div>
diff --git a/app/views/pms/index.html.erb b/app/views/pms/index.html.erb
index 1175cb2..b5f4884 100644
--- a/app/views/pms/index.html.erb
+++ b/app/views/pms/index.html.erb
@@ -1,66 +1,15 @@
-<h1>Listing pms</h1>
+<h1>Conversations</h1>
<table>
- <thead>
- <tr>
- <th>Author</th>
- <th>Recipient</th>
- <th>Message</th>
- <th></th>
- <th></th>
- <th></th>
- </tr>
- </thead>
-
<tbody>
-
- <tr>
- <td><h2>Inbox<h2></td>
- </tr>
-
- <% message = @pms.where(recipient: current_user) %>
- <% unless message.empty? then message.each do |pm| %>
- <tr>
- <td><%= pm.author.user_name %></td>
- <td><%= pm.recipient.user_name %></td>
- <td><%= pm.message %></td>
- <td><%= link_to 'Show', pm %></td>
- <td><%# link_to 'Edit', edit_pm_path(pm) %></td>
- <td><%= link_to 'Delete', pm, method: :delete, data: { confirm: 'Are you sure (also deletes the author\'s copy)?' } %></td>
- </tr>
- <% end %>
- <% else %>
- <td><h3>No New Messages</h3></td>
- <% end %>
-
- <tr>
- <td><h2>Outbox<h2></td>
- </tr>
-
- <% message = @pms.where(author: current_user) %>
- <% unless message.empty? then message.each do |pm| %>
- <tr>
- <td><%= pm.author.user_name %></td>
- <td><%= pm.recipient.user_name %></td>
- <td><%= pm.message %></td>
- <td><%= link_to 'Show', pm %></td>
- <td><%# link_to 'Edit', edit_pm_path(pm) %></td>
- <td><%= link_to 'Delete', pm, method: :delete, data: { confirm: 'Are you sure (also deletes the recipient\'s copy)?'} %></td>
- </tr>
- <% end %>
- <% else %>
- <td><h3>No New Messages</h3></td>
- <% end %>
-
- <tr>
- <td><h2>Conversations<h2></td>
- </tr>
<tr>
<td><h3>Inbox<h3></td>
</tr>
<tr>
<% conversations = current_user.mailbox.inbox %>
- <% if !conversations.nil? %>
+ <% if !conversations.empty? %>
+ <%# require 'pp' %>
+ <%= conversations.class %>
<tr>
<td><b>From</b></td>
<td><b>Subject</b></td>
@@ -74,7 +23,7 @@
<td><%= conversation.last_sender.user_name %></td>
<td><%= message.subject %></td>
<td><%= message.body %></td>
- <td><%# link_to 'Show', pm %></td>
+ <td><%# link_to 'Show', @pms.where(conversation: conversation) %></td>
</tr>
<% end %>
<% end %>
@@ -89,7 +38,7 @@
</tr>
<tr>
<% conversations = current_user.mailbox.sentbox %>
- <% if !conversations.nil? %>
+ <% if !conversations.empty? %>
<tr>
<td><b>To</b></td>
<td><b>Subject</b></td>
@@ -103,7 +52,7 @@
<td>Doesn't work</td>
<td><%= message.subject %></td>
<td><%= message.body %></td>
- <td><%# link_to 'Show', conversation %></td>
+ <td><%# link_to 'Show', @pms.where(conversation: conversation) %></td>
</tr>
<% end %>
<% end %>
diff --git a/app/views/pms/index.json.jbuilder b/app/views/pms/index.json.jbuilder
index fcfca84..3dc1abb 100644
--- a/app/views/pms/index.json.jbuilder
+++ b/app/views/pms/index.json.jbuilder
@@ -1,4 +1,4 @@
json.array!(@pms) do |pm|
- json.extract! pm, :id, :author_id, :recipient_id, :message
+ json.extract! pm, :id, :author_id, :recipient_id, :message, :subject, :conversation_id
json.url pm_url(pm, format: :json)
end
diff --git a/app/views/pms/show.html.erb b/app/views/pms/show.html.erb
index cfaf00d..6f81d1b 100644
--- a/app/views/pms/show.html.erb
+++ b/app/views/pms/show.html.erb
@@ -1,6 +1,6 @@
<p>
<strong>Author:</strong>
- <%= @conversation.last_sender.user_name %>
+ <%# @conversation.last_sender.user_name %>
</p>
<p>
@@ -13,5 +13,14 @@
<%# @pm.message %>
</p>
-<%# link_to 'Edit', edit_pm_path(@pm) %> |
+<p>
+ <strong>Subject:</strong>
+ <%= @pm.subject %>
+</p>
+
+<p>
+ <strong>Conversation:</strong>
+ <%= @pm.conversation %>
+</p>
+
<%= link_to 'Back', pms_path %>
diff --git a/app/views/pms/show.json.jbuilder b/app/views/pms/show.json.jbuilder
index 94252e9..4e69026 100644
--- a/app/views/pms/show.json.jbuilder
+++ b/app/views/pms/show.json.jbuilder
@@ -1 +1 @@
-json.extract! @pm, :id, :author_id, :recipient_id, :message, :created_at, :updated_at
+json.extract! @pm, :id, :author_id, :recipient_id, :message, :subject, :conversation_id, :created_at, :updated_at
diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb
index a5eb46c..f79b975 100644
--- a/app/views/tournaments/show.html.erb
+++ b/app/views/tournaments/show.html.erb
@@ -113,3 +113,4 @@
<%end %>
</div>
+</div>
diff --git a/db/migrate/20140424162546_create_simple_captcha_data.rb b/db/migrate/20140424190540_create_simple_captcha_data.rb
index 4573b20..4573b20 100644
--- a/db/migrate/20140424162546_create_simple_captcha_data.rb
+++ b/db/migrate/20140424190540_create_simple_captcha_data.rb
diff --git a/db/migrate/20140424202542_create_mailboxer.mailboxer_engine.rb b/db/migrate/20140424230536_create_mailboxer.mailboxer_engine.rb
index 690cec2..690cec2 100644
--- a/db/migrate/20140424202542_create_mailboxer.mailboxer_engine.rb
+++ b/db/migrate/20140424230536_create_mailboxer.mailboxer_engine.rb
diff --git a/db/migrate/20140424202543_add_notified_object.mailboxer_engine.rb b/db/migrate/20140424230537_add_notified_object.mailboxer_engine.rb
index 7f41ac6..7f41ac6 100644
--- a/db/migrate/20140424202543_add_notified_object.mailboxer_engine.rb
+++ b/db/migrate/20140424230537_add_notified_object.mailboxer_engine.rb
diff --git a/db/migrate/20140424202544_add_notification_code.mailboxer_engine.rb b/db/migrate/20140424230538_add_notification_code.mailboxer_engine.rb
index 04c12ef..04c12ef 100644
--- a/db/migrate/20140424202544_add_notification_code.mailboxer_engine.rb
+++ b/db/migrate/20140424230538_add_notification_code.mailboxer_engine.rb
diff --git a/db/migrate/20140424202545_add_attachments.mailboxer_engine.rb b/db/migrate/20140424230539_add_attachments.mailboxer_engine.rb
index b8d6588..b8d6588 100644
--- a/db/migrate/20140424202545_add_attachments.mailboxer_engine.rb
+++ b/db/migrate/20140424230539_add_attachments.mailboxer_engine.rb
diff --git a/db/migrate/20140424202546_rename_receipts_read.mailboxer_engine.rb b/db/migrate/20140424230540_rename_receipts_read.mailboxer_engine.rb
index 9ce904f..9ce904f 100644
--- a/db/migrate/20140424202546_rename_receipts_read.mailboxer_engine.rb
+++ b/db/migrate/20140424230540_rename_receipts_read.mailboxer_engine.rb
diff --git a/db/migrate/20140424202547_add_global_notification_support.mailboxer_engine.rb b/db/migrate/20140424230541_add_global_notification_support.mailboxer_engine.rb
index 60f67ab..60f67ab 100644
--- a/db/migrate/20140424202547_add_global_notification_support.mailboxer_engine.rb
+++ b/db/migrate/20140424230541_add_global_notification_support.mailboxer_engine.rb
diff --git a/db/migrate/20140424202549_create_delayed_jobs.rb b/db/migrate/20140424230543_create_delayed_jobs.rb
index ec0dd93..ec0dd93 100644
--- a/db/migrate/20140424202549_create_delayed_jobs.rb
+++ b/db/migrate/20140424230543_create_delayed_jobs.rb
diff --git a/db/migrate/20140424202553_create_servers.rb b/db/migrate/20140424230547_create_servers.rb
index fbe1b02..fbe1b02 100644
--- a/db/migrate/20140424202553_create_servers.rb
+++ b/db/migrate/20140424230547_create_servers.rb
diff --git a/db/migrate/20140424202557_create_matches.rb b/db/migrate/20140424230550_create_matches.rb
index bac92d1..bac92d1 100644
--- a/db/migrate/20140424202557_create_matches.rb
+++ b/db/migrate/20140424230550_create_matches.rb
diff --git a/db/migrate/20140424202600_create_teams.rb b/db/migrate/20140424230554_create_teams.rb
index dd8397d..dd8397d 100644
--- a/db/migrate/20140424202600_create_teams.rb
+++ b/db/migrate/20140424230554_create_teams.rb
diff --git a/db/migrate/20140424202604_create_alerts.rb b/db/migrate/20140424230558_create_alerts.rb
index 68a8e10..68a8e10 100644
--- a/db/migrate/20140424202604_create_alerts.rb
+++ b/db/migrate/20140424230558_create_alerts.rb
diff --git a/db/migrate/20140424202608_create_pms.rb b/db/migrate/20140424230602_create_pms.rb
index 93bb5c6..eb9f443 100644
--- a/db/migrate/20140424202608_create_pms.rb
+++ b/db/migrate/20140424230602_create_pms.rb
@@ -4,6 +4,8 @@ class CreatePms < ActiveRecord::Migration
t.references :author, index: true
t.references :recipient, index: true
t.text :message
+ t.text :subject
+ t.references :conversation, index: true
t.timestamps
end
diff --git a/db/migrate/20140424202611_create_tournaments.rb b/db/migrate/20140424230605_create_tournaments.rb
index 716871f..716871f 100644
--- a/db/migrate/20140424202611_create_tournaments.rb
+++ b/db/migrate/20140424230605_create_tournaments.rb
diff --git a/db/migrate/20140424202615_create_games.rb b/db/migrate/20140424230609_create_games.rb
index 23edf0b..23edf0b 100644
--- a/db/migrate/20140424202615_create_games.rb
+++ b/db/migrate/20140424230609_create_games.rb
diff --git a/db/migrate/20140424202619_create_users.rb b/db/migrate/20140424230613_create_users.rb
index 8032870..8032870 100644
--- a/db/migrate/20140424202619_create_users.rb
+++ b/db/migrate/20140424230613_create_users.rb
diff --git a/db/migrate/20140424202623_create_sessions.rb b/db/migrate/20140424230617_create_sessions.rb
index f667f1e..f667f1e 100644
--- a/db/migrate/20140424202623_create_sessions.rb
+++ b/db/migrate/20140424230617_create_sessions.rb
diff --git a/db/migrate/20140424202626_create_brackets.rb b/db/migrate/20140424230620_create_brackets.rb
index 8813bf2..8813bf2 100644
--- a/db/migrate/20140424202626_create_brackets.rb
+++ b/db/migrate/20140424230620_create_brackets.rb
diff --git a/db/migrate/20140424202630_create_game_settings.rb b/db/migrate/20140424230624_create_game_settings.rb
index 06fb72e..06fb72e 100644
--- a/db/migrate/20140424202630_create_game_settings.rb
+++ b/db/migrate/20140424230624_create_game_settings.rb
diff --git a/db/migrate/20140424202634_create_tournament_settings.rb b/db/migrate/20140424230628_create_tournament_settings.rb
index e56697f..e56697f 100644
--- a/db/migrate/20140424202634_create_tournament_settings.rb
+++ b/db/migrate/20140424230628_create_tournament_settings.rb
diff --git a/db/migrate/20140424202638_create_tournament_stages.rb b/db/migrate/20140424230632_create_tournament_stages.rb
index e3668cb..e3668cb 100644
--- a/db/migrate/20140424202638_create_tournament_stages.rb
+++ b/db/migrate/20140424230632_create_tournament_stages.rb
diff --git a/db/migrate/20140424202641_create_statistics.rb b/db/migrate/20140424230635_create_statistics.rb
index cc2e97d..cc2e97d 100644
--- a/db/migrate/20140424202641_create_statistics.rb
+++ b/db/migrate/20140424230635_create_statistics.rb
diff --git a/db/migrate/20140424202645_create_remote_usernames.rb b/db/migrate/20140424230639_create_remote_usernames.rb
index e265985..e265985 100644
--- a/db/migrate/20140424202645_create_remote_usernames.rb
+++ b/db/migrate/20140424230639_create_remote_usernames.rb
diff --git a/db/migrate/20140424202649_create_bracket_matches.rb b/db/migrate/20140424230643_create_bracket_matches.rb
index 3323e31..3323e31 100644
--- a/db/migrate/20140424202649_create_bracket_matches.rb
+++ b/db/migrate/20140424230643_create_bracket_matches.rb
diff --git a/db/migrate/20140424202652_create_api_requests.rb b/db/migrate/20140424230646_create_api_requests.rb
index 544c330..544c330 100644
--- a/db/migrate/20140424202652_create_api_requests.rb
+++ b/db/migrate/20140424230646_create_api_requests.rb
diff --git a/db/migrate/20140424202656_create_tournament_players_join_table.rb b/db/migrate/20140424230650_create_tournament_players_join_table.rb
index be240e8..be240e8 100644
--- a/db/migrate/20140424202656_create_tournament_players_join_table.rb
+++ b/db/migrate/20140424230650_create_tournament_players_join_table.rb
diff --git a/db/migrate/20140424202659_create_tournament_hosts_join_table.rb b/db/migrate/20140424230654_create_tournament_hosts_join_table.rb
index 7521d89..7521d89 100644
--- a/db/migrate/20140424202659_create_tournament_hosts_join_table.rb
+++ b/db/migrate/20140424230654_create_tournament_hosts_join_table.rb
diff --git a/db/migrate/20140424202703_create_team_user_join_table.rb b/db/migrate/20140424230657_create_team_user_join_table.rb
index f3b57fc..f3b57fc 100644
--- a/db/migrate/20140424202703_create_team_user_join_table.rb
+++ b/db/migrate/20140424230657_create_team_user_join_table.rb
diff --git a/db/migrate/20140424202706_create_match_team_join_table.rb b/db/migrate/20140424230701_create_match_team_join_table.rb
index c2ed1b7..c2ed1b7 100644
--- a/db/migrate/20140424202706_create_match_team_join_table.rb
+++ b/db/migrate/20140424230701_create_match_team_join_table.rb
diff --git a/db/migrate/20140424202717_add_hidden_attrs_to_user.rb b/db/migrate/20140424230712_add_hidden_attrs_to_user.rb
index 9b5c505..9b5c505 100644
--- a/db/migrate/20140424202717_add_hidden_attrs_to_user.rb
+++ b/db/migrate/20140424230712_add_hidden_attrs_to_user.rb
diff --git a/db/schema.rb b/db/schema.rb
index 0833263..d7e4efd 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20140424202717) do
+ActiveRecord::Schema.define(version: 20140424230712) do
create_table "alerts", force: true do |t|
t.integer "author_id"
@@ -156,11 +156,14 @@ ActiveRecord::Schema.define(version: 20140424202717) do
t.integer "author_id"
t.integer "recipient_id"
t.text "message"
+ t.text "subject"
+ t.integer "conversation_id"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "pms", ["author_id"], name: "index_pms_on_author_id"
+ add_index "pms", ["conversation_id"], name: "index_pms_on_conversation_id"
add_index "pms", ["recipient_id"], name: "index_pms_on_recipient_id"
create_table "receipts", force: true do |t|
diff --git a/generate.sh b/generate.sh
index be2e1a1..a81c0b3 100755
--- a/generate.sh
+++ b/generate.sh
@@ -43,7 +43,7 @@ bundle exec rails generate scaffold server default_user_permissions:integer
bundle exec rails generate scaffold match status:integer tournament_stage:references winner:references remote_id:text submitted_peer_evaluations:integer
bundle exec rails generate scaffold team
bundle exec rails generate scaffold alert author:references message:text
-bundle exec rails generate scaffold pm author:references recipient:references message:text
+bundle exec rails generate scaffold pm author:references recipient:references message:text subject:text conversation:references
bundle exec rails generate scaffold tournament game:references status:integer name:string:uniq min_players_per_team:integer max_players_per_team:integer min_teams_per_match:integer max_teams_per_match:integer set_rounds:integer randomized_teams:boolean sampling_method:string
bundle exec rails generate scaffold game parent:references name:string:uniq min_players_per_team:integer max_players_per_team:integer min_teams_per_match:integer max_teams_per_match:integer set_rounds:integer randomized_teams:boolean sampling_method:string
bundle exec rails generate scaffold user name:string email:string:uniq user_name:string:uniq
diff --git a/lib/scheduling/elimination.rb b/lib/scheduling/elimination.rb
index cf0d625..0e93f7a 100644
--- a/lib/scheduling/elimination.rb
+++ b/lib/scheduling/elimination.rb
@@ -61,11 +61,6 @@ module Scheduling
matchHeight = 50*logBase;
height = [(matchHeight+50) * logBase**(depth-1) + 100, 500].max;
- lastrx = 0
- lastry = 0
- lastrh = 0
- lastrw = 0
-
str = <<-STRING
<svg version="1.1" baseProfile="full"
xmlns="http://www.w3.org/2000/svg"
@@ -80,11 +75,20 @@ module Scheduling
STRING
(1..matches.count).each do |i|
matchDepth = Math.log(i*(logBase-1), logBase).floor+1
+ puts matchDepth
base = (logBase**(matchDepth-1)/(logBase-1)).ceil
+ if base == 0
+ base = 1
+ end
+ puts base
rh = 100 / (logBase**(depth-1)+1) - 100/height;
+ puts rh
rw = 100/(depth+1) - 5
+ puts rw
rx = 50/(depth+1) + 100/(depth+1)*(depth-matchDepth)
+ puts rx
ry = 100/(logBase**(matchDepth-1)+1) * (i-base+1) - rh/2
+ puts ry
str += "\t<a id=\"svg-match-#{i}\" xlink:href=\"#{match_path(matches[i])}\"><g>\n"
str += "\t\t<rect height=\"#{rh}%\" width=\"#{rw}%\" x=\"#{rx}%\" y=\"#{ry}%\" fill=\"url(#gradMatch)\" rx=\"5px\" stroke-width=\"2\""
@@ -111,10 +115,10 @@ STRING
color = (matches[i].teams[t-1] and matches[i].teams[t-1].users.include?(current_user)) ? "#5BC0DE" : "white"
str += "\t\t<rect width=\"#{rw-5}%\" height=\"#{rh*Float(30)/(matchHeight)}%\" x=\"#{rx + 2.5}%\" y=\"#{ry + (Float(t-1)/numTeams)*rh + 2 }%\" fill=\"#{color}\" />\n"
if matches[i].teams[t-1]
- str += "\t\t<text x=\"#{rx + rw/4}%\" y=\"#{ry + (Float(t-1)/numTeams + Float(30)/(matchHeight))*rh}%\" font-size=\"#{rh}\">Team #{matches[i].teams[t-1].id}</text>\n"
+ str += "\t\t<text x=\"#{rx + rw/4}%\" y=\"#{ry + (Float(t-1)/numTeams + Float(30)/(matchHeight))*rh}%\" font-size=\"200%\">Team #{matches[i].teams[t-1].id}</text>\n"
end
if (t < numTeams)
- str += "\t\t<text x=\"#{rx + 1.3*rw/3}%\" y=\"#{ry + (Float(20+35*(t))/matchHeight)*rh}%\" font-size=\"#{rh}\"> VS </text>\n"
+ str += "\t\t<text x=\"#{rx + 1.3*rw/3}%\" y=\"#{ry + (Float(t)/numTeams)*rh + 1}%\" font-size=\"200%\"> VS </text>\n"
end
t = t + 1
end
diff --git a/test/controllers/pms_controller_test.rb b/test/controllers/pms_controller_test.rb
index 18b2449..2a2c1ce 100644
--- a/test/controllers/pms_controller_test.rb
+++ b/test/controllers/pms_controller_test.rb
@@ -18,7 +18,7 @@ class PmsControllerTest < ActionController::TestCase
test "should create pm" do
assert_difference('Pm.count') do
- post :create, pm: { author_id: @pm.author_id, message: @pm.message, recipient_id: @pm.recipient_id }
+ post :create, pm: { author_id: @pm.author_id, conversation_id: @pm.conversation_id, message: @pm.message, recipient_id: @pm.recipient_id, subject: @pm.subject }
end
assert_redirected_to pm_path(assigns(:pm))
@@ -35,7 +35,7 @@ class PmsControllerTest < ActionController::TestCase
end
test "should update pm" do
- patch :update, id: @pm, pm: { author_id: @pm.author_id, message: @pm.message, recipient_id: @pm.recipient_id }
+ patch :update, id: @pm, pm: { author_id: @pm.author_id, conversation_id: @pm.conversation_id, message: @pm.message, recipient_id: @pm.recipient_id, subject: @pm.subject }
assert_redirected_to pm_path(assigns(:pm))
end
diff --git a/test/fixtures/pms.yml b/test/fixtures/pms.yml
index f77e727..ba31b86 100644
--- a/test/fixtures/pms.yml
+++ b/test/fixtures/pms.yml
@@ -4,8 +4,12 @@ one:
author_id:
recipient_id:
message: MyText
+ subject: MyText
+ conversation_id:
two:
author_id:
recipient_id:
message: MyText
+ subject: MyText
+ conversation_id: