Compare commits

...

79 Commits

Author SHA1 Message Date
jasder 38f6254edc Merge branch 'develop' into dev_trustie_server 2021-05-15 10:20:14 +08:00
jasder acc4282c8e Merge branch 'sync_develop' into develop 2021-05-15 10:19:57 +08:00
jasder 27d9d806ce FIX update project bug 2021-05-15 10:19:25 +08:00
jasder 8a4b0ba966 Merge branch 'develop' into dev_trustie_server 2021-05-14 17:34:36 +08:00
jasder 5d91b6b3be ADD 页面置顶功能等功能
* ADD 页面置顶功能
* ADD FAQ快速入口
* 修复bug
2021-05-14 17:34:07 +08:00
jasder 8ee0acae85 set default desc sort for faqs api 2021-05-14 16:39:32 +08:00
jasder dac07bcae0 ADD 页面置顶功能、帮助文档快速入口 2021-05-14 16:23:19 +08:00
jasder b1abac201f FIX query columns bug with query recommend organization api 2021-05-13 15:06:41 +08:00
jasder e304dd0c98 FIX query recommend organization bug 2021-05-13 15:02:28 +08:00
jasder fe9201d9f6 FIX code bug 2021-05-13 14:56:58 +08:00
jasder c2d7d8289e FIX dismiss num for recommend projects api 2021-05-13 14:53:46 +08:00
jasder 2cca2c756e ADD recommend organizations api 2021-05-13 14:52:07 +08:00
jasder 84927c2361 FIX 解决大赛中点击项目跳转到forge平台,保持自动登陆的bug 2021-05-13 11:47:47 +08:00
jasder b568ac4e97 ADD title 2021-05-12 17:48:05 +08:00
jasder 91bbb58d4f FIX delete input readonly 2021-05-12 17:44:45 +08:00
jasder f278b38e6c Merge branch 'trustie_server' into dev_trustie_server 2021-05-12 17:01:59 +08:00
jasder 4023b8980e FIX 完善通过大赛点击项目链接自动注册关联Educoder平台账号的功能 2021-05-12 17:01:30 +08:00
jasder 1c1be18151 Merge branch 'dev_trustie_server' into trustie_server 2021-05-10 14:39:14 +08:00
jasder e5f591e509 Merge branch 'develop' into dev_trustie_server 2021-05-10 14:38:58 +08:00
jasder 3c61848a77 Merge branch 'sync_develop' into develop 2021-05-10 14:38:46 +08:00
jasder 23704dbae3 FIX get mirror url bug with get detail repo api 2021-05-10 14:38:39 +08:00
yystopf 27ee32054b 发布v3.0.3版本 2021-05-08 17:45:23 +08:00
jasder 3e3fd46cad Merge branch 'develop' into dev_trustie_server 2021-05-08 17:02:56 +08:00
jasder 7a752b177d Merge branch 'develop' into dev_trustie_server 2021-05-08 14:23:34 +08:00
jasder abbabfdefd Merge branch 'dev_trustie_server' into trustie_server 2021-04-30 17:13:33 +08:00
jasder edd76b9286 Merge branch 'develop' into dev_trustie_server 2021-04-30 17:13:18 +08:00
jasder a3ca94d433 Merge branch 'dev_trustie_server' into trustie_server 2021-04-29 23:23:55 +08:00
jasder 91a804caf7 Merge branch 'develop' into dev_trustie_server 2021-04-29 23:23:42 +08:00
jasder 663deae21b Merge branch 'dev_trustie_server' into trustie_server 2021-04-29 23:19:34 +08:00
jasder dae5c9690f Merge branch 'develop' into dev_trustie_server 2021-04-29 23:19:17 +08:00
jasder e65df07d79 Merge branch 'dev_trustie_server' into trustie_server 2021-04-29 19:27:55 +08:00
jasder 246b6b52ec Merge branch 'develop' into dev_trustie_server 2021-04-29 19:27:36 +08:00
jasder b9789183e3 Merge branch 'dev_trustie_server' into trustie_server 2021-04-29 19:17:03 +08:00
jasder 7cf2c6021f Merge branch 'develop' into dev_trustie_server 2021-04-29 19:13:12 +08:00
jasder e0f9a3d43d Merge branch 'develop' into dev_trustie_server 2021-04-29 18:50:11 +08:00
jasder c1ef39b262 Merge branch 'develop' into dev_trustie_server 2021-04-29 18:37:35 +08:00
jasder 51643dc02c Merge branch 'dev_trustie_server' into trustie_server 2021-04-29 10:42:12 +08:00
jasder a078c07b59 Merge branch 'develop' into dev_trustie_server 2021-04-29 10:41:59 +08:00
jasder b984790d5c Merge branch 'develop' into trustie_server 2021-04-28 21:17:43 +08:00
jasder 876591100e Merge branch 'develop' into dev_trustie_server 2021-04-28 21:17:36 +08:00
jasder ba9848ebe7 Merge branch 'develop' into dev_trustie_server 2021-04-27 18:24:41 +08:00
jasder 41c621cf55 Merge branch 'develop' into dev_trustie_server 2021-04-26 16:53:05 +08:00
jasder 09ac49dda5 Merge branch 'develop' into dev_trustie_server 2021-04-26 16:46:24 +08:00
jasder 341a810afc Merge branch 'develop' into dev_trustie_server 2021-04-23 17:54:13 +08:00
jasder 2282c52efb FIX update README.md 2021-04-23 17:33:19 +08:00
jasder 34edd78ae7 Merge branch 'develop' into dev_trustie_server 2021-04-23 17:21:34 +08:00
jasder 36fb5a118c Merge branch 'develop' into dev_trustie_server 2021-04-23 14:40:41 +08:00
jasder b756be1d6a Merge branch 'develop' into dev_trustie_server 2021-04-22 18:10:32 +08:00
jasder 348c2244f7 Merge branch 'develop' into dev_trustie_server 2021-04-22 16:45:40 +08:00
jasder 31738fc227 Merge branch 'develop' into dev_trustie_server 2021-04-22 16:43:04 +08:00
jasder a93c98fb7c Merge branch 'trustie_server' into dev_trustie_server 2021-04-22 16:39:03 +08:00
jasder 39193324e9 Merge branch 'develop' into dev_trustie_server 2021-04-22 16:38:58 +08:00
jasder 81743ce3bc Merge branch 'develop' into trustie_server 2021-04-20 19:07:56 +08:00
jasder e9ae536f04 Merge branch 'develop' into trustie_server 2021-04-20 19:06:40 +08:00
jasder 186955fe4a Merge branch 'develop' into trustie_server 2021-04-20 18:58:24 +08:00
jasder 8ce7fd95cb Merge branch 'develop' into trustie_server 2021-04-20 18:37:55 +08:00
jasder 0867e5130f Merge branch 'dev_trustie_server' into trustie_server 2021-04-20 11:37:25 +08:00
jasder db476a1a9b Merge branch 'develop' into dev_trustie_server 2021-04-20 11:37:08 +08:00
jasder fa1fd8a4ba Merge branch 'develop' into trustie_server 2021-04-19 20:39:29 +08:00
jasder 0d7a11f3ab Merge branch 'develop' into dev_trustie_server 2021-04-19 18:41:18 +08:00
jasder 879e45e106 Merge branch 'develop' into trustie_server 2021-04-13 16:40:23 +08:00
jasder b3b0f75e9b Merge branch 'develop' into trustie_server 2021-04-13 10:18:52 +08:00
jasder 5c8e561bd8 Merge branch 'develop' into trustie_server 2021-04-08 18:36:27 +08:00
jasder 2b0c987558 Merge branch 'develop' into trustie_server 2021-04-07 11:35:09 +08:00
jasder 6796805b21 Merge branch 'develop' into trustie_server 2021-04-02 18:58:08 +08:00
jasder 5752f19b2f FIX gug 2021-04-02 18:56:44 +08:00
jasder eb52f05417 集成educoder登陆 2021-04-02 18:46:15 +08:00
vilet.yy 786629dbff fix 2021-04-02 18:41:48 +08:00
vilet.yy 7a00541375 Merge branch 'develop' into hh_develop 2021-04-02 18:41:37 +08:00
vilet.yy 1d832a1723 fix 2021-04-02 18:38:08 +08:00
vilet.yy 80ce40e492 fix 2021-04-02 18:33:31 +08:00
vilet.yy 91f6dae56a fix 2021-04-02 18:24:20 +08:00
vilet.yy 8c5a834b14 Merge branch 'develop' into hh_develop 2021-04-02 18:22:32 +08:00
vilet.yy 57f420848e Merge branch 'develop' into hh_develop 2021-04-02 18:20:41 +08:00
vilet.yy fba58800a7 fix 2021-04-02 18:08:36 +08:00
vilet.yy c4a43c4392 add: need edit user password 2021-04-02 16:44:36 +08:00
vilet.yy 1153bd5ab6 fix: set redirect_uri 2021-04-02 09:43:18 +08:00
vilet.yy f732b0374c fix: ceshi 2021-04-02 09:23:11 +08:00
vilet.yy 0d97d7d4f0 add: educoder third party 2021-04-01 18:01:51 +08:00
42 changed files with 474 additions and 48 deletions

