mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-01-12 04:40:42 +00:00
gave gathermods the possibility to respond to gather issues
This commit is contained in:
parent
313500c257
commit
8579d0b569
5 changed files with 46 additions and 15 deletions
|
@ -2,7 +2,7 @@ class IssuesController < ApplicationController
|
||||||
before_filter :get_issue, only: [:show, :edit, :update, :destroy]
|
before_filter :get_issue, only: [:show, :edit, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
raise AccessError unless cuser and cuser.admin?
|
raise AccessError unless cuser and (cuser.admin? or cuser.moderator?)
|
||||||
|
|
||||||
sort = case params['sort']
|
sort = case params['sort']
|
||||||
when "title" then "title"
|
when "title" then "title"
|
||||||
|
@ -12,9 +12,11 @@ class IssuesController < ApplicationController
|
||||||
else "created_at DESC"
|
else "created_at DESC"
|
||||||
end
|
end
|
||||||
|
|
||||||
@open = Issue.with_status(Issue::STATUS_OPEN).all order: sort
|
allowed = Issue::allowed_categories cuser
|
||||||
@solved = Issue.with_status(Issue::STATUS_SOLVED).all order: sort
|
|
||||||
@rejected = Issue.with_status(Issue::STATUS_REJECTED).all order: sort
|
@open = Issue.where(category_id: allowed).with_status(Issue::STATUS_OPEN).all order: sort
|
||||||
|
@solved = Issue.where(category_id: allowed).with_status(Issue::STATUS_SOLVED).all order: sort
|
||||||
|
@rejected = Issue.where(category_id: allowed).with_status(Issue::STATUS_REJECTED).all order: sort
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
@ -49,7 +51,7 @@ class IssuesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @issue.can_update? cuser
|
raise AccessError unless @issue.can_update?(cuser, params[:issue])
|
||||||
if @issue.update_attributes(params[:issue])
|
if @issue.update_attributes(params[:issue])
|
||||||
flash[:notice] = t(:issues_update)
|
flash[:notice] = t(:issues_update)
|
||||||
redirect_to(@issue)
|
redirect_to(@issue)
|
||||||
|
|
|
@ -96,18 +96,36 @@ class Issue < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_show? cuser
|
def can_show? cuser
|
||||||
cuser and !cuser.nil? and ((author == cuser) or cuser.admin?)
|
cuser and ((author == cuser) or (Issue::allowed_categories(cuser).include?(self.category_id)))
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_create? cuser
|
def can_create? cuser
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_update? cuser
|
def can_update?(cuser, params = {})
|
||||||
cuser and cuser.admin?
|
ret = cuser && Issue::allowed_categories(cuser).include?(self.category_id)
|
||||||
|
if ret && !cuser.admin? && params.member?(:category_id)
|
||||||
|
ret = (self.category_id.to_s == params[:category_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
ret
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_destroy? cuser
|
def can_destroy? cuser
|
||||||
cuser and cuser.admin?
|
cuser and cuser.admin?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# STATIC METHODS
|
||||||
|
|
||||||
|
def self.allowed_categories cuser
|
||||||
|
allowed = []
|
||||||
|
allowed << 54 if cuser.admin? || cuser.gather_moderator? # gather
|
||||||
|
allowed << 17 if cuser.admin? # website
|
||||||
|
allowed << 22 if cuser.admin? # league
|
||||||
|
allowed << 20 if cuser.admin? # ensl plugin
|
||||||
|
allowed
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -190,19 +190,24 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def admin?
|
def admin?
|
||||||
groups.exists? :id => Group::ADMINS
|
groups.exists? id: Group::ADMINS
|
||||||
end
|
end
|
||||||
|
|
||||||
def ref?
|
def ref?
|
||||||
groups.exists? :id => Group::REFEREES
|
groups.exists? id: Group::REFEREES
|
||||||
end
|
end
|
||||||
|
|
||||||
def staff?
|
def staff?
|
||||||
groups.exists? :id => Group::STAFF
|
groups.exists? id: Group::STAFF
|
||||||
end
|
end
|
||||||
|
|
||||||
def caster?
|
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
|
end
|
||||||
|
|
||||||
def gather_moderator?
|
def gather_moderator?
|
||||||
|
@ -210,7 +215,7 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def allowed_to_ban?
|
def allowed_to_ban?
|
||||||
admin? or gather_moderator?
|
admin? or moderator?
|
||||||
end
|
end
|
||||||
|
|
||||||
def verified?
|
def verified?
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<%= f.label :title %>
|
<%= f.label :title %>
|
||||||
<%= f.text_field :title %>
|
<%= f.text_field :title %>
|
||||||
</div>
|
</div>
|
||||||
<% if cuser and cuser.admin? %>
|
<% if cuser and Issue::allowed_categories(cuser).include?(@issue.category_id) %>
|
||||||
<div class="fields horizontal">
|
<div class="fields horizontal">
|
||||||
<%= f.label :status %>
|
<%= f.label :status %>
|
||||||
<%= f.select :status, @issue.statuses.invert %>
|
<%= f.select :status, @issue.statuses.invert %>
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
<%= f.label :text %>
|
<%= f.label :text %>
|
||||||
<%= f.text_area :text, rows: 7 %>
|
<%= f.text_area :text, rows: 7 %>
|
||||||
</div>
|
</div>
|
||||||
<% if cuser and cuser.admin? %>
|
<% if cuser and Issue::allowed_categories(cuser).include?(@issue.category_id) %>
|
||||||
<div class="fields horizontal">
|
<div class="fields horizontal">
|
||||||
<%= f.label :solution %>
|
<%= f.label :solution %>
|
||||||
<%= f.text_area :solution, rows: 7 %>
|
<%= f.text_area :solution, rows: 7 %>
|
||||||
|
|
|
@ -7,6 +7,12 @@
|
||||||
Admin (<%= Issue.with_status(0).count %>) <%= icon 'wrench' %>
|
Admin (<%= Issue.with_status(0).count %>) <%= icon 'wrench' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</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 %>
|
<% end %>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to user_path(cuser) do %>
|
<%= link_to user_path(cuser) do %>
|
||||||
|
|
Loading…
Reference in a new issue