parent
e9284ba3fe
commit
d721d177c0
@ -0,0 +1,12 @@
|
|||||||
|
module OperateProjectAbilityAble
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
included do
|
||||||
|
end
|
||||||
|
|
||||||
|
def authorizate_user_can_edit_project!
|
||||||
|
return if current_user.project_manager? @project || current_user.admin?
|
||||||
|
render_forbidden('你没有权限操作.')
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -1,5 +1,7 @@
|
|||||||
class MainController < ApplicationController
|
class MainController < ApplicationController
|
||||||
|
protect_from_forgery except: :index
|
||||||
|
|
||||||
def index
|
def index
|
||||||
render file: 'public/react/build/index.html', :layout => false
|
render file: 'public/react/build/index.html', :layout => false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
class SettingsController < ApplicationController
|
class SettingsController < ApplicationController
|
||||||
def show
|
def show
|
||||||
@laboratory = current_laboratory
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
class Projects::UpdateForm < BaseForm
|
||||||
|
attr_reader :name, :description, :repository_name, :project_category_id
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,39 @@
|
|||||||
|
module Repositories
|
||||||
|
class GetInteractor
|
||||||
|
def self.call(user, repo)
|
||||||
|
interactor = new(user, repo)
|
||||||
|
interactor.run
|
||||||
|
interactor
|
||||||
|
end
|
||||||
|
|
||||||
|
attr_reader :error, :result
|
||||||
|
|
||||||
|
def initialize(user, repo)
|
||||||
|
@user = user
|
||||||
|
@repo = repo
|
||||||
|
end
|
||||||
|
|
||||||
|
def success?
|
||||||
|
@error.nil?
|
||||||
|
end
|
||||||
|
|
||||||
|
def result
|
||||||
|
@result
|
||||||
|
end
|
||||||
|
|
||||||
|
def run
|
||||||
|
@result = Gitea::Repository::GetService.new(@user, @repo.identifier).call
|
||||||
|
rescue Exception => exception
|
||||||
|
fail!(exception.message)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
attr_reader :user, :repo
|
||||||
|
|
||||||
|
def fail!(error)
|
||||||
|
@error = error
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,33 @@
|
|||||||
|
class Gitea::Repository::UpdateService < Gitea::ClientService
|
||||||
|
attr_reader :user, :repo, :params
|
||||||
|
|
||||||
|
# params:
|
||||||
|
# {
|
||||||
|
# name: 'name of the repository',
|
||||||
|
# default_branch: 'sets the default branch for this repository.',
|
||||||
|
# description: 'string a short description of the repository.',
|
||||||
|
# private: 'boolean either true to make the repository private or false to make it public.',
|
||||||
|
# has_issues: 'boolean either true to enable issues for this repository or false to disable them.',
|
||||||
|
# has_pull_requests: 'boolean either true to allow pull requests, or false to prevent pull request.',
|
||||||
|
# allow_merge_commits: 'boolean either true to allow merging pull requests with a merge commit, or false to prevent merging pull requests with merge commits. has_pull_requests must be true.'
|
||||||
|
# }
|
||||||
|
|
||||||
|
def initialize(user, repo, params={})
|
||||||
|
@user = user
|
||||||
|
@repo = repo
|
||||||
|
@params = params
|
||||||
|
end
|
||||||
|
|
||||||
|
def call
|
||||||
|
patch(url, data_params)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def url
|
||||||
|
"/repos/#{user.login}/#{repo}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def data_params
|
||||||
|
Hash.new.merge(token: user.gitea_token, data: params)
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,6 @@
|
|||||||
|
json.name @project.name
|
||||||
|
json.identifier @project.identifier
|
||||||
|
json.is_public @project.is_public
|
||||||
|
json.description @project.description
|
||||||
|
json.repo_id @project.repository.id
|
||||||
|
json.repo_identifier @project.repository.identifier
|
Loading…
Reference in new issue