summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/matches_controller.rb4
-rw-r--r--app/controllers/pms_controller.rb10
-rw-r--r--app/views/pms/_form.html.erb4
-rw-r--r--app/views/pms/index.html.erb117
-rw-r--r--app/views/pms/show.html.erb2
-rwxr-xr-xdb.sh2
-rw-r--r--db/seeds.rb50
7 files changed, 120 insertions, 69 deletions
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb
index 1ad86d0..138cf28 100644
--- a/app/controllers/matches_controller.rb
+++ b/app/controllers/matches_controller.rb
@@ -23,8 +23,8 @@ class MatchesController < ApplicationController
@match.teams.each do |team|
team.users.each do |user|
- players_id.push(user.remote_usernames[0]["json_value"]["id"])
- players.push(user.remote_usernames[0]["json_value"]["id"])
+ players_id.push(user.remote_usernames[0].value["id"])
+ players.push(user.remote_usernames[0].value["name"])
end
end
diff --git a/app/controllers/pms_controller.rb b/app/controllers/pms_controller.rb
index 1d6540d..9dbe760 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
diff --git a/app/views/pms/_form.html.erb b/app/views/pms/_form.html.erb
index e9a7c08..b329e24 100644
--- a/app/views/pms/_form.html.erb
+++ b/app/views/pms/_form.html.erb
@@ -15,6 +15,10 @@
<%= 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 %>
diff --git a/app/views/pms/index.html.erb b/app/views/pms/index.html.erb
index 1175cb2..ee31e08 100644
--- a/app/views/pms/index.html.erb
+++ b/app/views/pms/index.html.erb
@@ -1,66 +1,85 @@
-<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>
+ <td><h3>Inbox<h3></td>
</tr>
+ <tr>
+ <% conversations = current_user.mailbox.inbox %>
+ <% if !conversations.empty? %>
+ <%# require 'pp' %>
+ <%= conversations.class %>
+ <tr>
+ <td><b>From</b></td>
+ <td><b>Subject</b></td>
+ <td><b>Body</b></td>
+ </tr>
+ <% conversations.each do |conversation| %>
+ <% receipts = conversation.receipts_for current_user %>
+ <% receipts.each do |receipt| %>
+ <% message = receipt.message %>
+ <tr>
+ <td><%= conversation.last_sender.user_name %></td>
+ <td><%= message.subject %></td>
+ <td><%= message.body %></td>
+ <td><%# link_to 'Show', @pms.where(conversation: conversation) %></td>
+ </tr>
+ <% end %>
+ <% end %>
- <% 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>
+ <% else %>
+ <td><p> No Messages </p></td>
<% end %>
- <% else %>
- <td><h3>No New Messages</h3></td>
- <% end %>
+ </tr>
- <tr>
- <td><h2>Outbox<h2></td>
+ <tr>
+ <td><h3>Outbox<h3></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>
+ <tr>
+ <% conversations = current_user.mailbox.sentbox %>
+ <% if !conversations.empty? %>
+ <tr>
+ <td><b>To</b></td>
+ <td><b>Subject</b></td>
+ <td><b>Body</b></td>
+ </tr>
+ <% conversations.each do |conversation| %>
+ <% receipts = conversation.receipts_for current_user %>
+ <% receipts.each do |receipt| %>
+ <% message = receipt.message %>
+ <tr>
+ <td>Doesn't work</td>
+ <td><%= message.subject %></td>
+ <td><%= message.body %></td>
+ <td><%# link_to 'Show', @pms.where(conversation: conversation) %></td>
+ </tr>
+ <% end %>
+ <% end %>
+
+ <% else %>
+ <td><p> No Messages </p></td>
<% end %>
- <% else %>
- <td><h3>No New Messages</h3></td>
- <% end %>
+ </tr>
- <tr>
- <td><h2>Conversations<h2></td>
- </tr>
+ </tbody>
+</table>
+
+<br>
+
+<%= link_to 'New Pm', new_pm_path %>
+<h1>Conversations</h1>
+
+<table>
+ <tbody>
<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 +93,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', @pm.where(conversation: conversation) %></td>
</tr>
<% end %>
<% end %>
@@ -89,7 +108,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>
diff --git a/app/views/pms/show.html.erb b/app/views/pms/show.html.erb
index cfaf00d..aec160f 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>
diff --git a/db.sh b/db.sh
new file mode 100755
index 0000000..9d86834
--- /dev/null
+++ b/db.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+bundle exec rake db:drop && bundle exec rake db:migrate && bundle exec rake db:seed
diff --git a/db/seeds.rb b/db/seeds.rb
index 7f066bc..61cf44a 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -68,24 +68,25 @@ if Rails.env.development?
players_for_league.push(User.create(name: "Kaceytron", password: "password", email: "Kaceytron@gmail.com", user_name: "Kaceytron", password_confirmation: "password"))
#semi-real users
- User.create(name: "Davis Webb", password: "password", email: "davislwebb@gmail.com", user_name: "TeslasMind", password_confirmation: "password")
- User.create(name: "Nathaniel Foy", password: "password", email: "nfoy@notreal.com", user_name: "Nalfeinx", password_confirmation: "password")
- User.create(name: "Guntas Grewal", password: "password", email: "guntasgrewal@gmail.com", user_name: "guntasgrewal", password_confirmation: "password")
- User.create(name: "Luke Shumaker", password: "password", email: "lukeshu@emacs4lyfe.com", user_name: "lukeshu", password_confirmation: "password")
- User.create(name: "Tomer Kimia", password: "password", email: "tomer@2majors4lyfe.com", user_name: "tkimia", password_confirmation: "password")
- User.create(name: "Andrew Murrell", password: "password", email: "murrel@murrel.gov", user_name: "ImFromNasa", password_confirmation: "password")
- User.create(name: "Joseph Adams", password: "password", email: "alpha142@fluttershyop.com", user_name: "alpha142", password_confirmation: "password")
- User.create(name: "Josh Huser", password: "password", email: "jhuser@iownabusiness.net", user_name: "WinterWorks", password_confirmation: "password")
- User.create(name: "Professor Dunsmore", password: "password", email: "bxd@purdue.edu", user_name: "Dumbledore", password_confirmation: "password")
- User.create(name: "Marco Polo", password: "password", email: "marco@ta4lyfe.com", user_name: "iCoordinate", password_confirmation: "password")
- User.create(name: "Geoffrey Webb", password: "password", email: "imnotjoffreybarathian@gameofthrones.com", user_name: "GTBPhoenix", password_confirmation: "password")
- User.create(name: "Obama", password: "password", email: "obama@whitehouse.gov", user_name: "Obama", password_confirmation: "password")
+ davis = User.create(name: "Davis Webb", password: "password", email: "davislwebb@gmail.com", user_name: "TeslasMind", password_confirmation: "password")
+ foy = User.create(name: "Nathaniel Foy", password: "password", email: "nfoy@notreal.com", user_name: "Nalfeinx", password_confirmation: "password")
+ guntas = User.create(name: "Guntas Grewal", password: "password", email: "guntasgrewal@gmail.com", user_name: "guntasgrewal", password_confirmation: "password")
+ luke = User.create(name: "Luke Shumaker", password: "password", email: "lukeshu@emacs4lyfe.com", user_name: "lukeshu", password_confirmation: "password")
+ tomer = User.create(name: "Tomer Kimia", password: "password", email: "tomer@2majors4lyfe.com", user_name: "tkimia", password_confirmation: "password")
+ andrew = User.create(name: "Andrew Murrell", password: "password", email: "murrel@murrel.gov", user_name: "ImFromNasa", password_confirmation: "password")
+ joey = User.create(name: "Joseph Adams", password: "password", email: "alpha142@fluttershyop.com", user_name: "alpha142", password_confirmation: "password")
+ josh = User.create(name: "Josh Huser", password: "password", email: "jhuser@iownabusiness.net", user_name: "WinterWorks", password_confirmation: "password")
+ dunsmore = User.create(name: "Professor Dunsmore", password: "password", email: "bxd@purdue.edu", user_name: "Dumbledore", password_confirmation: "password")
+ marco = User.create(name: "Marco Polo", password: "password", email: "marco@ta4lyfe.com", user_name: "iCoordinate", password_confirmation: "password")
+ jordan = User.create(name: "Geoffrey Webb", password: "password", email: "imnotjoffreybarathian@gameofthrones.com", user_name: "GTBPhoenix", password_confirmation: "password")
+ obama = User.create(name: "Obama", password: "password", email: "obama@whitehouse.gov", user_name: "Obama", password_confirmation: "password")
#league of legends tournament
league_tourn = Tournament.create(game_id: 1, status: 0, name: "League of Legends Seed", min_players_per_team: 5, max_players_per_team: 5, min_teams_per_match: 2,
max_teams_per_match: 2, set_rounds: 1, randomized_teams: true, sampling_method: nil)
+ #adds players to the seeded league tournament
for i in 0..9
if i == 0
league_tourn.hosts.push(players_for_league[i])
@@ -95,10 +96,31 @@ if Rails.env.development?
league_tourn.join(players_for_league[9])
#chess
- Tournament.create(game_id: 2, status: 0, name: "Chess Seed", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2,
+ chess_tourn = Tournament.create(game_id: 2, status: 0, name: "Chess Seed", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2,
max_teams_per_match: 2, set_rounds: 1, randomized_teams: true, sampling_method: nil)
+ chess_tourn.hosts.push(davis)
+ chess_tourn.join(davis)
+ chess_tourn.join(foy)
+
#Rock Paper Scissors
- Tournament.create(game_id: 4, status: 0, name: "Rock, Paper, Scissors Seed", min_players_per_team: 1, max_players_per_team: 3, min_teams_per_match: 2,
+ rps = Tournament.create(game_id: 4, status: 0, name: "Rock, Paper, Scissors Seed", min_players_per_team: 1, max_players_per_team: 3, min_teams_per_match: 2,
max_teams_per_match: 2, set_rounds: 1, randomized_teams: true, sampling_method: nil)
+
+ rps.hosts.push(davis)
+ rps.join(davis)
+ rps.join(foy)
+ rps.join(guntas)
+
+ tourn5 = Tournament.create(game_id: 1, status: 0, name: "5 Teams, 2 Teams Per Match", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2,
+ max_teams_per_match: 2, set_rounds: 1, randomized_teams: true, sampling_method: nil)
+
+ for i in 0..9
+ if i == 0
+ tourn5.hosts.push(players_for_league[i])
+ end
+ tourn5.join(players_for_league[i])
+ end
+ tourn5.join(players_for_league[9])
+
end