Skip to content

Commit

Permalink
Show a unviersity all exists batch_levels
Browse files Browse the repository at this point in the history
  • Loading branch information
zw963 committed Jun 25, 2024
1 parent 16e4903 commit 8e2b2c1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
17 changes: 17 additions & 0 deletions src/actions/mixins/page_helpers.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
module PageHelpers
def show_university_batch_levels(university_name, university_code, university_batch_level)
batch_names = UniversityQuery.new
.name.like("#{university_name}%")
.reject { |e| e.code == university_code && e.batch_level == university_batch_level }
.map { |e| [e.name, e.batch_level.display_name] }

str = String.build do |io|
io << "名称相似的其他学校:\n"

io << "\n" unless batch_names.blank?

batch_names.each do |e|
io << "#{e[0]}, #{e[1]}\n"
end
end
end

def show_score_info(university, year, score_value)
if score_value.blank?
""
Expand Down
16 changes: 11 additions & 5 deletions src/components/universities/name_link.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Universities::NameLink < BaseComponent
include PageHelpers

needs university : University
needs current_user : User

Expand All @@ -7,17 +9,21 @@ class Universities::NameLink < BaseComponent
name = university.name

if university.is_985
name = "#{name}/985"
full_name = "#{name}/985"
elsif university.is_211
name = "#{name}/211"
full_name = "#{name}/211"
elsif university.is_good
name = "#{name}/双一流"
full_name = "#{name}/双一流"
else
full_name = name
end

a(
name,
full_name,
href: "#",
class: "dropdown-trigger",
class: "dropdown-trigger tooltipped",
"data-position": "top",
"data-tooltip": show_university_batch_levels(name, university.code, university.batch_level),
data_target: "dropdown3",
id: id,
marked_2023: university.marked_2023(current_user),
Expand Down

0 comments on commit 8e2b2c1

Please sign in to comment.