View File

@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.

View File

@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.

View File

@ -0,0 +1,3 @@
// Place all the styles related to the admins/faqs controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the helps/faqs controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -0,0 +1,58 @@
class Admins::FaqsController < Admins::BaseController
before_action :find_faq, only: [:edit,:update, :destroy]
def index
sort_by = params[:sort_by] ||= 'updated_at'
sort_direction = params[:sort_direction] ||= 'desc'
keyword = params[:keyword].to_s.strip
collection = Faq.search_question(keyword).order("#{sort_by} #{sort_direction}")
@faqs = paginate collection
end
def new
@faq = Faq.new
end
def edit
end
def update
begin
@faq.update!(faq_params)
flash[:success] = '修改成功'
rescue Exception
flash[:danger] = @faq.errors.full_messages.to_sentence
end
redirect_to admins_faqs_path
end
def destroy
@faq.destroy
redirect_to admins_faqs_path
flash[:success] = "删除成功"
end
def create
@faq = Faq.new(faq_params)
begin
@faq.save!
flash[:success] = '创建成功'
rescue Exception
flash[:danger] = @faq.errors.full_messages.to_sentence
end
redirect_to admins_faqs_path
end
private
def find_faq
@faq = Faq.find params[:id]
end
def faq_params
params.require(:faq).permit(:question, :url)
end
end

View File

@ -329,7 +329,6 @@ class ApplicationController < ActionController::Base
User.current = user
end
end
# if !User.current.logged? && Rails.env.development?
# User.current = User.find 1
# end

View File

@ -1,13 +1,17 @@
module RegisterHelper
extend ActiveSupport::Concern
def autologin_register(username, email, password, platform= 'forge')
def autologin_register(username, email, password, platform= 'forge', need_edit_info = false)
result = {message: nil, user: nil}
user = User.new(admin: false, login: username, mail: email, type: "User")
user.password = password
user.platform = platform
user.activate
if need_edit_info
user.need_edit_info
else
user.activate
end
return unless user.valid?
@ -27,4 +31,31 @@ module RegisterHelper
result
end
def autosync_register_trustie(username, password, email, lastname="")
config = Rails.application.config_for(:configuration).symbolize_keys!
api_host = config[:sync_url]
return if api_host.blank?
url = "#{api_host}/api/v1/users/common"
sync_json = {
"mail": email,
"password": password,
"login": username,
"lastname": lastname
}.compact
uri = URI.parse(url)
if api_host
http = Net::HTTP.new(uri.hostname, uri.port)
if api_host.include?("https://")
http.use_ssl = true
end
http.send_request('POST', uri.path, sync_json.to_json, {'Content-Type' => 'application/json'})
end
end
end

View File

@ -0,0 +1,8 @@
class Helps::FaqsController < ApplicationController
skip_before_action :check_sign, :user_setup
def index
faqs = Faq.select_without_id.order(updated_at: :desc)
render json: faqs.as_json(:except => [:id])
end
end

View File

@ -2,6 +2,7 @@ class Oauth::BaseController < ActionController::Base
include RenderHelper
include LoginHelper
include ControllerRescueHandler
include LoggerHelper
# include LaboratoryHelper
skip_before_action :verify_authenticity_token
@ -11,6 +12,18 @@ class Oauth::BaseController < ActionController::Base
end
private
def tip_exception(status = -1, message)
raise Educoder::TipException.new(status, message)
end
def tip_show_exception(status = -2, message)
raise Educoder::TipException.new(status, message)
end
def tip_show(exception)
uid_logger("Tip show status is #{exception.status}, message is #{exception.message}")
render json: exception.tip_json
end
def session_user_id
# session[:user_id]
@ -48,4 +61,13 @@ class Oauth::BaseController < ActionController::Base
Rails.logger.info("[wechat] set session unionid: #{unionid}")
session[:unionid] = unionid
end
def session_edulogin
session[:edulogin]
end
def set_session_edulogin(login)
Rails.logger.info("[educoder] set sesstion edulogin: #{login}")
session[:edulogin] = login
end
end

View File

@ -1,4 +1,6 @@
class Oauth::EducoderController < Oauth::BaseController
include RegisterHelper
def bind
begin
login = params[:login]
@ -32,4 +34,41 @@ class Oauth::EducoderController < Oauth::BaseController
render_error(ex.message)
end
end
# 需要educoder那边设置回调地址
def create
begin
code = params['code'].to_s.strip
tip_exception("code不能为空") if code.blank?
new_user = false
result = EducoderOauth::Service.access_token(code)
result = EducoderOauth::Service.user_info(result[:access_token])
# 存在该用户
open_user = OpenUsers::Educoder.find_by(uid: result['login'])
if open_user.present? && open_user.user.present?
successful_authentication(open_user.user)
else
if current_user.blank? || !current_user.logged?
new_user = true
login = User.generate_login('E')
reg_result = autologin_register(login,"#{login}@forge.com", "Ec#{login}2021#", 'educoder', true)
if reg_result[:message].blank?
open_user = OpenUsers::Educoder.create!(user_id: reg_result[:user][:id], uid: result['login'], extra: result)
autosync_register_trustie(login, "Ec#{login}2021#", "#{login}@forge.com")
successful_authentication(open_user.user)
else
render_error(reg_result[:message])
end
else
OpenUsers::Educoder.create!(user: current_user, uid: result['login'], extra: result)
end
end
redirect_to root_path(new_user: new_user)
rescue Exception => ex
render_error(ex.message)
end
end
end

View File

@ -61,6 +61,7 @@ class OauthController < ApplicationController
login = params[:login]
email = params[:mail]
password = params[:password]
lastname = params[:lastname]
callback_url = params[:callback_url]
platform = params[:plathform] || 'educoder'
@ -72,8 +73,11 @@ class OauthController < ApplicationController
if result[:message].blank?
logger.info "[Oauth educoer] ====auto_register success"
user = User.find result[:user][:id]
successful_authentication(user)
user.update_column(:lastname, params[:lastname])
autosync_register_trustie(login, password, email, lastname)
OpenUsers::Educoder.create!(user: user, uid: user.login)
successful_authentication(user)
render json: { callback_url: callback_url }
# redirect_to callback_url

View File

@ -1,5 +1,5 @@
class Organizations::OrganizationsController < Organizations::BaseController
before_action :require_login, except: [:index, :show]
before_action :require_login, except: [:index, :show, :recommend]
before_action :convert_image!, only: [:create, :update]
before_action :load_organization, only: [:show, :update, :destroy]
before_action :check_user_can_edit_org, only: [:update, :destroy]
@ -62,6 +62,13 @@ class Organizations::OrganizationsController < Organizations::BaseController
tip_exception(e.message)
end
def recommend
recommend = %W(xuos Huawei_Technology openatom_foundation pkecosystem TensorLayer)
@organizations = Organization.with_visibility(%w(common))
.where(login: recommend).select(:id, :login, :firstname, :lastname, :nickname)
end
private
def convert_image!
return unless params[:image].present?

View File

@ -106,19 +106,29 @@ class ProjectsController < ApplicationController
def update
ActiveRecord::Base.transaction do
Projects::UpdateForm.new(project_params).validate!
private = params[:private] || false
# TODO:
# 临时特殊处理修改website、lesson_url操作方法
if project_params.has_key?("website")
@project.update(project_params)
else
validate_params = project_params.slice(:name, :description,
:project_category_id, :project_language_id, :private)
Projects::UpdateForm.new(validate_params).validate!
private = params[:private] || false
new_project_params = project_params.except(:private).merge(is_public: !private)
@project.update_attributes!(new_project_params)
gitea_params = {
private: private,
default_branch: @project.default_branch,
website: @project.website
}
if [true, false].include? private
Gitea::Repository::UpdateService.call(@owner, @project.identifier, gitea_params)
@project.repository.update_column(:hidden, private)
new_project_params = project_params.except(:private).merge(is_public: !private)
@project.update_attributes!(new_project_params)
gitea_params = {
private: private,
default_branch: @project.default_branch,
website: @project.website
}
if [true, false].include? private
Gitea::Repository::UpdateService.call(@owner, @project.identifier, gitea_params)
@project.repository.update_column(:hidden, private)
end
end
end
rescue Exception => e
@ -167,7 +177,7 @@ class ProjectsController < ApplicationController
end
def recommend
@projects = Project.recommend.includes(:repository, :project_category, :owner).order(id: :desc).limit(5)
@projects = Project.recommend.includes(:repository, :project_category, :owner).order(id: :desc)
end
def about

View File

@ -4,7 +4,7 @@ class SettingsController < ApplicationController
get_add_menu
get_common_menu
get_personal_menu
get_third_party
end
private
@ -40,6 +40,14 @@ class SettingsController < ApplicationController
end
end
def get_third_party
@third_party = []
@third_party << {
name: 'educoder',
url: EducoderOauth.oauth_url
}
end
def get_site_url(key, value)
key.to_s === "url" ? append_http(reset_site_url(value)) : reset_site_url(value)
end

View File

@ -261,7 +261,7 @@ class UsersController < ApplicationController
interactor = Gitea::User::UpdateInteractor.call(user.login, sync_params)
if interactor.success?
user.update!(password: params[:password], mail: params[:email], status: User::STATUS_EDIT_INFO)
user.update!(password: params[:password], mail: params[:email], status: User::STATUS_ACTIVE)
render_ok
else
render_error(interactor.error)

View File

@ -0,0 +1,2 @@
module Admins::FaqsHelper
end

View File

@ -0,0 +1,2 @@
module Helps::FaqsHelper
end

View File

@ -0,0 +1,18 @@
module EducoderOauth
class << self
attr_accessor :client_id, :client_secret, :base_url, :redirect_uri
def logger
@_logger ||= STDOUT
end
def logger=(l)
@_logger = l
end
def oauth_url
"#{base_url}/oauth2?call_url=/oauth/authorize?client_id=#{client_id}&redirect_uri=#{URI.encode_www_form_component(redirect_uri)}&response_type=code"
end
end
end

View File

@ -0,0 +1,37 @@
require 'oauth2'
module EducoderOauth::Service
module_function
def request(method, url, params)
begin
Rails.logger.info("[EducoderOauth] [#{method.to_s.upcase}] #{url} || #{params}")
client = Faraday.new(url: EducoderOauth.base_url)
response = client.public_send(method, url, params)
result = JSON.parse(response.body)
Rails.logger.info("[EducoderOauth] [#{response.status}] #{result}")
result
rescue Exception => e
raise Educoder::TipException.new(e.message)
end
end
def access_token(code)
begin
Rails.logger.info("[EducoderOauth] [code] #{code} ")
Rails.logger.info("[EducoderOauth] [redirect_uri] #{EducoderOauth.redirect_uri} ")
client = OAuth2::Client.new(EducoderOauth.client_id, EducoderOauth.client_secret, site: EducoderOauth.base_url)
result = client.auth_code.get_token(code, redirect_uri: EducoderOauth.redirect_uri).to_hash
return result
rescue Exception => e
raise Educoder::TipException.new(e.message)
end
end
def user_info(access_token)
request(:get, '/api/users/info.json', {access_token: access_token})
end
end

View File

@ -47,6 +47,7 @@
# watchers_count :integer default("0")
# devops_step :integer default("0")
# gitea_token :string(255)
# platform :string(255)
#
# Indexes
#

20
app/models/faq.rb Normal file
View File

@ -0,0 +1,20 @@
# == Schema Information
#
# Table name: faqs
#
# id :integer not null, primary key
# question :string(255)
# url :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
class Faq < ApplicationRecord
validates :question, presence: true,length: { maximum: 100, too_long: "最多%{count}个字符" }
validates :url, format: { with: CustomRegexp::URL, multiline: true, message: "格式不正确" }
scope :select_without_id, -> { select(:question, :url) }
scope :search_question, ->(keyword) { where("question LIKE ?", "%#{keyword}%") unless keyword.blank?}
end

View File

@ -47,6 +47,7 @@
# watchers_count :integer default("0")
# devops_step :integer default("0")
# gitea_token :string(255)
# platform :string(255)
#
# Indexes
#

View File

