修改homepage_info 及用户项目的分类
This commit is contained in:
parent
5410e11a51
commit
b64d910525
|
@ -113,7 +113,7 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def projects
|
def projects
|
||||||
scope = Projects::ListMyQuery.call(params.merge(joins: params[:joins], user_id: current_user.try(:id)))
|
scope = Projects::ListMyQuery.call(params.merge(category: params[:category], current_user: current_user))
|
||||||
@total_count = scope.size
|
@total_count = scope.size
|
||||||
@projects = paginate(scope)
|
@projects = paginate(scope)
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ class User < ApplicationRecord
|
||||||
has_many :apply_actions, dependent: :destroy
|
has_many :apply_actions, dependent: :destroy
|
||||||
has_many :trail_auth_apply_actions, -> { where(container_type: 'TrialAuthorization') }, class_name: 'ApplyAction'
|
has_many :trail_auth_apply_actions, -> { where(container_type: 'TrialAuthorization') }, class_name: 'ApplyAction'
|
||||||
|
|
||||||
has_many :attendances
|
# has_many :attendances
|
||||||
|
|
||||||
# 兴趣
|
# 兴趣
|
||||||
has_many :user_interests, dependent: :delete_all
|
has_many :user_interests, dependent: :delete_all
|
||||||
|
@ -688,9 +688,9 @@ class User < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
# 学院的url标识
|
# 学院的url标识
|
||||||
def college_identifier
|
# def college_identifier
|
||||||
Department.find_by_id(department_members.pluck(:department_id).first)&.identifier
|
# Department.find_by_id(department_members.pluck(:department_id).first)&.identifier
|
||||||
end
|
# end
|
||||||
|
|
||||||
# 是否能申请试用
|
# 是否能申请试用
|
||||||
def can_apply_trial?
|
def can_apply_trial?
|
||||||
|
|
|
@ -9,24 +9,20 @@ class Projects::ListMyQuery < ApplicationQuery
|
||||||
end
|
end
|
||||||
|
|
||||||
def call
|
def call
|
||||||
if params[:user_id].to_i == 2 || params[:user_id].to_i == 0
|
if params[:category].blank?
|
||||||
return nil
|
projects = current_user.projects
|
||||||
|
elsif params[:category].to_s == "manage"
|
||||||
|
projects = Project.where(user_id: current_user.id)
|
||||||
else
|
else
|
||||||
if params[:joins].present?
|
projects = Project.where.not(user_id: current_user.id).joins(:members).where("members.user_id = ?", current_user.id)
|
||||||
projects = Project.where.not(user_id: params[:user_id]).joins(:members).where("members.user_id = ?", params[:user_id])
|
|
||||||
else
|
|
||||||
projects = Project.where(user_id: params[:user_id])
|
|
||||||
end
|
|
||||||
scope = projects.includes(:members,:issues,:project_category, :project_language, owner: :user_extension).like(params[:search])
|
|
||||||
.with_project_type(params[:project_type])
|
|
||||||
.with_project_category(params[:category_id])
|
|
||||||
.with_project_language(params[:language_id])
|
|
||||||
|
|
||||||
sort = params[:sort_by] || "updated_on"
|
|
||||||
sort_direction = params[:sort_direction] || "desc"
|
|
||||||
scope.order("projects.#{sort} #{sort_direction}")
|
|
||||||
end
|
end
|
||||||
|
scope = projects.includes(:members,:issues,:project_category, :project_language, owner: :user_extension).like(params[:search])
|
||||||
|
.with_project_type(params[:project_type])
|
||||||
|
.with_project_category(params[:category_id])
|
||||||
|
.with_project_language(params[:language_id])
|
||||||
|
|
||||||
|
sort = params[:sort_by] || "updated_on"
|
||||||
|
sort_direction = params[:sort_direction] || "desc"
|
||||||
|
scope.order("projects.#{sort} #{sort_direction}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,22 +1,36 @@
|
||||||
json.id @user.id
|
|
||||||
json.name @user.full_name
|
json.name @user.full_name
|
||||||
json.avatar_url url_to_avatar(@user)
|
json.avatar_url url_to_avatar(@user)
|
||||||
json.is_logged_user @user.logged_user?
|
json.is_logged_user @user.logged_user?
|
||||||
json.experience @user.experience
|
|
||||||
json.grade @user.grade
|
|
||||||
json.follow_count @user.follow_count
|
json.follow_count @user.follow_count
|
||||||
json.fan_count @user.fan_count
|
json.fan_count @user.fan_count
|
||||||
json.identity @user.identity
|
json.identity @user.identity
|
||||||
#json.brief_introduction @user.user_extension&.brief_introduction
|
json.brief_introduction @user.user_extension&.brief_introduction
|
||||||
json.authentication @user.authentication
|
|
||||||
json.professional_certification @user.professional_certification
|
json.professional_certification @user.professional_certification
|
||||||
json.phone_binded @user.phone_binded?
|
json.phone_binded @user.phone_binded?
|
||||||
json.email_binded @user.email_binded?
|
json.email_binded @user.email_binded?
|
||||||
json.college_identifier @user.college_identifier
|
|
||||||
json.followed User.current.watched?(@user)
|
json.followed User.current.watched?(@user)
|
||||||
|
|
||||||
if @user.logged_user?
|
# json.id @user.id
|
||||||
#json.can_apply_trial @user.can_apply_trial?
|
# json.name @user.full_name
|
||||||
json.attendance_signed @user.attendance_signed?
|
# json.avatar_url url_to_avatar(@user)
|
||||||
json.tomorrow_attendance_gold @user.tomorrow_attendance_gold
|
# json.is_logged_user @user.logged_user?
|
||||||
end
|
# json.experience @user.experience
|
||||||
|
# json.grade @user.grade
|
||||||
|
# json.follow_count @user.follow_count
|
||||||
|
# json.fan_count @user.fan_count
|
||||||
|
# json.identity @user.identity
|
||||||
|
# json.brief_introduction @user.user_extension&.brief_introduction
|
||||||
|
# json.authentication @user.authentication
|
||||||
|
# json.professional_certification @user.professional_certification
|
||||||
|
# json.phone_binded @user.phone_binded?
|
||||||
|
# json.email_binded @user.email_binded?
|
||||||
|
# json.college_identifier @user.college_identifier
|
||||||
|
# json.followed User.current.watched?(@user)
|
||||||
|
#
|
||||||
|
# if @user.logged_user?
|
||||||
|
# #json.can_apply_trial @user.can_apply_trial?
|
||||||
|
# json.attendance_signed @user.attendance_signed?
|
||||||
|
# json.tomorrow_attendance_gold @user.tomorrow_attendance_gold
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue