summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-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
9 files changed, 42 insertions, 77 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>