From 7e18e89b3f4a36e0b146419354926b74ec375e2d Mon Sep 17 00:00:00 2001 From: "Billy.Zheng" Date: Sun, 9 Jun 2024 18:14:14 +0800 Subject: [PATCH] =?UTF-8?q?Add=20=E6=8B=9B=E7=94=9F=E7=AB=A0=E7=A8=8B,=20?= =?UTF-8?q?=E5=8E=86=E5=B9=B4=E5=88=86=E6=95=B0=20=E7=BD=91=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...15_add_zhaosheng_jianzhang_into_college.cr | 15 ++++++++++ src/actions/universities/edit.cr | 2 ++ src/components/universities/form_fields.cr | 12 ++++++++ src/components/universities/main.cr | 28 +++++++++++++++++-- src/models/university.cr | 3 ++ src/operations/save_university.cr | 12 ++++---- 6 files changed, 65 insertions(+), 7 deletions(-) create mode 100644 db/migrations/20240609092515_add_zhaosheng_jianzhang_into_college.cr diff --git a/db/migrations/20240609092515_add_zhaosheng_jianzhang_into_college.cr b/db/migrations/20240609092515_add_zhaosheng_jianzhang_into_college.cr new file mode 100644 index 0000000..7122e66 --- /dev/null +++ b/db/migrations/20240609092515_add_zhaosheng_jianzhang_into_college.cr @@ -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 diff --git a/src/actions/universities/edit.cr b/src/actions/universities/edit.cr index 0c12dcd..8a0e16c 100644 --- a/src/actions/universities/edit.cr +++ b/src/actions/universities/edit.cr @@ -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, diff --git a/src/components/universities/form_fields.cr b/src/components/universities/form_fields.cr index 58b1933..b94b42b 100644 --- a/src/components/universities/form_fields.cr +++ b/src/components/universities/form_fields.cr @@ -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 "其他选项" diff --git a/src/components/universities/main.cr b/src/components/universities/main.cr index 356ccdf..1e25231 100644 --- a/src/components/universities/main.cr +++ b/src/components/universities/main.cr @@ -298,8 +298,32 @@ then set (next ).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 diff --git a/src/models/university.cr b/src/models/university.cr index 39d3509..b2fe942 100644 --- a/src/models/university.cr +++ b/src/models/university.cr @@ -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 diff --git a/src/operations/save_university.cr b/src/operations/save_university.cr index d6ee3e0..7a218c1 100644 --- a/src/operations/save_university.cr +++ b/src/operations/save_university.cr @@ -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