@ -1,19 +1,19 @@
# == Schema Information
#
# Table name: tokens
#
# id :integer not null, primary key
# user_id :integer default("0"), not null
# action :string(30) default(""), not null
# value :string(40) default(""), not null
# created_on :datetime not null
#
# Indexes
#
# index_tokens_on_user_id (user_id)
# tokens_value (value) UNIQUE
#
# == Schema Information
#
# Table name: tokens
#
# id :integer not null, primary key
# user_id :integer default("0"), not null
# action :string(30) default(""), not null
# value :string(40) default(""), not null
# created_on :datetime not null
#
# Indexes
#
# index_tokens_on_user_id (user_id)
# tokens_value (value) UNIQUE
#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -76,7 +76,7 @@ class Token < ActiveRecord::Base
# Returns the active user who owns the key for the given action
def self.find_active_user(action, key, validity_days=nil)
user = find_user(action, key, validity_days)
if user && user.active?
if user && (user.active? || user.need_edit_info?)
user
end
end

View File

@ -47,6 +47,7 @@
# watchers_count :integer default("0")
# devops_step :integer default("0")
# gitea_token :string(255)
# platform :string(255)
#
# Indexes
#
@ -82,6 +83,7 @@ class User < Owner
STATUS_ACTIVE = 1
STATUS_REGISTERED = 2
STATUS_LOCKED = 3
STATUS_EDIT_INFO = 4
# tpi tpm权限控制
EDU_ADMIN = 1 # 超级管理员
@ -165,7 +167,7 @@ class User < Owner
has_many :organizations, through: :organization_users
# Groups and active users
scope :active, lambda { where(status: STATUS_ACTIVE) }
scope :active, lambda { where(status: [STATUS_ACTIVE, STATUS_EDIT_INFO]) }
scope :like, lambda { |keywords|
where("LOWER(concat(lastname, firstname, login, mail)) LIKE ?", "%#{keywords.split(" ").join('|')}%") unless keywords.blank?
}
@ -386,6 +388,10 @@ class User < Owner
status == STATUS_LOCKED
end
def need_edit_info?
status == STATUS_EDIT_INFO
end
def activate
self.status = STATUS_ACTIVE
end
@ -398,6 +404,10 @@ class User < Owner
self.status = STATUS_LOCKED
end
def need_edit_info
self.status = STATUS_EDIT_INFO
end
def activate!
update_attribute(:status, STATUS_ACTIVE)
end
@ -410,6 +420,10 @@ class User < Owner
update_attribute(:status, STATUS_LOCKED)
end
def need_edit_info!
update_attribute(:status, STATUS_EDIT_INFO)
end
# 课程用户身份
def course_identity(course)
if !logged?

View File

@ -21,9 +21,7 @@ class Repositories::MigrateService < ApplicationService
private
def repository_params
params.merge(project_id: project.id,
identifier: params[:identifier],
source_clone_url: params[:source_clone_url])
params.merge(project_id: project.id)
end
def gitea_repository_params

View File

@ -0,0 +1,24 @@
<div class="modal fade faq-change-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><%= type == "create" ? "新增" : "编辑" %></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<%= form_for @faq, url: {controller: "faqs", action: "#{type}"} do |p| %>
<div class="modal-body">
<%= p.text_field :question,class: "form-control input-lg",placeholder: "问题",required: true, maxlength: 100%>
</div>
<div class="modal-body">
<%= p.text_field :url,class: "form-control input-lg",placeholder: "链接",required: true, maxlength: 100%>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<%= p.submit "确认", class: "btn btn-primary submit-btn" %>
</div>
<% end %>
</div>
</div>
</div>

View File

@ -0,0 +1,33 @@
<table class="table table-hover text-center subject-list-table">
<thead class="thead-light">
<tr>
<th width="5%">序号</th>
<th width="20%">标题</th>
<th width="30%">url</th>
<th width="10%"><%= sort_tag('创建于', name: 'created_at', path: admins_faqs_path) %></th>
<th width="10%"><%= sort_tag('更新于', name: 'updated_at', path: admins_faqs_path) %></th>
<th width="25%">操作</th>
</tr>
</thead>
<tbody>
<% if faqs.present? %>
<% faqs.each_with_index do |faq, index| %>
<tr class="user-item-<%= faq.id %>">
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
<td><%= faq.question%></td>
<td><%= link_to faq.url, target: '_blank' %></td>
<td><%= display_text(faq.created_at&.strftime('%Y-%m-%d %H:%M')) %></td>
<td><%= display_text(faq.updated_at&.strftime('%Y-%m-%d %H:%M')) %></td>
<td class="action-container">
<%= link_to "编辑", edit_admins_faq_path(faq), remote: true, class: "action" %>
<%= link_to "删除", admins_faqs_path(faq.id), method: :delete, data:{confirm: "确认删除的吗?"}, class: "delete-project-action" %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>
<%= render partial: 'admins/shared/paginate', locals: { objects: faqs } %>

