Added Issue Type + Issue Reassigning + Last updated_by
This commit is contained in:
parent
fb78544d05
commit
f72c34aaf8
11 changed files with 85 additions and 25 deletions
|
@ -7,21 +7,34 @@ class IssuesController < ApplicationController
|
||||||
before_action :find_issue, only: [:show, :resolve, :reopen, :ignore]
|
before_action :find_issue, only: [:show, :resolve, :reopen, :ignore]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
if params[:search_by_user].present?
|
# Get user role
|
||||||
@user = User.find_by_display_name(params[:search_by_user])
|
if @user.administrator?
|
||||||
if @user.present?
|
@user_role = "administrator"
|
||||||
@issues = Issue.where(reported_user_id: @user.id).order(:status)
|
|
||||||
else
|
|
||||||
@issues = Issue.all.order(:status)
|
|
||||||
redirect_to issues_path, notice: t('issues.index.search.user_not_found')
|
|
||||||
end
|
|
||||||
|
|
||||||
if @user.present? and not @issues.present?
|
|
||||||
@issues = Issue.all.order(:status)
|
|
||||||
redirect_to issues_path, notice: t('issues.index.search.issues_not_found')
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
@issues = Issue.all.order(:status)
|
@user_role = "moderator"
|
||||||
|
end
|
||||||
|
|
||||||
|
# If search
|
||||||
|
if params[:search_by_user]
|
||||||
|
@find_user = User.find_by_display_name(params[:search_by_user])
|
||||||
|
if @find_user
|
||||||
|
@issues = Issue.where(reported_user_id: @find_user.id, issue_type: @user_role).order(:status)
|
||||||
|
else
|
||||||
|
@issues = Issue.where(issue_type: @user_role).order(:status)
|
||||||
|
notice = t('issues.index.search.user_not_found')
|
||||||
|
end
|
||||||
|
|
||||||
|
if @find_user !=nil and @issues.first == nil
|
||||||
|
@issues = Issue.where(issue_type: @user_role).order(:status)
|
||||||
|
notice = t('issues.index.search.issues_not_found')
|
||||||
|
end
|
||||||
|
|
||||||
|
if notice
|
||||||
|
redirect_to issues_path, notice: notice
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
@issues = Issue.where(issue_type: @user_role).order(:status)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,6 +43,9 @@ class IssuesController < ApplicationController
|
||||||
@unread_reports = @issue.unread_reports
|
@unread_reports = @issue.unread_reports
|
||||||
@comments = @issue.comments
|
@comments = @issue.comments
|
||||||
@related_issues = @issue.user.issues
|
@related_issues = @issue.user.issues
|
||||||
|
if @issue.updated_by
|
||||||
|
@updated_by_admin = User.find(@issue.updated_by)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
@ -41,14 +57,23 @@ class IssuesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
admin_issues = [ 'DiaryEntry', 'DiaryComment', 'User']
|
||||||
|
moderator_issues = []
|
||||||
@issue = Issue.find_by_reportable_id_and_reportable_type(params[:reportable_id],params[:reportable_type])
|
@issue = Issue.find_by_reportable_id_and_reportable_type(params[:reportable_id],params[:reportable_type])
|
||||||
# Check if Issue alrwady exists
|
# Check if Issue alrwady exists
|
||||||
if !@issue
|
if !@issue
|
||||||
@issue = Issue.find_or_initialize_by(issue_params)
|
@issue = Issue.find_or_initialize_by(issue_params)
|
||||||
|
@issue.updated_by = nil
|
||||||
@admins = UserRole.where(role: "administrator")
|
@admins = UserRole.where(role: "administrator")
|
||||||
@admins.each do |admin|
|
@admins.each do |admin|
|
||||||
Notifier.new_issue_notification(User.find(admin.user_id)).deliver_now
|
Notifier.new_issue_notification(User.find(admin.user_id)).deliver_now
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Reassign to moderators if it is a moderator issue
|
||||||
|
@issue.issue_type = "administrator"
|
||||||
|
if moderator_issues.include? @issue.reportable.class.name
|
||||||
|
reassign_issue
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check if details provided are sufficient
|
# Check if details provided are sufficient
|
||||||
|
@ -112,7 +137,13 @@ class IssuesController < ApplicationController
|
||||||
@issue = Issue.find(params[:id])
|
@issue = Issue.find(params[:id])
|
||||||
@issue_comment = @issue.comments.build(issue_comment_params)
|
@issue_comment = @issue.comments.build(issue_comment_params)
|
||||||
@issue_comment.commenter_user_id = @user.id
|
@issue_comment.commenter_user_id = @user.id
|
||||||
|
if params[:reassign]
|
||||||
|
reassign_issue
|
||||||
|
@issue_comment.reassign = true
|
||||||
|
end
|
||||||
@issue_comment.save!
|
@issue_comment.save!
|
||||||
|
@issue.updated_by = @user.id
|
||||||
|
@issue.save!
|
||||||
redirect_to @issue
|
redirect_to @issue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -128,6 +159,7 @@ class IssuesController < ApplicationController
|
||||||
|
|
||||||
def ignore
|
def ignore
|
||||||
if @issue.ignore
|
if @issue.ignore
|
||||||
|
@issue.updated_by = @user.id
|
||||||
@issue.save!
|
@issue.save!
|
||||||
redirect_to @issue, notice: t('issues.ignored')
|
redirect_to @issue, notice: t('issues.ignored')
|
||||||
else
|
else
|
||||||
|
@ -137,6 +169,7 @@ class IssuesController < ApplicationController
|
||||||
|
|
||||||
def reopen
|
def reopen
|
||||||
if @issue.reopen
|
if @issue.reopen
|
||||||
|
@issue.updated_by = @user.id
|
||||||
@issue.save!
|
@issue.save!
|
||||||
redirect_to @issue, notice: t('issues.reopened')
|
redirect_to @issue, notice: t('issues.reopened')
|
||||||
else
|
else
|
||||||
|
@ -144,6 +177,15 @@ class IssuesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Reassign Issues between Administrators and Moderators
|
||||||
|
def reassign_issue
|
||||||
|
if @issue.issue_type == "moderator"
|
||||||
|
@issue.issue_type = "administrator"
|
||||||
|
else
|
||||||
|
@issue.issue_type = "moderator"
|
||||||
|
end
|
||||||
|
@issue.save!
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ class Issue < ActiveRecord::Base
|
||||||
|
|
||||||
# Check if more statuses are needed
|
# Check if more statuses are needed
|
||||||
enum status: %w( open ignored resolved )
|
enum status: %w( open ignored resolved )
|
||||||
|
enum type: %w( administrator moderator )
|
||||||
|
|
||||||
scope :with_status, -> (issue_status) { where(:status => statuses[issue_status])}
|
scope :with_status, -> (issue_status) { where(:status => statuses[issue_status])}
|
||||||
|
|
||||||
|
@ -44,5 +45,4 @@ class Issue < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,11 +31,12 @@
|
||||||
<%= link_to t('diary_entry.diary_entry.edit_link'), :action => 'edit', :display_name => diary_entry.user.display_name, :id => diary_entry.id %>
|
<%= link_to t('diary_entry.diary_entry.edit_link'), :action => 'edit', :display_name => diary_entry.user.display_name, :id => diary_entry.id %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% if @user and diary_entry.user.id != @user.id %>
|
||||||
<li>
|
<li>
|
||||||
<% if @user and diary_entry.user.id != @user.id %>
|
|
||||||
<%= link_to t('issues.report'), new_issue_url(reportable_id: diary_entry.id, reportable_type: diary_entry.class.name, reported_user_id: diary_entry.user.id) %>
|
<%= link_to t('issues.report'), new_issue_url(reportable_id: diary_entry.id, reportable_type: diary_entry.class.name, reported_user_id: diary_entry.user.id) %>
|
||||||
<% end %>
|
|
||||||
</li>
|
</li>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<%= if_administrator(:li) do %>
|
<%= if_administrator(:li) do %>
|
||||||
<%= link_to t('diary_entry.diary_entry.hide_link'), hide_diary_entry_path(:display_name => diary_entry.user.display_name, :id => diary_entry.id), :method => :post, :data => { :confirm => t('diary_entry.diary_entry.confirm') } %>
|
<%= link_to t('diary_entry.diary_entry.hide_link'), hide_diary_entry_path(:display_name => diary_entry.user.display_name, :id => diary_entry.id), :method => :post, :data => { :confirm => t('diary_entry.diary_entry.confirm') } %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
</div>
|
</div>
|
||||||
<b> <%= link_to comment.user.display_name, :controller => :user,:action =>:view, :display_name => comment.user.display_name %> </b> <br/>
|
<b> <%= link_to comment.user.display_name, :controller => :user,:action =>:view, :display_name => comment.user.display_name %> </b> <br/>
|
||||||
<%= comment.body %>
|
<%= comment.body %>
|
||||||
|
|
||||||
|
<% if comment.reassign %>
|
||||||
|
<br/>
|
||||||
|
<i><%= t('issues.show.comments.reassign') %></i>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<span class="deemphasize">
|
<span class="deemphasize">
|
||||||
On <%= l comment.created_at.to_datetime, :format => :long %> </span>
|
On <%= l comment.created_at.to_datetime, :format => :long %> </span>
|
||||||
|
@ -16,6 +21,9 @@
|
||||||
<div class="comment">
|
<div class="comment">
|
||||||
<%= form_for :issue_comment, :url => { :action => 'comment', :id => @issue.id, :user_id => @user.id } do |f| %>
|
<%= form_for :issue_comment, :url => { :action => 'comment', :id => @issue.id, :user_id => @user.id } do |f| %>
|
||||||
<%= richtext_area :issue_comment, :body, :cols => 10, :rows => 8 %>
|
<%= richtext_area :issue_comment, :body, :cols => 10, :rows => 8 %>
|
||||||
|
<%= label_tag t('issues.show.comments.reassign_param') %> <%= check_box_tag :reassign, true %>
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
<%= submit_tag 'Submit' %>
|
<%= submit_tag 'Submit' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
|
@ -1,7 +1,7 @@
|
||||||
<p id= "notice"><%= notice %></p>
|
<p id= "notice"><%= notice %></p>
|
||||||
|
|
||||||
<% content_for :heading do %>
|
<% content_for :heading do %>
|
||||||
<h1>List of existing Issues:</h1>
|
<h1>List of <%= @user_role %> issues:</h1>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= form_tag(issues_path, :method => :get) do %>
|
<%= form_tag(issues_path, :method => :get) do %>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<p>Issue type: <%= @issue.reportable_type %></p>
|
<p>Issue type: <%= @issue.reportable_type %></p>
|
||||||
<p class="deemphasize">
|
<p class="deemphasize">
|
||||||
<small>
|
<small>
|
||||||
<%= @issue.reports.count %> reports | First reported: <%= l @issue.created_at.to_date, :format => :long %> <%= "| Last resolved at #{l(@issue.resolved_at.to_datetime, :format =>:long)}" if @issue.resolved_at? %>
|
<%= @issue.reports.count %> reports | First reported: <%= l @issue.created_at.to_date, :format => :long %> <%= "| Last resolved at #{l(@issue.resolved_at.to_datetime, :format =>:long)}" if @issue.resolved_at? %> <%= "| Last updated at #{l(@issue.updated_at.to_datetime, :format => :long)} by #{@updated_by_admin.display_name}" if @updated_by_admin %>
|
||||||
</small>
|
</small>
|
||||||
</p>
|
</p>
|
||||||
<p><%= link_to t('issues.resolve'), resolve_issue_url(@issue), :method => :post if @issue.may_resolve? %></p>
|
<p><%= link_to t('issues.resolve'), resolve_issue_url(@issue), :method => :post if @issue.may_resolve? %></p>
|
||||||
|
|
|
@ -953,6 +953,10 @@ en-GB:
|
||||||
provide_details: Please provide the required details
|
provide_details: Please provide the required details
|
||||||
new:
|
new:
|
||||||
details: Please provide some more details into the problem. (This field cannot be left blank!)
|
details: Please provide some more details into the problem. (This field cannot be left blank!)
|
||||||
|
show:
|
||||||
|
comments:
|
||||||
|
reassign: The Issue was reassigned
|
||||||
|
reassign_param: Reassign Issue?
|
||||||
resolved: Issue status has been set to 'Resolved'
|
resolved: Issue status has been set to 'Resolved'
|
||||||
ignored: Issue status has been set to 'Ignored'
|
ignored: Issue status has been set to 'Ignored'
|
||||||
reopened: Issue status has been set to 'Open'
|
reopened: Issue status has been set to 'Open'
|
||||||
|
|
|
@ -923,6 +923,10 @@ en:
|
||||||
provide_details: Please provide the required details
|
provide_details: Please provide the required details
|
||||||
new:
|
new:
|
||||||
details: Please provide some more details into the problem. (This field cannot be left blank!)
|
details: Please provide some more details into the problem. (This field cannot be left blank!)
|
||||||
|
show:
|
||||||
|
comments:
|
||||||
|
reassign: The Issue was reassigned
|
||||||
|
reassign_param: Reassign Issue?
|
||||||
resolved: Issue status has been set to 'Resolved'
|
resolved: Issue status has been set to 'Resolved'
|
||||||
ignored: Issue status has been set to 'Ignored'
|
ignored: Issue status has been set to 'Ignored'
|
||||||
reopened: Issue status has been set to 'Open'
|
reopened: Issue status has been set to 'Open'
|
||||||
|
|
|
@ -7,10 +7,12 @@ class CreateIssuesAndReports < ActiveRecord::Migration
|
||||||
t.integer :reportable_id, :null => false
|
t.integer :reportable_id, :null => false
|
||||||
t.integer :reported_user_id, :null => false
|
t.integer :reported_user_id, :null => false
|
||||||
t.integer :status
|
t.integer :status
|
||||||
|
t.string :issue_type
|
||||||
t.datetime :resolved_at
|
t.datetime :resolved_at
|
||||||
t.integer :resolved_by
|
t.integer :resolved_by
|
||||||
t.datetime :created_at
|
t.datetime :created_at
|
||||||
t.datetime :updated_at
|
t.datetime :updated_at
|
||||||
|
t.integer :updated_by
|
||||||
|
|
||||||
t.timestamps null: false
|
t.timestamps null: false
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ class CreateIssueComments < ActiveRecord::Migration
|
||||||
t.integer :commenter_user_id
|
t.integer :commenter_user_id
|
||||||
t.text :body
|
t.text :body
|
||||||
t.datetime :created_at
|
t.datetime :created_at
|
||||||
|
t.boolean :reassign
|
||||||
t.timestamps null: false
|
t.timestamps null: false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -151,10 +151,6 @@ CREATE FUNCTION xid_to_int4(xid) RETURNS integer
|
||||||
AS '$libdir/libpgosm', 'xid_to_int4';
|
AS '$libdir/libpgosm', 'xid_to_int4';
|
||||||
|
|
||||||
|
|
||||||
SET default_tablespace = '';
|
|
||||||
|
|
||||||
SET default_with_oids = false;
|
|
||||||
|
|
||||||
SET default_tablespace = '';
|
SET default_tablespace = '';
|
||||||
|
|
||||||
SET default_with_oids = false;
|
SET default_with_oids = false;
|
||||||
|
@ -677,6 +673,7 @@ CREATE TABLE issue_comments (
|
||||||
commenter_user_id integer,
|
commenter_user_id integer,
|
||||||
body text,
|
body text,
|
||||||
created_at timestamp without time zone NOT NULL,
|
created_at timestamp without time zone NOT NULL,
|
||||||
|
reassign boolean,
|
||||||
updated_at timestamp without time zone NOT NULL
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -710,10 +707,12 @@ CREATE TABLE issues (
|
||||||
reportable_id integer NOT NULL,
|
reportable_id integer NOT NULL,
|
||||||
reported_user_id integer NOT NULL,
|
reported_user_id integer NOT NULL,
|
||||||
status integer,
|
status integer,
|
||||||
|
issue_type character varying,
|
||||||
resolved_at timestamp without time zone,
|
resolved_at timestamp without time zone,
|
||||||
resolved_by integer,
|
resolved_by integer,
|
||||||
created_at timestamp without time zone NOT NULL,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone NOT NULL
|
updated_at timestamp without time zone NOT NULL,
|
||||||
|
updated_by integer
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue