Added projects. Part 4

master
alexey 2 months ago
parent 8d10b21963
commit 34a69e1a1d

@ -346,6 +346,42 @@ post "/prjcreate" do
end end
end end
get "/prjedit/:id" do
prj = ProjectsActions.new(cfg.get_projects_path, db)
if prj.path.nil?
print_error_page(503, "Путь к проектам не существует")
else
repo = GitRepo.new(cfg.get_repo, db)
if repo.path.nil?
print_error_page(503, "Путь к репозиториям не существует")
else
prj_info = prj.get_project(params["id"])
if prj_info.nil?
print_error_page(503, "Путь к проектам не существует")
else
@page_name = prj_info[:projname]
@proj_name = prj_info[:projname]
@proj_descr = prj_info[:descr]
@proj_id = prj_info[:id]
repo_lst = repo.getrepos
proj_repo_list = prj.get_project_gits(prj_info[:id])
@repo_list = repo_lst.reject do |item|
fnd = false
proj_repo_list.each do |item2|
if item2[:id] == item[:id]
fnd = true
break
end
end
fnd
end
@proj_repo = proj_repo_list
erb :prjinfo
end
end
end
end
not_found do not_found do
status 404 status 404
@page_name = "Кто-то потерялся" @page_name = "Кто-то потерялся"

@ -119,6 +119,10 @@ class DBase
Projects.order(:id).all Projects.order(:id).all
end end
def proj(id)
Projects[id]
end
def proj_create(proj_name, proj_descr) def proj_create(proj_name, proj_descr)
@error = nil @error = nil
data = Projects.where(projname: proj_name).first data = Projects.where(projname: proj_name).first
@ -130,4 +134,17 @@ class DBase
end end
@error @error
end end
def get_gits_for_projects(id)
result = []
git_list = ReposProjects.where(proj_id: id.to_i).all
unless git_list.nil?
result = git_list.map do |item|
Repos[item[:repo_id]]
end.reject do |item|
item.nil?
end
end
result
end
end end

@ -37,6 +37,15 @@ class ProjectsActions
prj prj
end end
def get_project(id)
prj = nil
File.open("locks/prjcreate", "r") do |f|
f.flock(File::LOCK_SH)
prj = @db.proj(id.to_i)
end
prj
end
def create_project(name, description, configuration) def create_project(name, description, configuration)
@error = nil @error = nil
ret_val = 0 ret_val = 0
@ -77,4 +86,8 @@ class ProjectsActions
end end
ret_val ret_val
end end
def get_project_gits(id)
@db.get_gits_for_projects(id)
end
end end

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 359 B

After

Width:  |  Height:  |  Size: 359 B

Before

Width:  |  Height:  |  Size: 102 B

After

Width:  |  Height:  |  Size: 102 B

Before

Width:  |  Height:  |  Size: 198 B

After

Width:  |  Height:  |  Size: 198 B

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Before

Width:  |  Height:  |  Size: 295 B

After

Width:  |  Height:  |  Size: 295 B

Before

Width:  |  Height:  |  Size: 256 B

After

Width:  |  Height:  |  Size: 256 B

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Before

Width:  |  Height:  |  Size: 257 B

After

Width:  |  Height:  |  Size: 257 B

Before

Width:  |  Height:  |  Size: 170 B

After

Width:  |  Height:  |  Size: 170 B

Before

Width:  |  Height:  |  Size: 147 B

After

Width:  |  Height:  |  Size: 147 B

Before

Width:  |  Height:  |  Size: 825 B

After

Width:  |  Height:  |  Size: 825 B

Before

Width:  |  Height:  |  Size: 169 B

After

Width:  |  Height:  |  Size: 169 B

Before

Width:  |  Height:  |  Size: 168 B

After

Width:  |  Height:  |  Size: 168 B

Before

Width:  |  Height:  |  Size: 285 B

After

Width:  |  Height:  |  Size: 285 B

Before

Width:  |  Height:  |  Size: 191 B

After

Width:  |  Height:  |  Size: 191 B

Before

Width:  |  Height:  |  Size: 174 B

After

Width:  |  Height:  |  Size: 174 B

Before

Width:  |  Height:  |  Size: 43 B

After

Width:  |  Height:  |  Size: 43 B

Before

Width:  |  Height:  |  Size: 79 B

After

Width:  |  Height:  |  Size: 79 B

Before

Width:  |  Height:  |  Size: 175 B

After

Width:  |  Height:  |  Size: 175 B

Before

Width:  |  Height:  |  Size: 951 B

After

Width:  |  Height:  |  Size: 951 B

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 245 B

Before

Width:  |  Height:  |  Size: 87 B

After

Width:  |  Height:  |  Size: 87 B

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save