FIX code review and user cache

This commit is contained in:
Jasder
2020-10-30 15:47:09 +08:00
parent ece6cba4a4
commit 1bc935ffd5
7 changed files with 167 additions and 50 deletions

View File

@@ -385,11 +385,7 @@ class ApplicationController < ActionController::Base
end
def current_user
if Rails.env.development?
User.current = User.find 1
else
User.current
end
User.current
end
## 默认输出json
@@ -745,7 +741,7 @@ class ApplicationController < ActionController::Base
namespace = params[:owner]
id = params[:repo] || params[:id]
@project = Project.find_with_namespace(namespace, id)
@project, @owner = Project.find_with_namespace(namespace, id)
if @project and current_user.can_read_project?(@project)
logger.info "########### has project and can read project"

View File

@@ -6,7 +6,6 @@ class IssuesController < ApplicationController
before_action :check_project_public, only: [:index ,:show, :copy, :index_chosen, :close_issue]
before_action :set_issue, only: [:edit, :update, :destroy, :show, :copy, :close_issue, :lock_issue]
before_action :get_branches, only: [:new, :edit]
before_action :check_token_enough, only: [:create, :update]
include ApplicationHelper
@@ -97,8 +96,7 @@ class IssuesController < ApplicationController
end
def new
@all_branches = get_branches
@issue_chosen = issue_left_chosen(@project, nil)
@issue_chosen = get_associated_data(@project)
end
def create
@@ -150,7 +148,6 @@ class IssuesController < ApplicationController
end
def edit
# @all_branches = get_branches
# @issue_chosen = issue_left_chosen(@project, @issue.id)
@cannot_edit_tags = @issue.issue_type=="2" && @issue.status_id == 5 #悬赏任务已解决且关闭的状态下,不能修改
@issue_attachments = @issue.attachments
@@ -439,17 +436,6 @@ class IssuesController < ApplicationController
tracker_array
end
def get_branches
all_branches = []
get_all_branches = Gitea::Repository::Branches::ListService.new(@user, @project&.repository.try(:identifier)).call
if get_all_branches && get_all_branches.size > 0
get_all_branches.each do |b|
all_branches.push(b["name"])
end
end
all_branches
end
def issue_send_params(params)
{
subject: params[:subject],

View File

@@ -44,7 +44,7 @@ class ProjectsController < ApplicationController
end
def branches
@branches = @project.forge? ? Gitea::Repository::Branches::ListService.new(@project.owner, @project.identifier).call : []
@branches = @project.forge? ? Gitea::Repository::Branches::ListService.new(@owner, @project.identifier).call : []
end
def group_type_list