Added Contributor Group Treatment

* Logrotation for production
* added contributors class method to Group
* added contributor? method to User
* added contributor flag to User-API
* added Contributor-Tab to staff-page
This commit is contained in:
Absurdon 2019-11-12 23:27:54 +01:00
parent 7ec019fda6
commit db9d4c1564
No known key found for this signature in database
GPG key ID: E383BEAE6F394B2F
6 changed files with 54 additions and 3 deletions

View file

@ -32,6 +32,7 @@ class Api::V1::UsersController < Api::V1::BaseController
referee: @user.ref?,
caster: @user.caster?,
moderator: @user.gather_moderator?,
contributor: @user.contributor?,
steam: @user.steamid.nil? ? nil : {
id: @user.steamid,
url: @steam.nil? ? nil : @steam.base_url,

View file

@ -22,6 +22,7 @@ class Group < ActiveRecord::Base
PREDICTORS = 8
STAFF = 10
GATHER_MODERATORS = 14
CONTRIBUTORS = 16
attr_protected :id, :updated_at, :created_at, :founder_id
validates_length_of :name, :maximum => 20
@ -113,4 +114,15 @@ class Group < ActiveRecord::Base
end
gathermods
end
def self.contributors
contributors = []
group_contrib = where(id:CONTRIBUTORS).first
return contributors unless group_contrib
(group_contrib.groupers).each do |g|
contributors << g unless contributors.include? g
end
contributors
end
end

View file

@ -27,7 +27,7 @@ require File.join(Rails.root, 'vendor', 'plugins', 'acts_as_versioned', 'lib', '
class User < ActiveRecord::Base
include Extra
VERIFICATION_TIME = 604800
attr_protected :id, :created_at, :updated_at, :lastvisit, :lastip, :password, :version
@ -211,6 +211,10 @@ class User < ActiveRecord::Base
groups.exists? id: Group::GATHER_MODERATORS
end
def contributor?
groups.exists? id: Group::CONTRIBUTORS
end
def allowed_to_ban?
admin? or moderator?
end

View file

@ -16,6 +16,7 @@
<div id="staff" class="tabbed">
<ul id="staff-nav" class="tabs">
<li><a href="#admins">Admins</a></li>
<li><a href="#contributors">Contributors</a></li>
<li><a href="#referees">Referees</a></li>
<li><a href="#casters">Casters</a></li>
<li><a href="#gathermods">Gather Mods</a></li>
@ -54,6 +55,37 @@
<% end %>
</table>
</div>
<div class="tab" id="contributors">
<h3>Admins</h3>
<table class="striped staff">
<tr>
<th></th>
<th>Username</th>
<th>Email</th>
<th>Task</th>
<th>Age</th>
</tr>
<% Group.contributors.each do |grouper| %>
<tr>
<td class="country"><%= flag grouper.user.country %></td>
<td class="username"><%= namelink grouper.user %></td>
<% if grouper.user.public_email %>
<td><%= h grouper.user.email_s %></td>
<% else %>
<td></td>
<% end %>
<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="referees">
<h3>Referees</h3>
<table class="striped staff">

View file

@ -33,8 +33,8 @@ Ensl::Application.configure do
# See everything in the log (default is :info)
config.log_level = :error
# Use a different logger for distrwt ibuted setups
# config.logger = SyslogLogger.new
# Use a different logger for distributed setups
config.logger = Logger.new(Rails.root.join("log", Rails.env + ".log" ), 5 , 10 * 1024 * 1024)
# Use a different cache store in production
config.cache_store = :dalli_store, 'memcached:11211', 'localhost'

View file

@ -14,6 +14,8 @@ Group.create!(id: Group::CASTERS, name: "Streamers", founder: User.first)
Group.create!(id: Group::CHAMPIONS, name: "Champions", founder: User.first)
Group.create!(id: Group::PREDICTORS, name: "Predictors", founder: User.first)
Group.create!(id: Group::STAFF, name: "Staff", founder: User.first)
Group.create!(id: Group::GATHER_MODERATORS, name: 'Gather Moderators', founder: User.first)
Group.create!(id: Group::CONTRIBUTORS, name: 'Contributors', founder: User.first)
# Group Association
Grouper.create!(group_id: Group::ADMINS, user_id: User.first.id)