diff --git a/app/assets/stylesheets/admins/common.scss b/app/assets/stylesheets/admins/common.scss index 510e7f8f1..8d48a67ed 100644 --- a/app/assets/stylesheets/admins/common.scss +++ b/app/assets/stylesheets/admins/common.scss @@ -135,5 +135,6 @@ padding: 10px 20px 0; background: #fff; } + .mt-10{margin-top: 10px;} } diff --git a/app/controllers/admins/project_categories_controller.rb b/app/controllers/admins/project_categories_controller.rb new file mode 100644 index 000000000..944a2cf04 --- /dev/null +++ b/app/controllers/admins/project_categories_controller.rb @@ -0,0 +1,83 @@ +class Admins::ProjectCategoriesController < Admins::BaseController + before_action :get_category, only: [:edit,:update, :destroy] + before_action :validate_names, only: [:create, :update] + + def index + sort_by = params[:sort_by] ||= 'created_at' + sort_direction = params[:sort_direction] ||= 'desc' + q = ProjectCategory.ransack(name_cont: params[:name]) + project_categories = q.result(distinct: true).order("#{sort_by} #{sort_direction}") + @project_categories = paginate(project_categories) + + end + + def new + @project_category = ProjectCategory.new + end + + def edit + end + + def create + max_position_items = ProjectCategory.select(:id, :position).pluck(:position).reject!(&:blank?) + max_position = max_position_items.present? ? max_position_items.max.to_i : 0 + + @project_category = ProjectCategory.new(name: @name,position: max_position) + if @project_category.save + redirect_to admins_project_categories_path + flash[:success] = '创建成功' + else + redirect_to admins_project_categories_path + flash[:danger] = '创建失败' + end + end + + def update + if @project_category.update_attribute(:name, @name) + redirect_to admins_project_categories_path + flash[:success] = '更新成功' + else + redirect_to admins_project_categories_path + flash[:success] = '更新失败' + end + end + + def destroy + if @project_language.destroy + redirect_to admins_project_categories_path + flash[:success] = "删除成功" + else + redirect_to admins_project_categories_path + flash[:danger] = "删除失败" + end + end + + private + + def get_category + @project_category = ProjectCategory.find_by(id: params[:id]) + unless @project_category.present? + redirect_to admins_project_categories_path + flash[:danger] = "分类不存在" + end + end + + def check_language_present?(name) + return true if name.blank? + name_downcase = name.downcase + name_upcase = name.upcase + name_first_big = name.capitalize + ProjectCategory.exists?(name: name_downcase) || ProjectCategory.exists?(name: name_upcase) || ProjectCategory.exists?(name: name_first_big) + end + + def validate_names + @name = params[:project_category][:name].to_s.first(64) + if @name.blank? + redirect_to admins_project_categories_path + flash[:danger] = '名称不能为空' + elsif check_language_present?(@name) && @project_category.blank? + redirect_to admins_project_categories_path + flash[:danger] = '分类已存在' + end + end +end \ No newline at end of file diff --git a/app/controllers/admins/project_ignores_controller.rb b/app/controllers/admins/project_ignores_controller.rb new file mode 100644 index 000000000..427ee86b8 --- /dev/null +++ b/app/controllers/admins/project_ignores_controller.rb @@ -0,0 +1,120 @@ +class Admins::ProjectIgnoresController < Admins::BaseController + before_action :set_ignore, only: [:edit,:update, :destroy,:show] + before_action :validate_params, only: [:create, :update] + + def index + sort_by = params[:sort_by] ||= 'created_at' + sort_direction = params[:sort_direction] ||= 'desc' + q = Ignore.ransack(name_cont: params[:search]) + project_ignores = q.result(distinct: true).order("#{sort_by} #{sort_direction}") + @project_ignores = paginate(project_ignores) + end + + def new + @project_ignore = Ignore.new + end + + def show + end + + def create + # conditions = params[:license][:conditions_array].reject(&:blank?).join(",") if params[:license][:conditions_array].present? + # permissions = params[:license][:permissions_array].reject(&:blank?).join(",") if params[:license][:permissions_array].present? + # limitations = params[:license][:limitations_array].reject(&:blank?).join(",") if params[:license][:limitations_array].present? + # max_position_items = License.select(:id, :position).pluck(:position).reject!(&:blank?) + # max_position = max_position_items.present? ? max_position_items.max.to_i : 0 + # other_params = { + # conditions: conditions.to_s, + # permissions: permissions.to_s, + # limitations: limitations.to_s, + # position: max_position + # } + @project_ignore = Ignore.new(ignore_params) + + if @project_ignore.save! + redirect_to admins_project_ignores_path + flash[:success] = "创建成功" + else + render :new + flash[:danger] = "创建失败" + end + end + + def edit + + end + + def update + # conditions = params[:license][:conditions_array].reject(&:blank?).join(",") if params[:license][:conditions_array].present? + # permissions = params[:license][:permissions_array].reject(&:blank?).join(",") if params[:license][:permissions_array].present? + # limitations = params[:license][:limitations_array].reject(&:blank?).join(",") if params[:license][:limitations_array].present? + + # other_params = { + # conditions: conditions.to_s, + # permissions: permissions.to_s, + # limitations: limitations.to_s + # } + if @project_ignore.update_attributes(ignore_params) + redirect_to admins_project_ignores_path + flash[:success] = "更新成功" + else + render :edit + flash[:danger] = "更新失败" + end + end + + def destroy + if @project_ignore.present? + if @project_ignore.destroy + redirect_to admins_project_ignores_path + flash[:success] = "删除成功" + else + redirect_to admins_project_ignores_path + flash[:success] = "删除失败" + end + else + redirect_to admins_project_ignores_path + flash[:success] = "删除失败:许可证已被项目引用" + end + end + + # def move + # cate_opt = params[:opr] + # cate_position = @project_license.position.to_i + # move_status = up_and_down(cate_opt,@project_license,cate_position,"license") + # if move_status == 0 + # @c_msg = "移动成功" + # else + # @c_msg = "移动失败" + # end + # end + + private + def set_ignore + @project_ignore = Ignore.find_by_id(params[:id]) + end + + def ignore_params + params.require(:ignore).permit(:name,:content) + end + + def validate_params + name = params[:ignore][:name] + if name.blank? + flash[:danger] = "名称不允许为空" + redirect_to admins_project_ignores_path + elsif check_ignore_present?(name) && @project_ignore.blank? + flash[:danger] = "创建失败:名称已存在" + redirect_to admins_project_ignores_path + end + end + + def check_ignore_present?(name) + return true if name.blank? + name_downcase = name.downcase + name_upcase = name.upcase + name_first_big = name.capitalize + Ignore.exists?(name: name_downcase) || Ignore.exists?(name: name_upcase) || Ignore.exists?(name: name_first_big) + end + +end diff --git a/app/controllers/admins/project_languages_controller.rb b/app/controllers/admins/project_languages_controller.rb new file mode 100644 index 000000000..e188b75ef --- /dev/null +++ b/app/controllers/admins/project_languages_controller.rb @@ -0,0 +1,82 @@ +class Admins::ProjectLanguagesController < Admins::BaseController + before_action :get_language, only: [:edit,:update, :destroy] + before_action :validate_names, only: [:create, :update] + + def index + sort_by = params[:sort_by] ||= 'created_at' + sort_direction = params[:sort_direction] ||= 'desc' + q = ProjectLanguage.ransack(name_cont: params[:search]) + project_languages = q.result(distinct: true).order("#{sort_by} #{sort_direction}") + @project_languages = paginate(project_languages) + + end + + def new + @project_language = ProjectLanguage.new + end + + def edit + end + + def create + max_position_items = ProjectLanguage.select(:id, :position).pluck(:position).reject!(&:blank?) + max_position = max_position_items.present? ? max_position_items.max.to_i : 0 + @project_language = ProjectLanguage.new(name: @name,position:max_position) + if @project_language.save + redirect_to admins_project_languages_path + flash[:success] = '创建成功' + else + redirect_to admins_project_languages_path + flash[:danger] = '创建失败' + end + end + + def update + if @project_language.update_attribute(:name, @name) + redirect_to admins_project_languages_path + flash[:success] = '更新成功' + else + redirect_to admins_project_languages_path + flash[:success] = '更新失败' + end + end + + def destroy + if @project_language.destroy + redirect_to admins_project_languages_path + flash[:success] = "项目语言删除成功" + else + redirect_to admins_project_languages_path + flash[:danger] = "项目语言删除失败" + end + end + + private + + def get_language + @project_language = ProjectLanguage.find_by(id: params[:id]) + unless @project_language.present? + redirect_to admins_project_languages_path + flash[:danger] = "项目语言不存在" + end + end + + def check_language_present?(name) + return true if name.blank? + name_downcase = name.downcase + name_upcase = name.upcase + name_first_big = name.capitalize + ProjectLanguage.exists?(name: name_downcase) || ProjectLanguage.exists?(name: name_upcase) || ProjectLanguage.exists?(name: name_first_big) + end + + def validate_names + @name = params[:project_language][:name].to_s.first(64) + if @name.blank? + redirect_to admins_project_languages_path + flash[:danger] = '名称不能为空' + elsif check_language_present?(@name) && @project_language.blank? + redirect_to admins_project_languages_path + flash[:danger] = '项目语言已存在' + end + end +end \ No newline at end of file diff --git a/app/controllers/admins/project_licenses_controller.rb b/app/controllers/admins/project_licenses_controller.rb new file mode 100644 index 000000000..bc5789026 --- /dev/null +++ b/app/controllers/admins/project_licenses_controller.rb @@ -0,0 +1,120 @@ +class Admins::ProjectLicensesController < Admins::BaseController + before_action :set_license, only: [:edit,:update, :destroy,:show] + before_action :validate_params, only: [:create, :update] + + def index + sort_by = params[:sort_by] ||= 'created_at' + sort_direction = params[:sort_direction] ||= 'desc' + q = License.ransack(name_cont: params[:search]) + project_licenses = q.result(distinct: true).order("#{sort_by} #{sort_direction}") + @project_licenses = paginate(project_licenses) + end + + def new + @project_license = License.new + end + + def show + end + + def create + # conditions = params[:license][:conditions_array].reject(&:blank?).join(",") if params[:license][:conditions_array].present? + # permissions = params[:license][:permissions_array].reject(&:blank?).join(",") if params[:license][:permissions_array].present? + # limitations = params[:license][:limitations_array].reject(&:blank?).join(",") if params[:license][:limitations_array].present? + # max_position_items = License.select(:id, :position).pluck(:position).reject!(&:blank?) + # max_position = max_position_items.present? ? max_position_items.max.to_i : 0 + # other_params = { + # conditions: conditions.to_s, + # permissions: permissions.to_s, + # limitations: limitations.to_s, + # position: max_position + # } + @project_license = License.new(license_params) + + if @project_license.save! + redirect_to admins_project_licenses_path + flash[:success] = "创建成功" + else + render :new + flash[:danger] = "创建失败" + end + end + + def edit + + end + + def update + # conditions = params[:license][:conditions_array].reject(&:blank?).join(",") if params[:license][:conditions_array].present? + # permissions = params[:license][:permissions_array].reject(&:blank?).join(",") if params[:license][:permissions_array].present? + # limitations = params[:license][:limitations_array].reject(&:blank?).join(",") if params[:license][:limitations_array].present? + + # other_params = { + # conditions: conditions.to_s, + # permissions: permissions.to_s, + # limitations: limitations.to_s + # } + if @project_license.update_attributes(license_params) + redirect_to admins_project_licenses_path + flash[:success] = "更新成功" + else + render :edit + flash[:danger] = "更新失败" + end + end + + def destroy + if @project_license.present? + if @project_license.destroy + redirect_to admins_project_licenses_path + flash[:success] = "删除成功" + else + redirect_to admins_project_licenses_path + flash[:success] = "删除失败" + end + else + redirect_to admins_project_licenses_path + flash[:success] = "删除失败:许可证已被项目引用" + end + end + + # def move + # cate_opt = params[:opr] + # cate_position = @project_license.position.to_i + # move_status = up_and_down(cate_opt,@project_license,cate_position,"license") + # if move_status == 0 + # @c_msg = "移动成功" + # else + # @c_msg = "移动失败" + # end + # end + + private + def set_license + @project_license = License.find_by_id(params[:id]) + end + + def license_params + params.require(:license).permit(:name,:content) + end + + def validate_params + name = params[:license][:name] + if name.blank? + flash[:danger] = "名称不允许为空" + redirect_to admins_project_licenses_path + elsif check_license_present?(name) && @project_license.blank? + flash[:danger] = "创建失败:名称已存在" + redirect_to admins_project_licenses_path + end + end + + def check_license_present?(name) + return true if name.blank? + name_downcase = name.downcase + name_upcase = name.upcase + name_first_big = name.capitalize + License.exists?(name: name_downcase) || License.exists?(name: name_upcase) || License.exists?(name: name_first_big) + end + +end diff --git a/app/controllers/admins/projects_controller.rb b/app/controllers/admins/projects_controller.rb index 53d94fd9b..2ef79a8e9 100644 --- a/app/controllers/admins/projects_controller.rb +++ b/app/controllers/admins/projects_controller.rb @@ -1,10 +1,11 @@ class Admins::ProjectsController < Admins::BaseController def index - default_sort('created_at', 'desc') + sort_by = params[:sort_by] ||= 'created_on' + sort_direction = params[:sort_direction] ||= 'desc' search = params[:search].to_s.strip - projects = Project.where("name like ?", "%#{search}%") + projects = Project.where("name like ?", "%#{search}%").order("#{sort_by} #{sort_direction}") @projects = paginate projects.includes(:owner, :members, :issues, :versions, :attachments, :project_score) end @@ -21,5 +22,4 @@ class Admins::ProjectsController < Admins::BaseController render_delete_success end end - end \ No newline at end of file diff --git a/app/controllers/admins/users_controller.rb b/app/controllers/admins/users_controller.rb index dee37b0ba..98f0a6bfb 100644 --- a/app/controllers/admins/users_controller.rb +++ b/app/controllers/admins/users_controller.rb @@ -4,7 +4,7 @@ class Admins::UsersController < Admins::BaseController params[:sort_direction] = params[:sort_direction].presence || 'desc' users = Admins::UserQuery.call(params) - @users = paginate users.includes(:user_extension) + @users = paginate users.includes(:user_extension, projects: :members) end def edit diff --git a/app/models/user.rb b/app/models/user.rb index a093665f3..e729b898e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -607,7 +607,7 @@ class User < ApplicationRecord end def projects_count - Project.joins(:members).where(members: { user_id: self.id }).select(:id).size + Project.includes(:members).joins(:members).where(members: { user_id: self.id }).select(:id).size end # 是否已经签到 diff --git a/app/views/admins/project_categories/_form_modal.html.erb b/app/views/admins/project_categories/_form_modal.html.erb new file mode 100644 index 000000000..fd20936b6 --- /dev/null +++ b/app/views/admins/project_categories/_form_modal.html.erb @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/app/views/admins/project_categories/_list.html.erb b/app/views/admins/project_categories/_list.html.erb new file mode 100644 index 000000000..1d3316817 --- /dev/null +++ b/app/views/admins/project_categories/_list.html.erb @@ -0,0 +1,33 @@ + + + + + + + + + + + + <% if project_categories.present? %> + <% project_categories.each_with_index do |project_category, index| %> + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
序号名称<%= sort_tag('项目数', name: 'projects_count', path: admins_project_categories_path) %><%= sort_tag('创建时间', name: 'created_at', path: admins_project_categories_path) %>操作
<%= list_index_no((params[:page] || 1).to_i, index) %> + <%= link_to(project_category.name, "/projects?category_id=#{project_category.id}", target: '_blank') %> + <%= project_category.projects_count %><%= project_category.created_at&.strftime('%Y-%m-%d %H:%M') %> + <%= link_to "编辑", edit_admins_project_category_path(project_category), remote: true, class: "action" %> + <%= link_to "删除", admins_project_category_path(project_category), method: :delete, data:{confirm: "确认删除的吗?"}, class: "action" %> +
+ +<%= render partial: 'admins/shared/paginate', locals: { objects: project_categories } %> \ No newline at end of file diff --git a/app/views/admins/project_categories/edit.js.erb b/app/views/admins/project_categories/edit.js.erb new file mode 100644 index 000000000..a8636cfce --- /dev/null +++ b/app/views/admins/project_categories/edit.js.erb @@ -0,0 +1,2 @@ +$("#project-category-modals").html("<%= j render(partial: 'admins/project_categories/form_modal', locals: {type: 'update'}) %>") +$(".project-category-change-modal").modal('show'); \ No newline at end of file diff --git a/app/views/admins/project_categories/index.html.erb b/app/views/admins/project_categories/index.html.erb new file mode 100644 index 000000000..b635cef43 --- /dev/null +++ b/app/views/admins/project_categories/index.html.erb @@ -0,0 +1,18 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('分类列表') %> +<% end %> + +
+ <%= form_tag(admins_project_categories_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> + <%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '名称检索') %> + <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> + + <% end %> + <%= link_to "新增", new_admins_project_category_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %> +
+ +
+ <%= render partial: 'admins/project_categories/list', locals: { project_categories: @project_categories } %> +
+
+
diff --git a/app/views/admins/project_categories/index.js.erb b/app/views/admins/project_categories/index.js.erb new file mode 100644 index 000000000..0a5ef2d13 --- /dev/null +++ b/app/views/admins/project_categories/index.js.erb @@ -0,0 +1 @@ +$('.project-category-list-container').html("<%= j( render partial: 'admins/project_categories/list', locals: { project_categories: @project_categories } ) %>"); \ No newline at end of file diff --git a/app/views/admins/project_categories/new.js.erb b/app/views/admins/project_categories/new.js.erb new file mode 100644 index 000000000..8266fd40c --- /dev/null +++ b/app/views/admins/project_categories/new.js.erb @@ -0,0 +1,2 @@ +$("#project-category-modals").html("<%= j render(partial: 'admins/project_categories/form_modal', locals: {type: 'create'}) %>") +$(".project-category-change-modal").modal('show'); \ No newline at end of file diff --git a/app/views/admins/project_ignores/_content.html.erb b/app/views/admins/project_ignores/_content.html.erb new file mode 100644 index 000000000..048feadb8 --- /dev/null +++ b/app/views/admins/project_ignores/_content.html.erb @@ -0,0 +1,9 @@ +
+
<%= @project_ignore.name %>
+ <%= link_to "返回", admins_project_ignores_path, class: "btn btn-default pull-right" %> +
+ +
+<%= @project_ignore.content.html_safe %> + +
\ No newline at end of file diff --git a/app/views/admins/project_ignores/_form.html.erb b/app/views/admins/project_ignores/_form.html.erb new file mode 100644 index 000000000..9a6ded0ba --- /dev/null +++ b/app/views/admins/project_ignores/_form.html.erb @@ -0,0 +1,38 @@ +
+
<%= type == "create" ? "新建" : "编辑" %>忽略文件
+ <%= link_to "返回", admins_project_ignores_path, class: "btn btn-default pull-right" %> +
+ +
+ <%= form_for @project_ignore, url: {controller: "project_ignores", action: "#{type}"} do |f| %> +
+ +
+ <%= f.text_field :name, class: "form-control input-lg", maxlength: "60", placeholder: "请输入忽略文件的全称" %> +
+ +
+
+ +
+ <%= f.text_area :content,class:"form-control", rows: "10", cols: "20",placeholer: "忽略文件的简要介绍,不得超过500字" %> +
+ + + +
+
+ <%= f.submit "确认", class: "btn btn-primary submit-btn" %> +
+ <% end %> +
\ No newline at end of file diff --git a/app/views/admins/project_ignores/_list.html.erb b/app/views/admins/project_ignores/_list.html.erb new file mode 100644 index 000000000..066ef8540 --- /dev/null +++ b/app/views/admins/project_ignores/_list.html.erb @@ -0,0 +1,45 @@ + + + + + + + <% +=begin%> + +<% +=end%> + + + + + + <% if project_ignores.present? %> + <% project_ignores.each_with_index do |project_ignore, index| %> + + + + + <% +=begin%> + +<% +=end%> + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
序号名称简介<%= sort_tag('项目数', name: 'projects_count', path: admins_project_licenses_path) %><%= sort_tag('创建时间', name: 'created_at', path: admins_project_licenses_path) %>操作
<%= list_index_no((params[:page] || 1).to_i, index) %> + <%= link_to project_ignore.name, admins_project_ignore_path(project_ignore.id), remote: true %> + + <%= project_ignore.content.to_s.truncate(200) %> + <%= project_license.projects_count %><%= project_ignore.created_at&.strftime('%Y-%m-%d %H:%M') %> + <%= link_to "编辑", edit_admins_project_ignore_path(project_ignore),remote: true, class: "action" %> + <%= link_to "删除", admins_project_ignore_path(project_ignore), method: :delete, data:{confirm: "确认删除的吗?"}, class: "action" %> +
+ +<%= render partial: 'admins/shared/paginate', locals: { objects: project_ignores } %> \ No newline at end of file diff --git a/app/views/admins/project_ignores/edit.js.erb b/app/views/admins/project_ignores/edit.js.erb new file mode 100644 index 000000000..36fe6852a --- /dev/null +++ b/app/views/admins/project_ignores/edit.js.erb @@ -0,0 +1 @@ +$("#admins-project-ignore-content").html("<%= j render partial: 'admins/project_ignores/form', locals:{type: 'update'} %>") \ No newline at end of file diff --git a/app/views/admins/project_ignores/index.html.erb b/app/views/admins/project_ignores/index.html.erb new file mode 100644 index 000000000..a9fc9982e --- /dev/null +++ b/app/views/admins/project_ignores/index.html.erb @@ -0,0 +1,18 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('git忽略文件') %> +<% end %> +
+
+ <%= form_tag(admins_project_ignores_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> + <%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '名称检索') %> + <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> + + <% end %> + <%= link_to "新增", new_admins_project_ignore_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %> +
+ +
+ <%= render partial: 'admins/project_ignores/list', locals: { project_ignores: @project_ignores } %> +
+
+ diff --git a/app/views/admins/project_ignores/index.js.erb b/app/views/admins/project_ignores/index.js.erb new file mode 100644 index 000000000..9d86113c1 --- /dev/null +++ b/app/views/admins/project_ignores/index.js.erb @@ -0,0 +1 @@ +$('.project-ignore-list-container').html("<%= j( render partial: 'admins/project_ignores/list', locals: { project_ignores: @project_ignores } ) %>"); \ No newline at end of file diff --git a/app/views/admins/project_ignores/new.js.erb b/app/views/admins/project_ignores/new.js.erb new file mode 100644 index 000000000..607a092e6 --- /dev/null +++ b/app/views/admins/project_ignores/new.js.erb @@ -0,0 +1 @@ +$("#admins-project-ignore-content").html("<%= j render partial: 'admins/project_ignores/form', locals:{type: 'create'} %>") \ No newline at end of file diff --git a/app/views/admins/project_ignores/show.js.erb b/app/views/admins/project_ignores/show.js.erb new file mode 100644 index 000000000..0c99dd7fd --- /dev/null +++ b/app/views/admins/project_ignores/show.js.erb @@ -0,0 +1 @@ +$("#admins-project-ignore-content").html("<%= j render partial: 'admins/project_ignores/content' %>") \ No newline at end of file diff --git a/app/views/admins/project_languages/_form_modal.html.erb b/app/views/admins/project_languages/_form_modal.html.erb new file mode 100644 index 000000000..79ceae969 --- /dev/null +++ b/app/views/admins/project_languages/_form_modal.html.erb @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/app/views/admins/project_languages/_list.html.erb b/app/views/admins/project_languages/_list.html.erb new file mode 100644 index 000000000..9afaca07c --- /dev/null +++ b/app/views/admins/project_languages/_list.html.erb @@ -0,0 +1,33 @@ + + + + + + + + + + + + <% if project_languages.present? %> + <% project_languages.each_with_index do |project_language, index| %> + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
序号名称<%= sort_tag('项目数', name: 'projects_count', path: admins_project_languages_path) %><%= sort_tag('创建时间', name: 'created_at', path: admins_project_languages_path) %>操作
<%= list_index_no((params[:page] || 1).to_i, index) %> + <%= link_to(project_language.name, "javascript:void(0)") %> + <%= project_language.projects_count %><%= project_language.created_at&.strftime('%Y-%m-%d %H:%M') %> + <%= link_to "编辑", edit_admins_project_language_path(project_language), remote: true, class: "action" %> + <%= link_to "删除", admins_project_language_path(project_language), method: :delete, data:{confirm: "确认删除的吗?"}, class: "action" %> +
+ +<%= render partial: 'admins/shared/paginate', locals: { objects: project_languages } %> \ No newline at end of file diff --git a/app/views/admins/project_languages/edit.js.erb b/app/views/admins/project_languages/edit.js.erb new file mode 100644 index 000000000..4bd5aef5a --- /dev/null +++ b/app/views/admins/project_languages/edit.js.erb @@ -0,0 +1,2 @@ +$("#project-language-modals").html("<%= j render(partial: 'admins/project_languages/form_modal', locals: {type: 'update'}) %>") +$(".project-language-change-modal").modal('show'); \ No newline at end of file diff --git a/app/views/admins/project_languages/index.html.erb b/app/views/admins/project_languages/index.html.erb new file mode 100644 index 000000000..ae1d81ee4 --- /dev/null +++ b/app/views/admins/project_languages/index.html.erb @@ -0,0 +1,18 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('项目语言') %> +<% end %> + +
+ <%= form_tag(admins_project_languages_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> + <%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '名称检索') %> + <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> + + <% end %> + <%= link_to "新增", new_admins_project_language_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %> +
+ +
+ <%= render partial: 'admins/project_languages/list', locals: { project_languages: @project_languages } %> +
+
+
diff --git a/app/views/admins/project_languages/index.js.erb b/app/views/admins/project_languages/index.js.erb new file mode 100644 index 000000000..3bd78628c --- /dev/null +++ b/app/views/admins/project_languages/index.js.erb @@ -0,0 +1 @@ +$('.project-language-list-container').html("<%= j( render partial: 'admins/project_languages/list', locals: { project_languages: @project_languages } ) %>"); \ No newline at end of file diff --git a/app/views/admins/project_languages/new.js.erb b/app/views/admins/project_languages/new.js.erb new file mode 100644 index 000000000..4b88b4f8b --- /dev/null +++ b/app/views/admins/project_languages/new.js.erb @@ -0,0 +1,2 @@ +$("#project-language-modals").html("<%= j render(partial: 'admins/project_languages/form_modal', locals: {type: 'create'}) %>") +$(".project-language-change-modal").modal('show'); \ No newline at end of file diff --git a/app/views/admins/project_licenses/_content.html.erb b/app/views/admins/project_licenses/_content.html.erb new file mode 100644 index 000000000..f25189a49 --- /dev/null +++ b/app/views/admins/project_licenses/_content.html.erb @@ -0,0 +1,9 @@ +
+
<%= @project_license.name %>
+ <%= link_to "返回", admins_project_licenses_path, class: "btn btn-default pull-right" %> +
+ +
+<%= @project_license.content.html_safe %> + +
\ No newline at end of file diff --git a/app/views/admins/project_licenses/_form.html.erb b/app/views/admins/project_licenses/_form.html.erb new file mode 100644 index 000000000..115b67935 --- /dev/null +++ b/app/views/admins/project_licenses/_form.html.erb @@ -0,0 +1,38 @@ +
+
<%= type == "create" ? "新建" : "编辑" %>开源许可证
+ <%= link_to "返回", admins_project_licenses_path, class: "btn btn-default pull-right" %> +
+ +
+ <%= form_for @project_license, url: {controller: "project_licenses", action: "#{type}"} do |f| %> +
+ +
+ <%= f.text_field :name, class: "form-control input-lg", maxlength: "60", placeholder: "请输入开源许可证的全称" %> +
+ +
+
+ +
+ <%= f.text_area :content,class:"form-control", rows: "10", cols: "20",placeholer: "许可证的简要介绍,不得超过500字" %> +
+ + + +
+
+ <%= f.submit "确认", class: "btn btn-primary submit-btn" %> +
+ <% end %> +
\ No newline at end of file diff --git a/app/views/admins/project_licenses/_list.html.erb b/app/views/admins/project_licenses/_list.html.erb new file mode 100644 index 000000000..1fa4f8d6b --- /dev/null +++ b/app/views/admins/project_licenses/_list.html.erb @@ -0,0 +1,45 @@ + + + + + + + <% +=begin%> + +<% +=end%> + + + + + + <% if project_licenses.present? %> + <% project_licenses.each_with_index do |project_license, index| %> + + + + + <% +=begin%> + +<% +=end%> + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
序号名称简介<%= sort_tag('项目数', name: 'projects_count', path: admins_project_licenses_path) %><%= sort_tag('创建时间', name: 'created_at', path: admins_project_licenses_path) %>操作
<%= list_index_no((params[:page] || 1).to_i, index) %> + <%= link_to project_license.name, admins_project_license_path(project_license.id), remote: true %> + + <%= project_license.content.to_s.truncate(200) %> + <%= project_license.projects_count %><%= project_license.created_at&.strftime('%Y-%m-%d %H:%M') %> + <%= link_to "编辑", edit_admins_project_license_path(project_license),remote: true, class: "action" %> + <%= link_to "删除", admins_project_license_path(project_license), method: :delete, data:{confirm: "确认删除的吗?"}, class: "action" %> +
+ +<%= render partial: 'admins/shared/paginate', locals: { objects: project_licenses } %> \ No newline at end of file diff --git a/app/views/admins/project_licenses/edit.js.erb b/app/views/admins/project_licenses/edit.js.erb new file mode 100644 index 000000000..ac48e7e15 --- /dev/null +++ b/app/views/admins/project_licenses/edit.js.erb @@ -0,0 +1 @@ +$("#admins-project-license-content").html("<%= j render partial: 'admins/project_licenses/form', locals:{type: 'update'} %>") \ No newline at end of file diff --git a/app/views/admins/project_licenses/index.html.erb b/app/views/admins/project_licenses/index.html.erb new file mode 100644 index 000000000..31e648006 --- /dev/null +++ b/app/views/admins/project_licenses/index.html.erb @@ -0,0 +1,18 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('开源许可证') %> +<% end %> +
+
+ <%= form_tag(admins_project_licenses_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> + <%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '名称检索') %> + <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> + + <% end %> + <%= link_to "新增", new_admins_project_license_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %> +
+ +
+ <%= render partial: 'admins/project_licenses/list', locals: { project_licenses: @project_licenses } %> +
+
+ diff --git a/app/views/admins/project_licenses/index.js.erb b/app/views/admins/project_licenses/index.js.erb new file mode 100644 index 000000000..670c34542 --- /dev/null +++ b/app/views/admins/project_licenses/index.js.erb @@ -0,0 +1 @@ +$('.project-license-list-container').html("<%= j( render partial: 'admins/project_licenses/list', locals: { project_licenses: @project_licenses } ) %>"); \ No newline at end of file diff --git a/app/views/admins/project_licenses/new.js.erb b/app/views/admins/project_licenses/new.js.erb new file mode 100644 index 000000000..ee1c173e2 --- /dev/null +++ b/app/views/admins/project_licenses/new.js.erb @@ -0,0 +1 @@ +$("#admins-project-license-content").html("<%= j render partial: 'admins/project_licenses/form', locals:{type: 'create'} %>") \ No newline at end of file diff --git a/app/views/admins/project_licenses/show.js.erb b/app/views/admins/project_licenses/show.js.erb new file mode 100644 index 000000000..eddc040e9 --- /dev/null +++ b/app/views/admins/project_licenses/show.js.erb @@ -0,0 +1 @@ +$("#admins-project-license-content").html("<%= j render partial: 'admins/project_licenses/content' %>") \ No newline at end of file diff --git a/app/views/admins/projects/shared/_list.html.erb b/app/views/admins/projects/shared/_list.html.erb index e2a6307ad..90c328792 100644 --- a/app/views/admins/projects/shared/_list.html.erb +++ b/app/views/admins/projects/shared/_list.html.erb @@ -12,7 +12,7 @@ 里程碑 成员 管理员 - <%= sort_tag('创建时间', name: 'created_at', path: admins_projects_path) %> + <%= sort_tag('创建时间', name: 'created_on', path: admins_projects_path) %> 操作 diff --git a/app/views/admins/shared/_sidebar.html.erb b/app/views/admins/shared/_sidebar.html.erb index d89e9a6f8..7287c0347 100644 --- a/app/views/admins/shared/_sidebar.html.erb +++ b/app/views/admins/shared/_sidebar.html.erb @@ -14,54 +14,18 @@ diff --git a/app/views/admins/users/index.html.erb b/app/views/admins/users/index.html.erb index 74c9215b2..37ca242e3 100644 --- a/app/views/admins/users/index.html.erb +++ b/app/views/admins/users/index.html.erb @@ -23,12 +23,20 @@ <%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: 'ID/姓名/邮箱/手机号检索') %> - <%= text_field_tag(:school_name, params[:school_name], class: 'form-control col-sm-2', placeholder: '学校/单位检索') %> + <% +=begin%> + <%= text_field_tag(:school_name, params[:school_name], class: 'form-control col-sm-2', placeholder: '学校/单位检索') %> +<% +=end%> <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> <% end %> <%= javascript_void_link '导入用户', class: 'btn btn-secondary btn-sm', data: { toggle: 'modal', target: '.admin-import-user-modal'} %> - <%= javascript_void_link '导入课堂成员', class: 'btn btn-secondary btn-sm ml-2', data: { toggle: 'modal', target: '.admin-import-course-member-modal'} %> + <% +=begin%> + <%= javascript_void_link '导入课堂成员', class: 'btn btn-secondary btn-sm ml-2', data: { toggle: 'modal', target: '.admin-import-course-member-modal'} %> +<% +=end%>
diff --git a/app/views/admins/users/shared/_user_list.html.erb b/app/views/admins/users/shared/_user_list.html.erb index 2949a087b..5c033d282 100644 --- a/app/views/admins/users/shared/_user_list.html.erb +++ b/app/views/admins/users/shared/_user_list.html.erb @@ -8,8 +8,7 @@ 角色 <%= sort_tag('创建于', name: 'created_on', path: admins_users_path) %> <%= sort_tag('最后登录', name: 'last_login_on', path: admins_users_path) %> - <%= sort_tag('经验值', name: 'experience', path: admins_users_path) %> - <%= sort_tag('金币', name: 'grade', path: admins_users_path) %> + 项目数 操作 @@ -28,8 +27,7 @@ <%= user.identity %> <%= display_text(user.created_on&.strftime('%Y-%m-%d %H:%M')) %> <%= display_text(user.last_login_on&.strftime('%Y-%m-%d %H:%M')) %> - <%= user.experience.to_i %> - <%= user.grade.to_i %> + <%= link_to user.projects_count, "/users/#{user.login}/projects", target: "_blank" %> <%= link_to '编辑', edit_admins_user_path(user), class: 'action' %> diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index f61aaba4f..91a77bf65 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -1,7 +1,7 @@ - EduCoder后台管理 + ForgePlus后台管理 diff --git a/config/routes.rb b/config/routes.rb index 8c124d658..af21e3bb1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,9 +2,9 @@ Rails.application.routes.draw do require 'sidekiq/web' require 'admin_constraint' - # mount Sidekiq::Web => '/sidekiq' + mount Sidekiq::Web => '/sidekiq' - mount Sidekiq::Web => '/sidekiq', :constraints => AdminConstraint.new + # mount Sidekiq::Web => '/sidekiq', :constraints => AdminConstraint.new get 'attachments/download/:id', to: 'attachments#show' get 'attachments/download/:id/:filename', to: 'attachments#show' @@ -389,6 +389,10 @@ Rails.application.routes.draw do get :visits_static end end + resources :project_languages + resources :project_categories + resources :project_licenses + resources :project_ignores resources :major_informations, only: [:index] resources :ec_templates, only: [:index, :destroy] do collection do diff --git a/public/favicon.ico b/public/favicon.ico old mode 100755 new mode 100644 index 9c65fe8c7..75a4c3dfd Binary files a/public/favicon.ico and b/public/favicon.ico differ