]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/issues_controller.rb
Remove new issue notifications for now
[rails.git] / app / controllers / issues_controller.rb
index 67c0d5b6ef8fe0d670a0a512c06ba95231ca67cc..b636b981c21543555f9cf8ffaba5b1338bceed28 100644 (file)
@@ -6,9 +6,6 @@ class IssuesController < ApplicationController
   before_action :set_issues
   before_action :check_permission, :only => [:index, :show, :resolve, :open, :ignore, :comment]
   before_action :find_issue, :only => [:show, :resolve, :reopen, :ignore]
-  before_action :setup_user_role, :only => [:show, :index]
-
-  helper_method :sort_column, :sort_direction
 
   def index
     if current_user.moderator?
@@ -19,7 +16,7 @@ class IssuesController < ApplicationController
       @users = User.joins(:roles).where(:user_roles => { :role => "administrator" })
     end
 
-    @issues = Issue.where(:issue_type => @user_role).order(sort_column + " " + sort_direction)
+    @issues = Issue.where(:assigned_role => current_user.roles.map(&:role))
 
     # If search
     if params[:search_by_user] && params[:search_by_user].present?
@@ -45,8 +42,6 @@ class IssuesController < ApplicationController
       @issues = @issues.where(:updated_by => last_updated_by)
     end
 
-    notice = t("issues.index.search.issues_not_found") if @issues.first.nil?
-
     if params[:last_reported_by] && params[:last_reported_by][0].present?
       last_reported_by = params[:last_reported_by][0].to_s == "nil" ? nil : params[:last_reported_by][0].to_i
       @issues = @issues.where(:updated_by => last_reported_by)
@@ -59,7 +54,8 @@ class IssuesController < ApplicationController
     @read_reports = @issue.read_reports
     @unread_reports = @issue.unread_reports
     @comments = @issue.comments
-    @related_issues = @issue.reported_user.issues.where(:issue_type => @user_role)
+    @related_issues = @issue.reported_user.issues.where(:assigned_role => current_user.roles.map(&:role))
+    @new_comment = IssueComment.new(:issue => @issue)
   end
 
   def update
@@ -96,25 +92,6 @@ class IssuesController < ApplicationController
     end
   end
 
-  def comment
-    @issue = Issue.find(params[:id])
-    if issue_comment_params.blank?
-      notice = t("issues.comment.provide_details")
-    else
-      @issue_comment = @issue.comments.build(issue_comment_params)
-      @issue_comment.commenter_user_id = current_user.id
-      if params[:reassign]
-        reassign_issue
-        @issue_comment.reassign = true
-      end
-      @issue_comment.save!
-      @issue.updated_by = current_user.id
-      @issue.save!
-      notice = t("issues.comment.comment_created")
-    end
-    redirect_to @issue, :notice => notice
-  end
-
   # Status Transistions
   def resolve
     if @issue.resolve
@@ -145,32 +122,13 @@ class IssuesController < ApplicationController
     end
   end
 
-  # Reassign Issues between Administrators and Moderators
-  def reassign_issue
-    @issue.issue_type = upgrade_issue(@issue.issue_type)
-    @issue.save!
-  end
-
   private
 
-  def upgrade_issue(type)
-    if type == "moderator"
-      "administrator"
-    else
-      "moderator"
-    end
-  end
-
   def set_issues
     @admin_issues = %w[DiaryEntry DiaryComment User]
     @moderator_issues = %w[Changeset Note]
   end
 
-  def setup_user_role
-    # Get user role
-    @user_role = current_user.administrator? ? "administrator" : "moderator"
-  end
-
   def check_if_updated
     if @issue.reportable && (@issue.ignored? || @issue.resolved?) && @issue.reportable.has_attribute?(:updated_by) && @issue.reportable.updated_at > @last_report.updated_at
       true