mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-01-13 05:10:59 +00:00
Fix gathers
This commit is contained in:
parent
b24d2e987d
commit
2e6453dc6e
4 changed files with 18 additions and 11 deletions
|
@ -46,6 +46,7 @@ class GathersController < ApplicationController
|
|||
redirect_to @gather
|
||||
end
|
||||
|
||||
# FIXME: Use gatherers.update
|
||||
def pick
|
||||
@gatherer = @gather.gatherers.find(params[:player])
|
||||
raise AccessError unless @gatherer.can_update? cuser, params
|
||||
|
|
|
@ -30,7 +30,7 @@ class Gatherer < ActiveRecord::Base
|
|||
|
||||
#attr_protected :id
|
||||
attr_accessor :confirm, :username
|
||||
cattr_accessor :skip_callbacks
|
||||
attr_accessor :skip_callbacks
|
||||
|
||||
scope :team, -> (team) { where(team: team) }
|
||||
scope :of_user, -> (user) { where(user_id: user.id) }
|
||||
|
@ -83,7 +83,7 @@ class Gatherer < ActiveRecord::Base
|
|||
|
||||
def validate_username
|
||||
if username
|
||||
if u = User.where(username: username).exists?
|
||||
if (u = User.where(username: username).first)
|
||||
self.user = u
|
||||
else
|
||||
errors.add(:username, t(:gatherer_wrong_username))
|
||||
|
@ -171,6 +171,6 @@ class Gatherer < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.params(params, cuser)
|
||||
params.require(:gatherer).permit(:status, :user_id, :gather_id, :team, :votes)
|
||||
params.require(:gatherer).permit(:status, :username, :user_id, :gather_id, :team, :votes)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<%= if team.nil? then "Lobby" else team == 1 ? "Marines" : "Aliens" end %>
|
||||
</h4>
|
||||
|
||||
<%= form_tag "/gathers/pick/#{@gather.id}" do %>
|
||||
<%= form_tag pick_gather_path(@gather) do %>
|
||||
<ul class="gatherers">
|
||||
<% @gather.gatherers.ordered.team(team).each do |gatherer| %>
|
||||
<li>
|
||||
|
|
|
@ -41,7 +41,19 @@ Ensl::Application.routes.draw do
|
|||
resources :shoutmsgs
|
||||
resources :teamers
|
||||
resources :teams
|
||||
resources :gathers
|
||||
resources :gathers do |g|
|
||||
collection do
|
||||
get :refresh
|
||||
end
|
||||
member do
|
||||
post :pick
|
||||
end
|
||||
end
|
||||
get 'gathers/latest/:game', to: "gathers#latest", via: :get
|
||||
get 'gather', to: "gathers#latest", game: "ns2", via: :get
|
||||
|
||||
get 'gatherers/:id/status', to: "gatherers#status", via: :post
|
||||
|
||||
resources :gatherers
|
||||
resources :groups
|
||||
resources :groupers
|
||||
|
@ -123,12 +135,6 @@ Ensl::Application.routes.draw do
|
|||
|
||||
get 'directories', to: "directories#show", id: 1
|
||||
|
||||
get 'gathers/refresh'
|
||||
get 'gathers/latest/:game', to: "gathers#latest", via: :get
|
||||
get 'gather', to: "gathers#latest", game: "ns2", via: :get
|
||||
|
||||
get 'gatherers/:id/status', to: "gatherers#status", via: :post
|
||||
|
||||
get 'groups/addUser'
|
||||
get 'groups/delUser'
|
||||
|
||||
|
|
Loading…
Reference in a new issue