Merge branch 'master' into MatchScheduler

This commit is contained in:
Absurdon 2017-07-07 16:05:02 +02:00
commit 9c9ae32a9c
16 changed files with 164 additions and 22 deletions

View file

@ -5,7 +5,7 @@
.tabbed {
$tabs-border-width: 1px;
$tabs-border-colour: $light-blue;
$tabs-padding-horizontal: 16px;
$tabs-padding-horizontal: 13px;
$tabs-height: 35px;
ul.tabs {

View file

@ -2,7 +2,7 @@ class IssuesController < ApplicationController
before_filter :get_issue, only: [:show, :edit, :update, :destroy]
def index
raise AccessError unless cuser and cuser.admin?
raise AccessError unless cuser and (cuser.admin? or cuser.moderator?)
sort = case params['sort']
when "title" then "title"
@ -12,9 +12,13 @@ class IssuesController < ApplicationController
else "created_at DESC"
end
@open = Issue.with_status(Issue::STATUS_OPEN).all order: sort
@solved = Issue.with_status(Issue::STATUS_SOLVED).all order: sort
@rejected = Issue.with_status(Issue::STATUS_REJECTED).all order: sort
allowed = Issue::allowed_categories cuser
qstring = 'category_id IN (?)'
qstring += ' OR category_id IS NULL' if cuser.admin?
@open = Issue.where(qstring, allowed).with_status(Issue::STATUS_OPEN).all order: sort
@solved = Issue.where(qstring, allowed).with_status(Issue::STATUS_SOLVED).all order: sort
@rejected = Issue.where(qstring, allowed).with_status(Issue::STATUS_REJECTED).all order: sort
end
def show
@ -49,7 +53,7 @@ class IssuesController < ApplicationController
end
def update
raise AccessError unless @issue.can_update? cuser
raise AccessError unless @issue.can_update?(cuser, params[:issue])
if @issue.update_attributes(params[:issue])
flash[:notice] = t(:issues_update)
redirect_to(@issue)

View file

@ -3,7 +3,11 @@ class UsersController < ApplicationController
respond_to :html, :js
def index
@users = User.search(params[:search]).paginate(per_page: 40, page: params[:page])
if params[:filter] == 'lately'
@users = User.search(params[:search]).lately.paginate(per_page: 40, page: params[:page])
else
@users = User.search(params[:search]).paginate(per_page: 40, page: params[:page])
end
end
def show

View file

@ -26,7 +26,7 @@ module Extra
end
def bbcode_to_html(text)
Sanitize.clean(text.to_s).bbcode_to_html.gsub(/\r/, "<br>").html_safe
Sanitize.clean(text.to_s).bbcode_to_html.gsub(/\n|\r\n/, "<br>").html_safe
end
def move_up(scope, column = "position")

View file

@ -22,6 +22,7 @@ class Group < ActiveRecord::Base
PREDICTORS = 8
STAFF = 10
GATHER_MODERATORS = 14
COMP_MOD_COUNCIL = 16
attr_protected :id, :updated_at, :created_at, :founder_id
validates_length_of :name, :maximum => 20
@ -86,4 +87,20 @@ class Group < ActiveRecord::Base
end
casters
end
def self.gathermods
gathermods = []
(find(GATHER_MODERATORS).groupers).each do |g|
gathermods << g unless gathermods.include? g
end
gathermods
end
def self.compmodcouncil
compmodcouncil = []
(find(COMP_MOD_COUNCIL).groupers).each do |g|
compmodcouncil << g unless compmodcouncil.include? g
end
compmodcouncil
end
end

View file

@ -24,6 +24,11 @@ class Issue < ActiveRecord::Base
STATUS_SOLVED = 1
STATUS_REJECTED = 2
CATEGORY_WEBSITE = 17
CATEGORY_NSLPLUGIN = 20
CATEGORY_LEAGUE = 22
CATEGORY_GATHER = 54
attr_accessor :assigned_name
attr_protected :id, :created_at, :updated_at
@ -96,18 +101,38 @@ class Issue < ActiveRecord::Base
end
def can_show? cuser
cuser and !cuser.nil? and ((author == cuser) or cuser.admin?)
return false unless cuser
return true if cuser.admin?
((author == cuser) or (Issue::allowed_categories(cuser).include?(self.category_id)))
end
def can_create? cuser
true
end
def can_update? cuser
cuser and cuser.admin?
def can_update?(cuser, params = {})
return false unless cuser
return true if cuser.admin?
return false unless Issue::allowed_categories(cuser).include?(self.category_id)
!(params.member?(:category_id) && (self.category_id.to_s != params[:category_id]))
end
def can_destroy? cuser
cuser and cuser.admin?
end
# STATIC METHODS
def self.allowed_categories cuser
allowed = []
allowed << CATEGORY_GATHER if cuser.admin? || cuser.gather_moderator? # gather
allowed << CATEGORY_WEBSITE if cuser.admin? # website
allowed << CATEGORY_LEAGUE if cuser.admin? # league
allowed << CATEGORY_NSLPLUGIN if cuser.admin? # ensl plugin
allowed
end
end

View file

@ -99,6 +99,8 @@ class User < ActiveRecord::Base
:conditions => "bans.id IS NOT NULL"
scope :idle,
:conditions => ["lastvisit < ?", 30.minutes.ago.utc]
scope :lately,
:conditions => ["lastvisit > ?", 30.days.ago.utc]
before_validation :update_password
@ -190,11 +192,15 @@ class User < ActiveRecord::Base
end
def admin?
groups.exists? :id => Group::ADMINS
groups.exists? id: Group::ADMINS
end
def ref?
groups.exists? :id => Group::REFEREES
groups.exists? id: Group::REFEREES
end
def staff?
groups.exists? id: Group::STAFF
end
def staff?
@ -202,7 +208,20 @@ class User < ActiveRecord::Base
end
def caster?
groups.exists? :id => Group::CASTERS
groups.exists? id: Group::CASTERS
end
# might seem redundant but allows for later extensions like forum moderators
def moderator?
groups.exists? id: Group::GATHER_MODERATORS
end
def gather_moderator?
groups.exists? id: Group::GATHER_MODERATORS
end
def allowed_to_ban?
admin? or moderator?
end
def gather_moderator?

View file

@ -6,7 +6,7 @@
<p>To contact us:</p>
<p>
<ol>
<li>Use the <%= link_to "contact", new_issue_path() %> form (you must be logged in)</li>
<li>Use the <%= link_to "contact", new_issue_path %> form (you must be logged in)</li>
<li>Visit our <%= link_to "IRC", article_path(408) %> channel <%= link_to "#ENSL", "irc://irc.quakenet.org/ensl" %> on Quakenet.</li>
<li>Send email to the head admin as per the list below</li>
<li>Contact other staff members directly, check below and click profile for contact details</li>
@ -21,6 +21,8 @@
<li><a href="#admins">Admins</a></li>
<li><a href="#referees">Referees</a></li>
<li><a href="#casters">Casters</a></li>
<li><a href="#gathermods">Gather Mods</a></li>
<li><a href="#compmodcouncil">Comp. Mod Council</a></li>
<li><a href="#extras">Extras</a></li>
<li><a href="#support">Support</a></li>
</ul>
@ -106,6 +108,60 @@
<% end %>
</table>
</div>
<div class="tab" id="gathermods">
<h3>GATHER MODERATORS</h3>
<table class="striped staff">
<tr>
<th></th>
<th>Username</th>
<th>Email</th>
<th>Task</th>
<th>Age</th>
</tr>
<% Group.gathermods.each do |grouper| %>
<tr>
<td class="country"><%= flag grouper.user.country %></td>
<td class="username"><%= namelink grouper.user %></td>
<td><%= h grouper.user.email_s %></td>
<td>
<% if grouper.task %>
<%= h grouper.task %>
<% else %>
<%= h grouper.group.name.singularize %>
<% end %>
</td>
<td class="age"><%= h grouper.user.age %></td>
</tr>
<% end %>
</table>
</div>
<div class="tab" id="compmodcouncil">
<h3>COMP. MOD COUNCIL</h3>
<table class="striped staff">
<tr>
<th></th>
<th>Username</th>
<th>Email</th>
<th>Task</th>
<th>Age</th>
</tr>
<% Group.compmodcouncil.each do |grouper| %>
<tr>
<td class="country"><%= flag grouper.user.country %></td>
<td class="username"><%= namelink grouper.user %></td>
<td><%= h grouper.user.email_s %></td>
<td>
<% if grouper.task %>
<%= h grouper.task %>
<% else %>
<%= h grouper.group.name.singularize %>
<% end %>
</td>
<td class="age"><%= h grouper.user.age %></td>
</tr>
<% end %>
</table>
</div>
<div class="tab" id="extras">
<h3>Extras</h3>
<table class="striped staff">
@ -137,7 +193,7 @@
<h3>Support</h3>
<ul>
<li><b><a href="http://unknownworlds.com/">Unknown Worlds Entertainment</a></b></li>
<ul>
</ul>
</div>
</div>
</div>

View file

@ -4,7 +4,7 @@
<%= f.label :title %>
<%= f.text_field :title %>
</div>
<% if cuser and cuser.admin? %>
<% if cuser and (cuser.admin? or Issue::allowed_categories(cuser).include?(@issue.category_id)) %>
<div class="fields horizontal">
<%= f.label :status %>
<%= f.select :status, @issue.statuses.invert %>
@ -22,7 +22,7 @@
<%= f.label :text %>
<%= f.text_area :text, rows: 7 %>
</div>
<% if cuser and cuser.admin? %>
<% if cuser and (cuser.admin? or Issue::allowed_categories(cuser).include?(@issue.category_id)) %>
<div class="fields horizontal">
<%= f.label :solution %>
<%= f.text_area :solution, rows: 7 %>

View file

@ -135,7 +135,6 @@
<% end %>
</div>
<% end %>
</div>
<%= add_comments @match %>

View file

@ -1,4 +1,6 @@
<h1 class="title">Listing Users</h1>
<p><%= User.lately.count %> players have signed in within the past 30 days.</p>
<%= link_to 'Show them', params.merge(filter: 'lately'), class: 'button' %><br><br><br>
<p>Search for users by name or Steam ID:</p>

View file

@ -7,6 +7,12 @@
Admin (<%= Issue.with_status(0).count %>) <%= icon 'wrench' %>
<% end %>
</li>
<% elsif cuser.moderator? %>
<li>
<%= link_to issues_path, class: 'admin' do %>
Issues (<%= Issue.where(category_id: Issue.allowed_categories(cuser)).with_status(0).count %>) <%= icon 'wrench' %>
<% end %>
</li>
<% end %>
<li>
<%= link_to user_path(cuser) do %>

View file

@ -1,5 +1,4 @@
Ensl::Application.routes.draw do
%w(403 404 422 500).each do |code|
get code, to: "errors#show", code: code
end

View file

@ -0,0 +1,5 @@
class ChangeTypeOfProfileParsedSignature < ActiveRecord::Migration
def up
change_column :profiles, :signature_parsed, :text
end
end

View file

@ -0,0 +1,5 @@
class AddLastvisitIndexToUsers < ActiveRecord::Migration
def change
add_index :users, :lastvisit
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20170501121908) do
ActiveRecord::Schema.define(:version => 20170702150454) do
create_table "admin_requests", :force => true do |t|
t.string "addr"
@ -649,7 +649,7 @@ ActiveRecord::Schema.define(:version => 20170501121908) do
t.boolean "notify_challenge", :default => true, :null => false
t.string "steam_profile"
t.string "achievements_parsed"
t.string "signature_parsed"
t.text "signature_parsed"
t.string "stream"
t.string "layout"
end
@ -872,6 +872,7 @@ ActiveRecord::Schema.define(:version => 20170501121908) do
end
add_index "users", ["email"], :name => "index_users_on_email"
add_index "users", ["lastvisit"], :name => "index_users_on_lastvisit"
add_index "users", ["password"], :name => "index_users_on_password"
add_index "users", ["team_id"], :name => "index_users_on_team_id"
add_index "users", ["username"], :name => "index_users_on_username"