Skip to content

Commit

Permalink
Add 招生章程, 历年分数 网址
Browse files Browse the repository at this point in the history
  • Loading branch information
zw963 committed Jun 9, 2024
1 parent 20c4429 commit 7e18e89
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class AddZhaoshengJianzhangIntoCollege::V20240609092515 < Avram::Migrator::Migration::V1
def migrate
alter table_for(University) do
add zhaosheng_zhangcheng_url : String?
add linian_fenshu_url : String?
end
end

def rollback
alter table_for(University) do
remove :zhaosheng_zhangcheng_url
remove :linian_fenshu_url
end
end
end
2 changes: 2 additions & 0 deletions src/actions/universities/edit.cr
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Universities::Edit < BrowserAction
province_code: university.province.code,
city_name: university.city.name,
city_code: university.city.code,
zhaosheng_zhangcheng_url: university.zhaosheng_zhangcheng_url,
linian_fenshu_url: university.linian_fenshu_url,
chong_2023: chong_wen_bao.chong_2023,
chong_2022: chong_wen_bao.chong_2022,
chong_2021: chong_wen_bao.chong_2021,
Expand Down
12 changes: 12 additions & 0 deletions src/components/universities/form_fields.cr
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ class Universities::FormFields < BaseComponent

br

div class: "row" do
mount Shared::Field, op.linian_fenshu_url, "历年分数(网址)", &.text_input(placeholder: "输入历年分数网址 URL")
end

br

div class: "row" do
mount Shared::Field, op.zhaosheng_zhangcheng_url, "招生章程(网址)", &.text_input(placeholder: "输入招生章程网址 URL")
end

br

if current_user.is_editable
fieldset style: "max-width: 800px;" do
legend "其他选项"
Expand Down
28 changes: 26 additions & 2 deletions src/components/universities/main.cr
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,32 @@ then set (next <input/>).value to my.value2
tbody do
universities.each do |university|
tr do
td university.id
td university.code.to_s
if (url1 = university.linian_fenshu_url).nil?
td university.id
else
td do
a(university.id,
href: url1,
class: "tooltipped",
"data-position": "top",
"data-tooltip": "历年分数"
)
end
end

if (url2 = university.zhaosheng_zhangcheng_url).nil?
td university.code.to_s
else
td do
a(university.code,
href: url2,
class: "tooltipped",
"data-position": "top",
"data-tooltip": "招生章程"
)
end
end

td do
link university.name, Edit.with(university), "hx-boost": "false"
end
Expand Down
3 changes: 3 additions & 0 deletions src/models/university.cr
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ class University < BaseModel
column ranking_2021_max : Float64?
column ranking_2020_max : Float64?

column zhaosheng_zhangcheng_url : String?
column linian_fenshu_url : String?

belongs_to province : Province
belongs_to city : City

Expand Down
12 changes: 7 additions & 5 deletions src/operations/save_university.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ class SaveUniversity < University::SaveOperation
upsert_lookup_columns code, batch_level

permit_columns name, code,
is_211, is_985, is_good, batch_level,
score_2023_min, ranking_2023_min,
score_2022_min, ranking_2022_min,
score_2021_min, ranking_2021_min,
score_2020_min, ranking_2020_min
is_211, is_985, is_good, batch_level,
score_2023_min, ranking_2023_min,
score_2022_min, ranking_2022_min,
score_2021_min, ranking_2021_min,
score_2020_min, ranking_2020_min,
zhaosheng_zhangcheng_url,
linian_fenshu_url

attribute province_code : Int32
attribute province_name : String
Expand Down

0 comments on commit 7e18e89

Please sign in to comment.