diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 573dbba8..1fd858be 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -11,7 +11,7 @@ class ProjectsController < ApplicationController menu = [] menu.append(menu_hash_by_name("home")) - menu.append(menu_hash_by_name("code")) if @project.has_menu_permission("code") + menu.append(menu_hash_by_name("code")) menu.append(menu_hash_by_name("issues")) if @project.has_menu_permission("issues") menu.append(menu_hash_by_name("pulls")) if @project.has_menu_permission("pulls") menu.append(menu_hash_by_name("devops")) if @project.has_menu_permission("devops") @@ -26,7 +26,7 @@ class ProjectsController < ApplicationController scope = Projects::ListQuery.call(params) # @projects = kaminari_paginate(scope) - @projects = paginate scope.includes(:project_category, :project_language, :repository, :project_educoder, :owner) + @projects = paginate scope.includes(:project_category, :project_language, :repository, :project_educoder, :owner, :project_units) category_id = params[:category_id] @total_count = diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index b66a5373..cd07803d 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -18,7 +18,6 @@ class RepositoriesController < ApplicationController # 新版项目详情 def detail - return render_not_found unless @project.has_menu_permission("code") @user = current_user @result = Repositories::DetailService.call(@owner, @repository, @user) @project_fork_id = @project.try(:forked_from_project_id) diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index bb031c7b..7e5e94d5 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -1,6 +1,11 @@ class SettingsController < ApplicationController def show - @old_projects_url = nil + @old_projects_url = nil @old_projects_url = "https://www.trustie.net/users/#{current_user.try(:login)}/projects" if User.current.logged? + + @add = Site.add + @personal = User.current.logged? ? Site.personal : [] + + # @sites = Site.group(:site_type).select(:name, :url, :key) end end diff --git a/app/models/site.rb b/app/models/site.rb new file mode 100644 index 00000000..0ed8d802 --- /dev/null +++ b/app/models/site.rb @@ -0,0 +1,23 @@ +# == Schema Information +# +# Table name: sites +# +# id :integer not null, primary key +# name :string(255) +# url :string(255) +# key :string(255) +# site_type :integer +# created_at :datetime not null +# updated_at :datetime not null +# + +class Site < ApplicationRecord + # add: 添加类链接 + # personal: 个人名下类链接, + # common: 普通链接 + enum site_type: { add: 0, personal: 1, common: 2 } + + def self.set_default + + end +end diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb index c6e5b213..f014b8d7 100644 --- a/app/services/projects/create_service.rb +++ b/app/services/projects/create_service.rb @@ -46,7 +46,6 @@ class Projects::CreateService < ApplicationService { hidden: !repo_is_public, user_id: params[:user_id], - website: params[:website], identifier: params[:repository_name] } end diff --git a/app/views/admins/laboratories/shared/_laboratory_item.html.erb b/app/views/admins/laboratories/shared/_laboratory_item.html.erb index 8fdf9c72..b9fa9c30 100644 --- a/app/views/admins/laboratories/shared/_laboratory_item.html.erb +++ b/app/views/admins/laboratories/shared/_laboratory_item.html.erb @@ -9,11 +9,11 @@ <% end %> - <% if school && school.identifier.present? %> - <%= link_to school.identifier.to_s, statistics_college_path(school.identifier), target: '_blank' %> - <% else %> + <%# if school && school.identifier.present? %> + <%#= link_to school.identifier.to_s, statistics_college_path(school.identifier), target: '_blank' %> + <%# else %> -- - <% end %> + <%# end %>
diff --git a/app/views/settings/show.json.jbuilder b/app/views/settings/show.json.jbuilder index 7de12345..4202283b 100644 --- a/app/views/settings/show.json.jbuilder +++ b/app/views/settings/show.json.jbuilder @@ -47,5 +47,12 @@ json.setting do json.new_course default_course_links json.old_projects_url @old_projects_url + json.add do + json.array! @add, :name, :url, :key + end + + json.personal do + json.array! @personal, :name, :url, :key + end end diff --git a/config/routes.rb b/config/routes.rb index f505003c..24cd6b63 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -23,7 +23,6 @@ Rails.application.routes.draw do resources :edu_settings - resources :edu_settings scope '/api' do namespace :ci do resources :languages, only: [:index, :show] do @@ -382,7 +381,7 @@ Rails.application.routes.draw do end end - resource :repositories, path: '/', only: [:show, :create, :edit] do + resource :repositories, path: '/', only: [:show, :create, :edit] do member do get :files get :detail diff --git a/db/migrate/20210322084619_create_sites.rb b/db/migrate/20210322084619_create_sites.rb new file mode 100644 index 00000000..e05784ec --- /dev/null +++ b/db/migrate/20210322084619_create_sites.rb @@ -0,0 +1,12 @@ +class CreateSites < ActiveRecord::Migration[5.2] + def change + create_table :sites do |t| + t.string :name, comment: "中文名称" + t.string :url, comment: "具体链接" + t.string :key, comment: "标识" + t.integer :site_type, comment: "分类,按照分类编排链接" + + t.timestamps + end + end +end