diff --git a/app/assets/stylesheets/themes/default/components/_gather.scss b/app/assets/stylesheets/themes/default/components/_gather.scss
index 5238713..ae2bdba 100644
--- a/app/assets/stylesheets/themes/default/components/_gather.scss
+++ b/app/assets/stylesheets/themes/default/components/_gather.scss
@@ -202,3 +202,11 @@ table.gathers {
ul.gatherers {
@include span-columns(12);
}
+
+ul#gatherers {
+ li.away a {
+ font-style: italic;
+ font-weight: normal;
+ color: #5b5b5b;
+ }
+}
diff --git a/app/controllers/gatherers_controller.rb b/app/controllers/gatherers_controller.rb
index 6a45076..488b403 100644
--- a/app/controllers/gatherers_controller.rb
+++ b/app/controllers/gatherers_controller.rb
@@ -32,6 +32,22 @@ class GatherersController < ApplicationController
redirect_to_back
end
+ def status
+ raise AccessError unless @gatherer.can_destroy? cuser
+
+ states = {
+ "leaving" => Gatherer::STATE_LEAVING,
+ "away" => Gatherer::STATE_AWAY,
+ "active" => Gatherer::STATE_ACTIVE,
+ }
+
+ if states.has_key?(params[:status])
+ @gatherer.update_attribute(:status, states[params[:status]])
+ end
+
+ render :nothing => true, :status => 200
+ end
+
def destroy
raise AccessError unless @gatherer.can_destroy? cuser
diff --git a/app/controllers/gathers_controller.rb b/app/controllers/gathers_controller.rb
index 79acc85..d8f4a87 100644
--- a/app/controllers/gathers_controller.rb
+++ b/app/controllers/gathers_controller.rb
@@ -72,5 +72,24 @@ class GathersController < ApplicationController
end
@gatherer = @gather.gatherers.of_user(cuser).first if cuser
+ update_gatherers
+ end
+
+ def update_gatherers
+ # Update user that has left and came back
+ if @gatherer and @gatherer.status == Gatherer::STATE_LEAVING
+ @gatherer.update_attribute(:status, Gatherer::STATE_ACTIVE)
+ end
+
+ # Remove any users that left over 30 seconds ago
+ removed_users = false
+ @gather.gatherers.each do |gatherer|
+ if gatherer.status == Gatherer::STATE_LEAVING and gatherer.updated_at < Time.now - 30
+ removed_users = true
+ gatherer.destroy
+ end
+ end
+
+ @gather.reload if removed_users
end
end
diff --git a/app/models/gatherer.rb b/app/models/gatherer.rb
index 06bf570..0b49f1b 100644
--- a/app/models/gatherer.rb
+++ b/app/models/gatherer.rb
@@ -15,6 +15,10 @@ class Gatherer < ActiveRecord::Base
IDLE_TIME = 600
EJECT_VOTES = 4
+ STATE_ACTIVE = 0
+ STATE_AWAY = 1
+ STATE_LEAVING = 2
+
include Extra
attr_protected :id
diff --git a/app/views/gathers/_running.html.erb b/app/views/gathers/_running.html.erb
index dba8a21..de2d68f 100644
--- a/app/views/gathers/_running.html.erb
+++ b/app/views/gathers/_running.html.erb
@@ -6,7 +6,7 @@
<% @gather.gatherers.each do |gatherer| %>
- -
+
- 0 %> class="away"<% end %>>
<%= flag gatherer.user.country %>
<%= namelink gatherer.user %>
<% if cuser and cuser.admin? %>
diff --git a/app/views/gathers/show.html.erb b/app/views/gathers/show.html.erb
index 958f0a8..509c9d1 100644
--- a/app/views/gathers/show.html.erb
+++ b/app/views/gathers/show.html.erb
@@ -1,6 +1,25 @@
@@ -46,7 +98,7 @@
<%= link_to @gather do %>
<%= @gather.category.to_s %> Gather
- <% end %>
+ <% end %>
diff --git a/config/routes.rb b/config/routes.rb
index 7cf11e2..5f247e1 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -100,7 +100,9 @@ Ensl::Application.routes.draw do
match 'gathers/refresh'
match 'gathers/latest/:game', to: "gathers#latest", via: :get
- match 'gather', to: "gathers#latest", game: "ns2", via: :get
+ match 'gather', to: "gathers#latest", game: "ns2", via: :get
+
+ match 'gatherers/:id/status', to: "gatherers#status", via: :post
match 'groups/addUser'
match 'groups/delUser'
diff --git a/db/migrate/20141010193221_add_status_to_gatherer.rb b/db/migrate/20141010193221_add_status_to_gatherer.rb
new file mode 100644
index 0000000..a3e3205
--- /dev/null
+++ b/db/migrate/20141010193221_add_status_to_gatherer.rb
@@ -0,0 +1,5 @@
+class AddStatusToGatherer < ActiveRecord::Migration
+ def change
+ add_column :gatherers, :status, :int, null: false, default: 0
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index f58c688..0839005 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20140810224606) do
+ActiveRecord::Schema.define(:version => 20141010193221) do
create_table "admin_requests", :force => true do |t|
t.string "addr"
@@ -294,6 +294,7 @@ ActiveRecord::Schema.define(:version => 20140810224606) do
t.datetime "created_at"
t.datetime "updated_at"
t.integer "votes", :default => 0, :null => false
+ t.integer "status", :default => 0, :null => false
end
add_index "gatherers", ["gather_id"], :name => "index_gatherers_on_gather_id"
@@ -758,18 +759,6 @@ ActiveRecord::Schema.define(:version => 20140810224606) do
add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
- create_table "shoutmsg_archive", :force => true do |t|
- t.integer "user_id"
- t.string "text"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.string "shoutable_type"
- t.integer "shoutable_id"
- end
-
- add_index "shoutmsg_archive", ["shoutable_type", "shoutable_id"], :name => "index_shoutmsgs_on_shoutable_type_and_shoutable_id"
- add_index "shoutmsg_archive", ["user_id"], :name => "index_shoutmsgs_on_user_id"
-
create_table "shoutmsgs", :force => true do |t|
t.integer "user_id"
t.string "text"