View File

@ -0,0 +1,2 @@
$("#faq-modals").html("<%= j render(partial: 'admins/faqs/form_modal', locals: {type: 'update'}) %>")
$(".faq-change-modal").modal('show');

View File

@ -0,0 +1,17 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('FAQ', admins_faqs_path) %>
<% end %>
<div class="box search-form-container faq-list-form">
<%= form_tag(admins_faqs_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '输入标题搜素') %>
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
<% end %>
<%= link_to "新增", new_admins_faq_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %>
</div>
<div class="box admin-list-container faqs-list-container">
<%= render partial: 'admins/faqs/list', locals: { faqs: @faqs } %>
</div>
<div id="faq-modals">
</div>

View File

@ -0,0 +1 @@
$('.faqs-list-container').html("<%= j( render partial: 'admins/faqs/list', locals: { faqs: @faqs } ) %>");

View File

@ -0,0 +1,2 @@
$("#faq-modals").html("<%= j render(partial: 'admins/faqs/form_modal', locals: {type: 'create'}) %>")
$(".faq-change-modal").modal('show');

View File

@ -10,7 +10,6 @@
</td>
<td>
<% if school && school.identifier.present? %>
<%= link_to school.identifier.to_s, statistics_college_path(school.identifier), target: '_blank' %>
<% else %>
--
<% end %>

View File

@ -38,6 +38,7 @@
<li><%= sidebar_item(admins_cooperatives_path, '合作伙伴', icon: 'handshake-o', controller: 'admins-cooperatives') %></li>
<li><%= sidebar_item(edit_admins_agreement_path, '服务协议', icon: 'file-text-o', controller: 'admins-agreements') %></li>
<li><%= sidebar_item(edit_admins_help_center_path, '帮助中心', icon: 'question-circle-o', controller: 'admins-help_centers') %></li>
<li><%= sidebar_item(admins_faqs_path, 'FAQ', icon: 'question-circle', controller: 'admins-faqs') %></li>
<% end %>
</li>
<li>

View File

