diff --git a/app/controllers/admins/topic/glcc_news_controller.rb b/app/controllers/admins/topic/glcc_news_controller.rb
new file mode 100644
index 000000000..3c1769e5f
--- /dev/null
+++ b/app/controllers/admins/topic/glcc_news_controller.rb
@@ -0,0 +1,57 @@
+class Admins::Topic::GlccNewsController < Admins::Topic::BaseController
+ before_action :find_glcc, only: [:edit, :update, :destroy]
+
+ def index
+ q = ::Topic::GlccNews.ransack(title_cont: params[:search])
+ glcc_news = q.result(distinct: true)
+ @glcc_news = paginate(glcc_news)
+ end
+
+ def new
+ @glcc = ::Topic::GlccNews.new
+ end
+
+ def create
+ @glcc = ::Topic::GlccNews.new(glcc_params)
+ if @glcc.save
+ redirect_to admins_topic_glcc_news_index_path
+ flash[:success] = "新增新闻稿成功"
+ else
+ redirect_to admins_topic_glcc_news_index_path
+ flash[:danger] = "新增新闻稿失败"
+ end
+ end
+
+ def edit
+ end
+
+ def update
+ @glcc.attributes = glcc_params
+ if @glcc.save
+ redirect_to admins_topic_glcc_news_index_path
+ flash[:success] = "更新新闻稿成功"
+ else
+ redirect_to admins_topic_glcc_news_index_path
+ flash[:danger] = "更新新闻稿失败"
+ end
+ end
+
+ def destroy
+ if @glcc.destroy
+ redirect_to admins_topic_glcc_news_index_path
+ flash[:success] = "删除新闻稿成功"
+ else
+ redirect_to admins_topic_glcc_news_index_path
+ flash[:danger] = "删除新闻稿失败"
+ end
+ end
+
+ private
+ def find_glcc
+ @glcc = ::Topic::GlccNews.find_by_id(params[:id])
+ end
+
+ def glcc_params
+ params.require(:topic_glcc_news).permit(:title, :uuid, :url, :order_index)
+ end
+end
\ No newline at end of file
diff --git a/app/controllers/concerns/login_helper.rb b/app/controllers/concerns/login_helper.rb
index d8f2445fb..e608b7833 100644
--- a/app/controllers/concerns/login_helper.rb
+++ b/app/controllers/concerns/login_helper.rb
@@ -108,7 +108,11 @@ module LoginHelper
def sync_pwd_to_gitea!(user, hash={})
return true if user.is_sync_pwd?
- sync_params = { email: user.mail }
+ sync_params = {
+ login_name: user.name,
+ source_id: 0,
+ email: user.mail
+ }
interactor = Gitea::User::UpdateInteractor.call(user.login, sync_params.merge(hash))
if interactor.success?
Rails.logger.info "########_ login is #{user.login} sync_pwd_to_gitea success _########"
diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb
index 704ffd9f5..f3eedd0a1 100644
--- a/app/controllers/settings_controller.rb
+++ b/app/controllers/settings_controller.rb
@@ -4,6 +4,7 @@ class SettingsController < ApplicationController
get_navbar
get_add_menu
get_common_menu
+ get_sub_competitions
get_personal_menu
get_third_party
get_top_system_notification
@@ -13,7 +14,7 @@ class SettingsController < ApplicationController
def get_navbar
@navbar = default_laboratory.navbar
if User.current.logged?
- pernal_index = {"name"=>"个人主页", "link"=>get_site_url("link", "/current_user"), "hidden"=>false}
+ pernal_index = {"name"=>"个人主页", "link"=>get_site_url("url", "#{Rails.application.config_for(:configuration)['platform_url']}/current_user"), "hidden"=>false}
@navbar << pernal_index
end
end
@@ -29,6 +30,15 @@ class SettingsController < ApplicationController
end
end
+ def get_sub_competitions
+ @sub_competitions = []
+ Site.competition.pluck(:key).uniq.each do |key|
+ hash = {"identifier": "#{key.to_s}"}
+ hash.merge!("list": Site.competition.where(key: key).select(:id, :name, :url, :key).to_a.map(&:serializable_hash))
+ @sub_competitions << hash
+ end
+ end
+
def get_common_menu
@common = {}
Site.common.select(:url, :key).each do |site|
diff --git a/app/models/site.rb b/app/models/site.rb
index 755fe3866..a8b725ef6 100644
--- a/app/models/site.rb
+++ b/app/models/site.rb
@@ -15,7 +15,7 @@ class Site < ApplicationRecord
# add: 添加类链接
# personal: 个人名下类链接,
# common: 普通链接
- enum site_type: { add: 0, personal: 1, common: 2 }
+ enum site_type: { add: 0, personal: 1, common: 2, competition: 3 }
scope :by_search, -> (keyword){ where("name LIKE :keyword OR url LIKE :keyword", keyword: "%#{strip_param(keyword)}%") unless strip_param(keyword).blank? }
scope :by_site_type, -> (site_type){ where(site_type: strip_param(site_type)) unless strip_param(site_type).blank? }
diff --git a/app/models/topic.rb b/app/models/topic.rb
index 13bf7b5bd..e464859ec 100644
--- a/app/models/topic.rb
+++ b/app/models/topic.rb
@@ -35,6 +35,8 @@ class Topic < ApplicationRecord
'Topic::ExcellentProject'
when 'experience_forum'
'Topic::ExperienceForum'
+ when "glcc_news"
+ 'Topic::GlccNews'
when 'pinned_forum'
'Topic::PinnedForum'
end
diff --git a/app/models/topic/glcc_news.rb b/app/models/topic/glcc_news.rb
new file mode 100644
index 000000000..6b707bf07
--- /dev/null
+++ b/app/models/topic/glcc_news.rb
@@ -0,0 +1,17 @@
+# == Schema Information
+#
+# Table name: topics
+#
+# id :integer not null, primary key
+# type :string(255)
+# title :string(255)
+# uuid :integer
+# image_url :string(255)
+# url :string(255)
+# order_index :integer
+#
+
+# GLCC 新闻稿
+class Topic::GlccNews < Topic
+
+end
\ No newline at end of file
diff --git a/app/views/admins/shared/_sidebar.html.erb b/app/views/admins/shared/_sidebar.html.erb
index 3e659395a..055988731 100644
--- a/app/views/admins/shared/_sidebar.html.erb
+++ b/app/views/admins/shared/_sidebar.html.erb
@@ -42,7 +42,11 @@
<%= sidebar_item(admins_topic_cooperators_path, '合作伙伴管理', icon: 'user', controller: 'admins-topic-cooperators') %>
<% end %>
-
+
+ <%= sidebar_item_group('#setting-glcc', 'GLCC配置', icon: 'fire') do %>
+ <%= sidebar_item(admins_topic_glcc_news_index_path, '新闻稿管理', icon: 'edit', controller: 'admins-topic-glcc_news') %>
+ <% end %>
+
<%= sidebar_item_group('#setting-submenu', '网站建设', icon: 'cogs') do %>
<%= sidebar_item(admins_faqs_path, 'FAQ', icon: 'question-circle', controller: 'admins-faqs') %>
diff --git a/app/views/admins/topic/glcc_news/_form_modal.html.erb b/app/views/admins/topic/glcc_news/_form_modal.html.erb
new file mode 100644
index 000000000..15af2f27b
--- /dev/null
+++ b/app/views/admins/topic/glcc_news/_form_modal.html.erb
@@ -0,0 +1,44 @@
+
+
+
+
+ <%= form_for @glcc, url: {controller: "topic/glcc_news", action: "#{type}"} do |p| %>
+
+
+
+ 标题 *
+
+ <%= p.text_field :title,class: "form-control input-lg",required: true%>
+
+
+
+ 跳转地址 *
+
+ <%= p.text_field :url,class: "form-control input-lg",required: true%>
+
+
+
+ 帖子ID *
+
+ <%= p.text_field :uuid,class: "form-control input-lg",required: true%>
+
+
+
+ 排序等级
+
+ <%= p.number_field :order_index, class: "form-control",placeholder: ""%>
+
+
+
+ <% end %>
+
+
+
\ No newline at end of file
diff --git a/app/views/admins/topic/glcc_news/_list.html.erb b/app/views/admins/topic/glcc_news/_list.html.erb
new file mode 100644
index 000000000..783910339
--- /dev/null
+++ b/app/views/admins/topic/glcc_news/_list.html.erb
@@ -0,0 +1,33 @@
+
+
+
+ 序号
+ 标题
+ 跳转地址
+ 帖子ID
+ 排序等级
+ 操作
+
+
+
+ <% if glcc_news.present? %>
+ <% glcc_news.each_with_index do |news, index| %>
+
+ <%= list_index_no((params[:page] || 1).to_i, index) %>
+ <%= news.title %>
+ <%= news.url %>
+ <%= news.uuid %>
+ <%= news.order_index %>
+
+ <%= link_to "编辑", edit_admins_topic_glcc_news_path(news), remote: true, class: "action" %>
+ <%= link_to "删除", admins_topic_glcc_news_path(news), method: :delete, data:{confirm: "确认删除的吗?"}, class: "action" %>
+
+
+ <% end %>
+ <% else %>
+ <%= render 'admins/shared/no_data_for_table' %>
+ <% end %>
+
+
+
+<%= render partial: 'admins/shared/paginate', locals: { objects: glcc_news } %>
\ No newline at end of file
diff --git a/app/views/admins/topic/glcc_news/edit.js.erb b/app/views/admins/topic/glcc_news/edit.js.erb
new file mode 100644
index 000000000..64ef542eb
--- /dev/null
+++ b/app/views/admins/topic/glcc_news/edit.js.erb
@@ -0,0 +1,2 @@
+$("#glcc-news-modals").html("<%= j render(partial: 'admins/topic/glcc_news/form_modal', locals: {type: 'update'}) %>")
+$(".glcc-news-change-modal").modal('show');
\ No newline at end of file
diff --git a/app/views/admins/topic/glcc_news/index.html.erb b/app/views/admins/topic/glcc_news/index.html.erb
new file mode 100644
index 000000000..8749fa104
--- /dev/null
+++ b/app/views/admins/topic/glcc_news/index.html.erb
@@ -0,0 +1,18 @@
+<% define_admin_breadcrumbs do %>
+ <% add_admin_breadcrumb('新闻稿管理') %>
+<% end %>
+
+
+ <%= form_tag(admins_topic_glcc_news_index_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_topic_glcc_news_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %>
+
+
+
+ <%= render partial: 'admins/topic/glcc_news/list', locals: { glcc_news: @glcc_news } %>
+
+
+
diff --git a/app/views/admins/topic/glcc_news/index.js.erb b/app/views/admins/topic/glcc_news/index.js.erb
new file mode 100644
index 000000000..f7db13698
--- /dev/null
+++ b/app/views/admins/topic/glcc_news/index.js.erb
@@ -0,0 +1 @@
+$('.glcc-news-list-container').html("<%= j( render partial: 'admins/topic/glcc_news/list', locals: { glcc_news: @glcc_news } ) %>");
\ No newline at end of file
diff --git a/app/views/admins/topic/glcc_news/new.js.erb b/app/views/admins/topic/glcc_news/new.js.erb
new file mode 100644
index 000000000..e03e5acd9
--- /dev/null
+++ b/app/views/admins/topic/glcc_news/new.js.erb
@@ -0,0 +1,2 @@
+$("#glcc-news-modals").html("<%= j render(partial: 'admins/topic/glcc_news/form_modal', locals: {type: 'create'}) %>")
+$(".glcc-news-change-modal").modal('show');
\ No newline at end of file
diff --git a/app/views/settings/show.json.jbuilder b/app/views/settings/show.json.jbuilder
index 4c57d573f..abe8207eb 100644
--- a/app/views/settings/show.json.jbuilder
+++ b/app/views/settings/show.json.jbuilder
@@ -51,6 +51,10 @@ json.setting do
json.array! @add
end
+ json.sub_competitions do
+ json.array! @sub_competitions
+ end
+
json.personal do
json.array! @personal
end
diff --git a/app/views/topics/_glcc_news.json.jbuilder b/app/views/topics/_glcc_news.json.jbuilder
new file mode 100644
index 000000000..0147aff3f
--- /dev/null
+++ b/app/views/topics/_glcc_news.json.jbuilder
@@ -0,0 +1,4 @@
+json.(glcc_news, :id, :title, :url, :uuid)
+request_memo = Forum::Memos::GetService.call(glcc_news&.uuid)
+json.visits request_memo.nil? ? 0 : request_memo["memo"]["viewed_count"]
+json.created_time request_memo.nil? ? format_time(Time.now) : request_memo["memo"]["published_time"]
\ No newline at end of file
diff --git a/app/views/topics/index.json.jbuilder b/app/views/topics/index.json.jbuilder
index 102da6b11..26a4f27d5 100644
--- a/app/views/topics/index.json.jbuilder
+++ b/app/views/topics/index.json.jbuilder
@@ -17,6 +17,8 @@ json.topics do
json.partial! "excellent_project", locals: {excellent_project: topic}
when "Topic::ExperienceForum"
json.partial! "experience_forum", locals: {experience_forum: topic}
+ when "Topic::GlccNews"
+ json.partial! "glcc_news", locals: {glcc_news: topic}
when "Topic::PinnedForum"
json.partial! "pinned_forum", locals: {pinned_forum: topic}
else
@@ -39,6 +41,8 @@ json.topics do
json.partial! "excellent_project", locals: {excellent_project: topic}
when "Topic::ExperienceForum"
json.partial! "experience_forum", locals: {experience_forum: topic}
+ when "Topic::GlccNews"
+ json.partial! "glcc_news", locals: {glcc_news: topic}
when "Topic::PinnedForum"
json.partial! "pinned_forum", locals: {pinned_forum: topic}
else
diff --git a/config/routes.rb b/config/routes.rb
index 21caf682e..eb1c09a8f 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -690,6 +690,7 @@ Rails.application.routes.draw do
resources :cooperators
resources :excellent_projects
resources :experience_forums
+ resources :glcc_news
resources :pinned_forums
end
resources :project_statistics, only: [:index] do