@ -1,14 +1,19 @@
<div class="indexPanel">
<p class="indexTitle">完善信息,进入比赛</p>
<p class="indexTitle">平台已检测到您的如下信息,完善即可进入比赛</p>
<div class="indexInfos">
<%= form_tag('', method: :post, id: 'oauth_form', class: 'form-inline search-form flex-1', remote: true) do %>
<%= hidden_field_tag 'callback_url', params[:callback_url] %>
<div class="indexInfo">
<span>用户名:</span>
<%= text_field_tag :login, params[:login], placeholder: '请输入用户名', readonly: true, id: 'login' %>
<span>登录名:</span>
<%= text_field_tag :login, params[:login], placeholder: '请输入登录名', readonly: true, id: 'login' %>
<p class="checkInfo loginCheck"><span></span></p>
</div>
<div class="indexInfo">
<span>用户名称:</span>
<%= text_field_tag :lastname, params[:lastname], placeholder: '登录平台后显示的用户名称', maxlength: 40, id: 'lastname' %>
<p class="checkInfo lastnameCheck"><span></span></p>
</div>
<div class="indexInfo">
<span>邮箱:</span>
<%= text_field_tag :mail, params[:mail], placeholder: '请输入绑定邮箱', maxlength: 40, id: 'email' %>
@ -16,7 +21,7 @@
</div>
<div class="indexInfo">
<span>密码:</span>
<%= password_field_tag :password, '', placeholder: '输入账号密码', id: 'password' %>
<%= password_field_tag :password, '', placeholder: '输入EduCoder账号密码或新的密码',maxlength: 15, id: 'password' %>
<p class="checkInfo passwordCheck"><span></span></p>
</div>
<div class="indexBtn">
@ -29,6 +34,7 @@
function submitdata(){
var login = $("#login").val();
var email = $("#email").val();
var lastname = $("#lastname").val();
var password = $("#password").val();
if(!login){
@ -37,6 +43,12 @@
}else{
$(".loginCheck span").html("");
}
if(!lastname){
$(".lastnameCheck span").html("请输入用户名称");
return;
}else{
$(".lastnameCheck span").html("");
}
if(!email){
$(".emailCheck span").html("请输入绑定的邮箱");
return;

View File

@ -0,0 +1,6 @@
json.organizations @organizations do |organization|
json.id organization.id
json.name organization.login
json.nickname organization.nickname.blank? ? organization.name : organization.nickname
json.avatar_url url_to_avatar(organization)
end

View File

@ -21,7 +21,7 @@ json.versions_count @project.versions_count #里程碑数量
json.version_releases_count @project.releases_size(@user.try(:id), "all")
json.version_releasesed_count @project.releases_size(@user.try(:id), "released") #已发行的版本
json.permission render_permission(@user, @project)
json.mirror_url @project&.repository.source_clone_url
json.mirror_url @project&.repository.remote_mirror_url
json.mirror @project&.repository.mirror_url.present?
json.type @project.numerical_for_project_type
json.open_devops @project.open_devops?

View File

@ -56,4 +56,5 @@ json.setting do
end
json.common @common
json.third_party @third_party
end

View File

@ -8,8 +8,9 @@ json.is_teacher @user.user_extension&.teacher?
json.user_identity @user.identity
json.tidding_count 0
json.user_phone_binded @user.phone.present?
json.need_edit_info @user.need_edit_info?
# json.phone @user.phone
# json.email @user.mail
json.email @user.mail
json.profile_completed @user.profile_completed?
json.professional_certification @user.professional_certification
json.devops_step @user.devops_step

View File

@ -43,6 +43,11 @@ default: &default
cate_id: '-1'
callback_url: 'callback_url'
signature_key: 'test12345678'
educoder:
client_id: 'e9ce4d5ba1698d6f7d01d8ee2959776c7a6d743ebe94da2341e288fd2fbf60aa'
client_secret: '6ff84dd75eddd859c5bd0e7a791b58bc5ad1ba4fbb30bc9db37cb0baf9f33012'
base_url: 'https://test-data.educoder.net'
redirect_uri: 'https://testforgeplus.trustie.net/api/auth/educoder/callback'
gitea:
access_key_id: ''

View File

@ -0,0 +1,16 @@
oauth_config = {}
begin
config = Rails.application.config_for(:configuration)
oauth_config = config.dig('oauth', 'educoder')
raise 'oauth educoder config missing' if oauth_config.blank?
rescue => ex
raise ex if Rails.env.production?
puts %Q{\033[33m [warning] wechat oauth config or configuration.yml missing,
please add it or execute 'cp config/configuration.yml.example config/configuration.yml' \033[0m}
end
EducoderOauth.client_id = oauth_config['client_id']
EducoderOauth.client_secret = oauth_config['client_secret']
EducoderOauth.base_url = oauth_config['base_url']
EducoderOauth.redirect_uri = oauth_config['redirect_uri']

View File

@ -130,6 +130,7 @@ Rails.application.routes.draw do
get :search
end
end
get :recommend, on: :collection
end
end
@ -321,6 +322,7 @@ Rails.application.routes.draw do
get '/auth/qq/callback', to: 'oauth/qq#create'
get '/auth/wechat/callback', to: 'oauth/wechat#create'
get '/auth/educoder/callback', to: 'oauth/educoder#create'
resource :bind_user, only: [:create]
resources :hot_keywords, only: [:index]
@ -603,6 +605,10 @@ Rails.application.routes.draw do
end
end
# Project Area END
scope module: :helps do
resources :faqs, only: [:index]
end
end
namespace :admins do
@ -779,6 +785,7 @@ Rails.application.routes.draw do
post :drag, on: :collection
post :replace_image_url, on: :member
end
resources :faqs
resources :laboratories, only: [:index, :create, :destroy, :update] do
member do
get :shixuns_for_select

View File

@ -0,0 +1,10 @@
class CreateFaqs < ActiveRecord::Migration[5.2]
def change
create_table :faqs do |t|
t.string :question
t.string :url
t.timestamps
end
end
end