rails_org 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +30 -0
- data/Rakefile +20 -0
- data/app/controllers/me/base_controller.rb +4 -0
- data/app/controllers/me/home_controller.rb +9 -0
- data/app/controllers/me_controller.rb +4 -0
- data/app/controllers/org/admin/authorized_tokens_controller.rb +48 -0
- data/app/controllers/org/admin/base_controller.rb +4 -0
- data/app/controllers/org/admin/current_organ_controller.rb +43 -0
- data/app/controllers/org/admin/department_grants_controller.rb +44 -0
- data/app/controllers/org/admin/departments_controller.rb +92 -0
- data/app/controllers/org/admin/home_controller.rb +8 -0
- data/app/controllers/org/admin/job_descriptions_controller.rb +49 -0
- data/app/controllers/org/admin/job_titles_controller.rb +69 -0
- data/app/controllers/org/admin/job_transfers_controller.rb +88 -0
- data/app/controllers/org/admin/member_departments_controller.rb +82 -0
- data/app/controllers/org/admin/members_controller.rb +129 -0
- data/app/controllers/org/admin/organ_domains_controller.rb +61 -0
- data/app/controllers/org/admin/organs_controller.rb +57 -0
- data/app/controllers/org/admin/resign_reasons_controller.rb +19 -0
- data/app/controllers/org/admin/resigns_controller.rb +103 -0
- data/app/controllers/org/admin/super_job_titles_controller.rb +70 -0
- data/app/controllers/org/admin/supports_controller.rb +93 -0
- data/app/controllers/org/admin/tutorials_controller.rb +74 -0
- data/app/controllers/org/base_controller.rb +4 -0
- data/app/controllers/org/board/base_controller.rb +4 -0
- data/app/controllers/org/board/members_controller.rb +61 -0
- data/app/controllers/org/board/organs_controller.rb +78 -0
- data/app/controllers/org/controller/application.rb +84 -0
- data/app/controllers/org/controller/me.rb +25 -0
- data/app/controllers/org/controller/our.rb +12 -0
- data/app/controllers/org/layout/me.rb +16 -0
- data/app/controllers/org/layout/panel.rb +16 -0
- data/app/controllers/org/me/base_controller.rb +4 -0
- data/app/controllers/org/me/departments_controller.rb +78 -0
- data/app/controllers/org/me/job_transfers_controller.rb +62 -0
- data/app/controllers/org/me/members_controller.rb +37 -0
- data/app/controllers/org/me/orders_controller.rb +66 -0
- data/app/controllers/org/me/resigns_controller.rb +53 -0
- data/app/controllers/org/me/tutorials_controller.rb +76 -0
- data/app/controllers/org/members_controller.rb +48 -0
- data/app/controllers/org/organs_controller.rb +30 -0
- data/app/controllers/org/panel/base_controller.rb +4 -0
- data/app/controllers/org/panel/organ_domains_controller.rb +5 -0
- data/app/controllers/org/panel/organs_controller.rb +40 -0
- data/app/mailers/org/attendance_mailer.rb +17 -0
- data/app/mailers/org/exam_mailer.rb +26 -0
- data/app/mailers/org/lesson_mailer.rb +15 -0
- data/app/mailers/org/lesson_member_mailer.rb +25 -0
- data/app/models/org/account.rb +8 -0
- data/app/models/org/application_record.rb +5 -0
- data/app/models/org/department.rb +6 -0
- data/app/models/org/department_grant.rb +5 -0
- data/app/models/org/department_hierarchy.rb +5 -0
- data/app/models/org/job_description.rb +5 -0
- data/app/models/org/job_title.rb +6 -0
- data/app/models/org/job_transfer.rb +5 -0
- data/app/models/org/member.rb +7 -0
- data/app/models/org/member_department.rb +6 -0
- data/app/models/org/model/account.rb +11 -0
- data/app/models/org/model/department.rb +67 -0
- data/app/models/org/model/department_grant.rb +13 -0
- data/app/models/org/model/department_hierarchy.rb +10 -0
- data/app/models/org/model/job_description.rb +18 -0
- data/app/models/org/model/job_title.rb +54 -0
- data/app/models/org/model/job_transfer.rb +108 -0
- data/app/models/org/model/member.rb +142 -0
- data/app/models/org/model/member_department.rb +66 -0
- data/app/models/org/model/organ.rb +62 -0
- data/app/models/org/model/organ_domain.rb +44 -0
- data/app/models/org/model/organ_handle.rb +15 -0
- data/app/models/org/model/resign.rb +66 -0
- data/app/models/org/model/resign_reason.rb +17 -0
- data/app/models/org/model/resign_reference.rb +11 -0
- data/app/models/org/model/super_job_title.rb +25 -0
- data/app/models/org/model/support.rb +19 -0
- data/app/models/org/model/tutorial.rb +64 -0
- data/app/models/org/model/user.rb +30 -0
- data/app/models/org/organ.rb +7 -0
- data/app/models/org/organ_domain.rb +5 -0
- data/app/models/org/organ_handle.rb +5 -0
- data/app/models/org/resign.rb +5 -0
- data/app/models/org/resign_reason.rb +5 -0
- data/app/models/org/resign_reference.rb +5 -0
- data/app/models/org/super_job_title.rb +6 -0
- data/app/models/org/support.rb +5 -0
- data/app/models/org/tutorial.rb +5 -0
- data/app/models/org.rb +11 -0
- data/app/views/admin/_department_navbar.html.erb +6 -0
- data/app/views/admin/_nav_show.erb +17 -0
- data/app/views/admin/_nav_with_login.html.erb +37 -0
- data/app/views/admin/_org_nav.html.erb +16 -0
- data/app/views/admin/_right_menu.html.erb +17 -0
- data/app/views/application/_org_navbar.html.erb +19 -0
- data/app/views/application/require_member.html.erb +4 -0
- data/app/views/application/require_member.js.erb +2 -0
- data/app/views/application/require_member.json.jbuilder +1 -0
- data/app/views/application/require_organ.html.erb +4 -0
- data/app/views/application/require_organ.js.erb +2 -0
- data/app/views/application/require_organ.json.jbuilder +1 -0
- data/app/views/layouts/me.html+phone.erb +12 -0
- data/app/views/layouts/me.html.erb +17 -0
- data/app/views/me/_nav_with_login.html.erb +3 -0
- data/app/views/me/_org_nav.html.erb +13 -0
- data/app/views/me/_right_menu.html.erb +23 -0
- data/app/views/me/home/index.html.erb +17 -0
- data/app/views/me/update.turbo_stream.erb +3 -0
- data/app/views/org/admin/authorized_tokens/_breadcrumb.html.erb +6 -0
- data/app/views/org/admin/authorized_tokens/_button.html.erb +0 -0
- data/app/views/org/admin/authorized_tokens/_edit_form.html.erb +4 -0
- data/app/views/org/admin/authorized_tokens/_filter_form.html.erb +9 -0
- data/app/views/org/admin/authorized_tokens/_form.html.erb +4 -0
- data/app/views/org/admin/authorized_tokens/_index_tbody.html.erb +18 -0
- data/app/views/org/admin/authorized_tokens/_index_thead.html.erb +6 -0
- data/app/views/org/admin/authorized_tokens/_new_form.html.erb +4 -0
- data/app/views/org/admin/authorized_tokens/_show_table.html.erb +20 -0
- data/app/views/org/admin/authorized_tokens/index.html.erb +3 -0
- data/app/views/org/admin/base/_nav.html.erb +3 -0
- data/app/views/org/admin/current_organ/_edit_form.html.erb +11 -0
- data/app/views/org/admin/current_organ/_edit_x_form.html.erb +5 -0
- data/app/views/org/admin/current_organ/_show_table.html.erb +16 -0
- data/app/views/org/admin/current_organ/show.html.erb +1 -0
- data/app/views/org/admin/department_grants/_add.html.erb +3 -0
- data/app/views/org/admin/department_grants/_index.html.erb +29 -0
- data/app/views/org/admin/department_grants/_new.html.erb +6 -0
- data/app/views/org/admin/department_grants/index.js.erb +7 -0
- data/app/views/org/admin/departments/_department.json.jbuilder +6 -0
- data/app/views/org/admin/departments/_department_form.html.erb +8 -0
- data/app/views/org/admin/departments/_department_support.html.erb +26 -0
- data/app/views/org/admin/departments/_edit_form.html.erb +4 -0
- data/app/views/org/admin/departments/_filter_form.html.erb +9 -0
- data/app/views/org/admin/departments/_filter_table.html.erb +11 -0
- data/app/views/org/admin/departments/_form.html.erb +23 -0
- data/app/views/org/admin/departments/_index_tbody.html.erb +29 -0
- data/app/views/org/admin/departments/_index_thead.html.erb +14 -0
- data/app/views/org/admin/departments/_index_tr.html.erb +23 -0
- data/app/views/org/admin/departments/_member.html.erb +28 -0
- data/app/views/org/admin/departments/_menu.html.erb +12 -0
- data/app/views/org/admin/departments/_new_form.html.erb +4 -0
- data/app/views/org/admin/departments/_show/_breadcrumb.html.erb +9 -0
- data/app/views/org/admin/departments/_show/_thead.html.erb +9 -0
- data/app/views/org/admin/departments/_show.json.jbuilder +1 -0
- data/app/views/org/admin/departments/index.html.erb +14 -0
- data/app/views/org/admin/departments/index.json.jbuilder +1 -0
- data/app/views/org/admin/departments/need.html.erb +12 -0
- data/app/views/org/admin/departments/show.html.erb +25 -0
- data/app/views/org/admin/departments/supports.html.erb +28 -0
- data/app/views/org/admin/home/index.html.erb +0 -0
- data/app/views/org/admin/job_descriptions/_edit_form.html.erb +4 -0
- data/app/views/org/admin/job_descriptions/_filter_form.html.erb +7 -0
- data/app/views/org/admin/job_descriptions/_form.html.erb +8 -0
- data/app/views/org/admin/job_descriptions/_index_tbody.html.erb +7 -0
- data/app/views/org/admin/job_descriptions/_index_thead.html.erb +8 -0
- data/app/views/org/admin/job_descriptions/_new_form.html.erb +4 -0
- data/app/views/org/admin/job_titles/_breadcrumb.html.erb +7 -0
- data/app/views/org/admin/job_titles/_edit_form.html.erb +4 -0
- data/app/views/org/admin/job_titles/_form.html.erb +3 -0
- data/app/views/org/admin/job_titles/_index_thead.html.erb +9 -0
- data/app/views/org/admin/job_titles/_job_titles.html.erb +49 -0
- data/app/views/org/admin/job_titles/_new_form.html.erb +4 -0
- data/app/views/org/admin/job_titles/_show_table.html.erb +12 -0
- data/app/views/org/admin/job_titles/_super_job_titles.html.erb +14 -0
- data/app/views/org/admin/job_titles/create_department.turbo_stream.erb +3 -0
- data/app/views/org/admin/job_titles/index.html.erb +4 -0
- data/app/views/org/admin/job_transfers/_edit_form.html.erb +4 -0
- data/app/views/org/admin/job_transfers/_filter_table.html.erb +11 -0
- data/app/views/org/admin/job_transfers/_form.html.erb +7 -0
- data/app/views/org/admin/job_transfers/_index_thead.html.erb +6 -0
- data/app/views/org/admin/job_transfers/_list.html.erb +29 -0
- data/app/views/org/admin/job_transfers/_new_form.html.erb +4 -0
- data/app/views/org/admin/job_transfers/index.html.erb +3 -0
- data/app/views/org/admin/job_transfers/my.html.erb +7 -0
- data/app/views/org/admin/job_transfers/show.html.erb +54 -0
- data/app/views/org/admin/member_departments/_edit_form.html.erb +3 -0
- data/app/views/org/admin/member_departments/_filter_form.html.erb +8 -0
- data/app/views/org/admin/member_departments/_form.html.erb +4 -0
- data/app/views/org/admin/member_departments/_job_title_options.html.erb +10 -0
- data/app/views/org/admin/member_departments/_new_form.html.erb +3 -0
- data/app/views/org/admin/member_departments/_organ_options.html.erb +1 -0
- data/app/views/org/admin/member_departments/_show_table.html.erb +20 -0
- data/app/views/org/admin/member_departments/_super_job_title_options.html.erb +10 -0
- data/app/views/org/admin/member_departments/index.html.erb +38 -0
- data/app/views/org/admin/member_departments/options.js.erb +4 -0
- data/app/views/org/admin/member_departments/show.html.erb +7 -0
- data/app/views/org/admin/members/_button.html.erb +6 -0
- data/app/views/org/admin/members/_edit/_breadcrumb.html.erb +12 -0
- data/app/views/org/admin/members/_edit_form.html.erb +4 -0
- data/app/views/org/admin/members/_edit_table.html.erb +3 -0
- data/app/views/org/admin/members/_filter_form.html.erb +10 -0
- data/app/views/org/admin/members/_filter_table.html.erb +9 -0
- data/app/views/org/admin/members/_form.html.erb +9 -0
- data/app/views/org/admin/members/_index_tbody.html.erb +24 -0
- data/app/views/org/admin/members/_index_thead.html.erb +7 -0
- data/app/views/org/admin/members/_index_tr.html.erb +22 -0
- data/app/views/org/admin/members/_item_field.html.erb +3 -0
- data/app/views/org/admin/members/_item_form.html.erb +27 -0
- data/app/views/org/admin/members/_member.json.jbuilder +5 -0
- data/app/views/org/admin/members/_menu.html.erb +11 -0
- data/app/views/org/admin/members/_new/_breadcrumb.html.erb +6 -0
- data/app/views/org/admin/members/_new_form.html.erb +4 -0
- data/app/views/org/admin/members/_outer_options.html.erb +4 -0
- data/app/views/org/admin/members/_profile/_show_table.html.erb +38 -0
- data/app/views/org/admin/members/_profile_form.html.erb +17 -0
- data/app/views/org/admin/members/_show/_breadcrumb.html.erb +6 -0
- data/app/views/org/admin/members/_show.json.jbuilder +1 -0
- data/app/views/org/admin/members/_show_table.html.erb +54 -0
- data/app/views/org/admin/members/edit_profile.html.erb +1 -0
- data/app/views/org/admin/members/index.html.erb +5 -0
- data/app/views/org/admin/members/index.json.jbuilder +1 -0
- data/app/views/org/admin/members/options.turbo_stream.erb +7 -0
- data/app/views/org/admin/members/profile.html.erb +16 -0
- data/app/views/org/admin/members/super_options.js.erb +15 -0
- data/app/views/org/admin/organ_domains/_breadcrumb.html.erb +6 -0
- data/app/views/org/admin/organ_domains/_edit_form.html.erb +4 -0
- data/app/views/org/admin/organ_domains/_filter_form.html.erb +9 -0
- data/app/views/org/admin/organ_domains/_form.html.erb +5 -0
- data/app/views/org/admin/organ_domains/_index_tbody.html.erb +12 -0
- data/app/views/org/admin/organ_domains/_index_thead.html.erb +8 -0
- data/app/views/org/admin/organ_domains/_new_form.html.erb +4 -0
- data/app/views/org/admin/organ_domains/_show_table.html.erb +20 -0
- data/app/views/org/admin/organ_domains/index.html.erb +5 -0
- data/app/views/org/admin/organs/_edit_form.html.erb +6 -0
- data/app/views/org/admin/organs/_filter_form.html.erb +9 -0
- data/app/views/org/admin/organs/_form.html.erb +6 -0
- data/app/views/org/admin/organs/_index_tbody.html.erb +17 -0
- data/app/views/org/admin/organs/_index_thead.html.erb +9 -0
- data/app/views/org/admin/organs/_index_tr.html.erb +22 -0
- data/app/views/org/admin/organs/_new_form.html.erb +8 -0
- data/app/views/org/admin/organs/_organ.json.jbuilder +7 -0
- data/app/views/org/admin/organs/_show.json.jbuilder +1 -0
- data/app/views/org/admin/organs/_show_table.html.erb +16 -0
- data/app/views/org/admin/organs/index.html.erb +4 -0
- data/app/views/org/admin/organs/index.json.jbuilder +1 -0
- data/app/views/org/admin/organs/show.json.jbuilder +1 -0
- data/app/views/org/admin/resign_reasons/_edit_form.html.erb +4 -0
- data/app/views/org/admin/resign_reasons/_filter_form.html.erb +7 -0
- data/app/views/org/admin/resign_reasons/_form.html.erb +3 -0
- data/app/views/org/admin/resign_reasons/_new_form.html.erb +4 -0
- data/app/views/org/admin/resign_reasons/_resign_reason.html.erb +13 -0
- data/app/views/org/admin/resign_reasons/index.html.erb +30 -0
- data/app/views/org/admin/resigns/_edit_form.html.erb +4 -0
- data/app/views/org/admin/resigns/_form.html.erb +6 -0
- data/app/views/org/admin/resigns/_index_tbody.html.erb +23 -0
- data/app/views/org/admin/resigns/_index_thead.html.erb +6 -0
- data/app/views/org/admin/resigns/_new_form.html.erb +4 -0
- data/app/views/org/admin/resigns/_search_chart1_form.html.erb +9 -0
- data/app/views/org/admin/resigns/_search_chart2_form.html.erb +8 -0
- data/app/views/org/admin/resigns/_search_form.html.erb +8 -0
- data/app/views/org/admin/resigns/charts.html.erb +19 -0
- data/app/views/org/admin/resigns/index.html.erb +1 -0
- data/app/views/org/admin/resigns/my.html.erb +1 -0
- data/app/views/org/admin/resigns/show.html.erb +47 -0
- data/app/views/org/admin/super_job_titles/_breadcrumb.html.erb +6 -0
- data/app/views/org/admin/super_job_titles/_edit_form.html.erb +4 -0
- data/app/views/org/admin/super_job_titles/_filter_form.html.erb +9 -0
- data/app/views/org/admin/super_job_titles/_form.html.erb +3 -0
- data/app/views/org/admin/super_job_titles/_index_tbody.html.erb +13 -0
- data/app/views/org/admin/super_job_titles/_index_thead.html.erb +6 -0
- data/app/views/org/admin/super_job_titles/_new_form.html.erb +4 -0
- data/app/views/org/admin/super_job_titles/_show_table.html.erb +12 -0
- data/app/views/org/admin/super_job_titles/index.html.erb +5 -0
- data/app/views/org/admin/supports/_edit_form.html.erb +4 -0
- data/app/views/org/admin/supports/_filter_form.html.erb +8 -0
- data/app/views/org/admin/supports/_form.html.erb +6 -0
- data/app/views/org/admin/supports/_index_tbody.html.erb +5 -0
- data/app/views/org/admin/supports/_index_thead.html.erb +6 -0
- data/app/views/org/admin/supports/_new_form.html.erb +4 -0
- data/app/views/org/admin/supports/index.html.erb +5 -0
- data/app/views/org/admin/tutorials/_edit_form.html.erb +4 -0
- data/app/views/org/admin/tutorials/_filter_form.html.erb +9 -0
- data/app/views/org/admin/tutorials/_form.html.erb +5 -0
- data/app/views/org/admin/tutorials/_index_tbody.html.erb +19 -0
- data/app/views/org/admin/tutorials/_index_thead.html.erb +15 -0
- data/app/views/org/admin/tutorials/_new_form.html.erb +8 -0
- data/app/views/org/admin/tutorials/index.html.erb +5 -0
- data/app/views/org/admin/tutorials/my.html.erb +5 -0
- data/app/views/org/board/base/_nav.html.erb +4 -0
- data/app/views/org/board/members/_form.html+phone.erb +29 -0
- data/app/views/org/board/members/_form.html.erb +4 -0
- data/app/views/org/board/members/_member.json.jbuilder +11 -0
- data/app/views/org/board/members/_new_form.html+phone.erb +4 -0
- data/app/views/org/board/members/_new_form.html.erb +4 -0
- data/app/views/org/board/members/index.html+phone.erb +40 -0
- data/app/views/org/board/members/index.html.erb +28 -0
- data/app/views/org/board/members/index.json.jbuilder +1 -0
- data/app/views/org/board/members/login.json.jbuilder +1 -0
- data/app/views/org/board/organs/_form.html.erb +4 -0
- data/app/views/org/board/organs/_new_form.html.erb +4 -0
- data/app/views/org/board/organs/create.turbo_stream.erb +3 -0
- data/app/views/org/board/organs/index.html+phone.erb +9 -0
- data/app/views/org/board/organs/index.html.erb +41 -0
- data/app/views/org/board/organs/showx.html.erb +1 -0
- data/app/views/org/me/base/_nav.html.erb +3 -0
- data/app/views/org/me/departments/_breadcrumb.html.erb +5 -0
- data/app/views/org/me/departments/_department.html.erb +31 -0
- data/app/views/org/me/departments/_filter_form.html.erb +9 -0
- data/app/views/org/me/departments/_index_thead.html.erb +5 -0
- data/app/views/org/me/departments/_index_tr.html.erb +10 -0
- data/app/views/org/me/departments/_member.html.erb +11 -0
- data/app/views/org/me/departments/_nav_show.erb +16 -0
- data/app/views/org/me/departments/index.html.erb +11 -0
- data/app/views/org/me/departments/index2.html.erb +46 -0
- data/app/views/org/me/home/index.html.erb +8 -0
- data/app/views/org/me/job_transfers/_form.html.erb +8 -0
- data/app/views/org/me/job_transfers/_index_tbody.html.erb +7 -0
- data/app/views/org/me/job_transfers/_index_thead.html.erb +6 -0
- data/app/views/org/me/job_transfers/_tabs.html.erb +9 -0
- data/app/views/org/me/job_transfers/index.html.erb +25 -0
- data/app/views/org/me/members/_badges.html.erb +13 -0
- data/app/views/org/me/members/_edit.html+phone.erb +10 -0
- data/app/views/org/me/members/_edit_form.html.erb +6 -0
- data/app/views/org/me/members/_member.json.jbuilder +6 -0
- data/app/views/org/me/members/_show.json.jbuilder +1 -0
- data/app/views/org/me/members/_show_table.html.erb +24 -0
- data/app/views/org/me/members/index.json.jbuilder +1 -0
- data/app/views/org/me/members/show.json.jbuilder +1 -0
- data/app/views/org/me/orders/_search_form.html.erb +7 -0
- data/app/views/org/me/orders/dinners.html.erb +32 -0
- data/app/views/org/me/orders/new.html.erb +5 -0
- data/app/views/org/me/orders/show.html.erb +0 -0
- data/app/views/org/me/resigns/_form.html.erb +12 -0
- data/app/views/org/me/resigns/_tabs.html.erb +4 -0
- data/app/views/org/me/resigns/show.html.erb +45 -0
- data/app/views/org/me/tutorials/_form.html.erb +6 -0
- data/app/views/org/me/tutorials/_menu.html.erb +11 -0
- data/app/views/org/me/tutorials/_search_form.html.erb +7 -0
- data/app/views/org/me/tutorials/index.html.erb +35 -0
- data/app/views/org/me/tutorials/perform.html.erb +21 -0
- data/app/views/org/me/tutorials/tutorings.html.erb +40 -0
- data/app/views/org/members/_filter_form.html.erb +9 -0
- data/app/views/org/members/_filter_table.html.erb +11 -0
- data/app/views/org/members/groups.json.jbuilder +5 -0
- data/app/views/org/members/index.html.erb +24 -0
- data/app/views/org/members/journals.json.jbuilder +9 -0
- data/app/views/org/members/people.json.jbuilder +14 -0
- data/app/views/org/members/sections.json.jbuilder +5 -0
- data/app/views/org/members/show.html+phone.erb +23 -0
- data/app/views/org/members/show.html.erb +39 -0
- data/app/views/org/organs/_form_search.html.erb +11 -0
- data/app/views/org/organs/form_search.js.erb +1 -0
- data/app/views/org/organs/index.html+phone.erb +20 -0
- data/app/views/org/organs/index.html.erb +18 -0
- data/app/views/org/organs/show.html.erb +0 -0
- data/app/views/org/panel/base/_nav.html.erb +3 -0
- data/app/views/org/panel/organs/_edit_form.html.erb +6 -0
- data/app/views/org/panel/organs/_filter_form.html.erb +9 -0
- data/app/views/org/panel/organs/_form.html.erb +5 -0
- data/app/views/org/panel/organs/_index_tbody.html.erb +28 -0
- data/app/views/org/panel/organs/_index_thead.html.erb +12 -0
- data/app/views/org/panel/organs/_index_tr.html.erb +19 -0
- data/app/views/org/panel/organs/_new_form.html.erb +6 -0
- data/app/views/org/panel/organs/_show_table.html.erb +16 -0
- data/app/views/org/panel/organs/index.html.erb +5 -0
- data/app/views/our/_nav_bar.html.erb +18 -0
- data/app/views/our/_nav_choosex.html.erb +23 -0
- data/app/views/panel/_org_nav.html.erb +10 -0
- data/config/locales/en.attributes.yml +37 -0
- data/config/locales/en.controller.yml +113 -0
- data/config/locales/en.enum.yml +31 -0
- data/config/locales/zh.attributes.yml +89 -0
- data/config/locales/zh.controller.yml +116 -0
- data/config/locales/zh.enum.yml +31 -0
- data/config/locales/zh.help.yml +7 -0
- data/config/routes.rb +152 -0
- data/lib/rails_org/config.rb +13 -0
- data/lib/rails_org/default_form.rb +17 -0
- data/lib/rails_org/engine.rb +19 -0
- data/lib/rails_org.rb +3 -0
- data/test/application_system_test_case.rb +5 -0
- data/test/controllers/department_journals_controller_test.rb +48 -0
- data/test/controllers/job_transfers_controller_test.rb +48 -0
- data/test/controllers/journal_transfers_controller_test.rb +48 -0
- data/test/controllers/org/admin/authorized_tokens_controller_test.rb +49 -0
- data/test/controllers/org/admin/department_grants_controller_test.rb +48 -0
- data/test/controllers/org/admin/departments_controller_test.rb +51 -0
- data/test/controllers/org/admin/job_descriptions_controller_test.rb +48 -0
- data/test/controllers/org/admin/job_titles_controller_test.rb +51 -0
- data/test/controllers/org/admin/member_departments_controller_test.rb +48 -0
- data/test/controllers/org/admin/organ_domains_controller_test.rb +49 -0
- data/test/controllers/org/admin/organ_handles_controller_test.rb +48 -0
- data/test/controllers/org/admin/organ_tokens_controller_test.rb +48 -0
- data/test/controllers/org/admin/super_job_titles_controller_test.rb +51 -0
- data/test/controllers/org/mine/members_controller_test.rb +49 -0
- data/test/controllers/resign_reasons_controller_test.rb +48 -0
- data/test/controllers/resigns_controller_test.rb +48 -0
- data/test/controllers/tutorials_controller_test.rb +48 -0
- data/test/dummy/Gemfile +59 -0
- data/test/dummy/Gemfile.lock +379 -0
- data/test/dummy/README.md +12 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/images/default_avatar.jpg +0 -0
- data/test/dummy/app/assets/images/logo.png +0 -0
- data/test/dummy/app/assets/javascripts/admin/application.js +1 -0
- data/test/dummy/app/assets/javascripts/application.js +11 -0
- data/test/dummy/app/assets/javascripts/phone.js +5 -0
- data/test/dummy/app/assets/stylesheets/css.scss +4 -0
- data/test/dummy/app/channels/application_cable/channel.rb +4 -0
- data/test/dummy/app/channels/application_cable/connection.rb +4 -0
- data/test/dummy/app/controllers/active_storage/base_controller.rb +19 -0
- data/test/dummy/app/controllers/admin_controller.rb +3 -0
- data/test/dummy/app/controllers/application_controller.rb +12 -0
- data/test/dummy/app/controllers/home_controller.rb +6 -0
- data/test/dummy/app/controllers/me_controller.rb +4 -0
- data/test/dummy/app/controllers/my_controller.rb +4 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/jobs/application_job.rb +2 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/auth/user.rb +7 -0
- data/test/dummy/app/views/home/index.css +3 -0
- data/test/dummy/app/views/home/index.html.erb +0 -0
- data/test/dummy/app/views/layouts/_right_menu.html.erb +3 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +34 -0
- data/test/dummy/bin/vite +19 -0
- data/test/dummy/bin/yarn +11 -0
- data/test/dummy/config/application.rb +20 -0
- data/test/dummy/config/boot.rb +9 -0
- data/test/dummy/config/cable.yml +9 -0
- data/test/dummy/config/credentials/development.key +1 -0
- data/test/dummy/config/credentials/test.key +1 -0
- data/test/dummy/config/credentials.yml.enc +1 -0
- data/test/dummy/config/database.yml +16 -0
- data/test/dummy/config/environment.rb +3 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +74 -0
- data/test/dummy/config/environments/test.rb +47 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +0 -0
- data/test/dummy/config/initializers/new_framework_defaults.rb +14 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +2 -0
- data/test/dummy/config/master.key +1 -0
- data/test/dummy/config/puma.rb +34 -0
- data/test/dummy/config/routes.rb +14 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/config/storage.yml +11 -0
- data/test/dummy/config/vite/base.js +7 -0
- data/test/dummy/config/vite/development.js +6 -0
- data/test/dummy/config/vite/production.js +6 -0
- data/test/dummy/config.ru +7 -0
- data/test/dummy/lib/deploy.rb +115 -0
- data/test/dummy/package.json +27 -0
- data/test/dummy/postcss.config.js +11 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/test/dummy/public/apple-touch-icon.png +0 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/yarn.lock +2147 -0
- data/test/factories/attendance_logs.rb +5 -0
- data/test/factories/badges.rb +5 -0
- data/test/factories/bands.rb +5 -0
- data/test/factories/department_grants.rb +8 -0
- data/test/factories/department_journals.rb +5 -0
- data/test/factories/departments.rb +12 -0
- data/test/factories/job_descriptions.rb +5 -0
- data/test/factories/job_titles.rb +9 -0
- data/test/factories/job_transfers.rb +5 -0
- data/test/factories/resigns.rb +5 -0
- data/test/factories/super_job_titles.rb +8 -0
- data/test/factories/tutorials.rb +5 -0
- data/test/mailers/previews/the_notify_mailer_preview.rb +9 -0
- data/test/models/department_test.rb +7 -0
- data/test/models/job_description_test.rb +7 -0
- data/test/models/job_title/department_job_title_test.rb +1 -0
- data/test/models/job_title/super_job_title_test.rb +1 -0
- data/test/models/job_title_test.rb +10 -0
- data/test/models/job_transfer_test.rb +7 -0
- data/test/models/resign_test.rb +7 -0
- data/test/models/teacher_test.rb +7 -0
- data/test/models/tutorial_test.rb +7 -0
- data/test/system/org/admin/authorized_tokens_test.rb +51 -0
- data/test/system/org/admin/organ_domains_test.rb +51 -0
- data/test/system/org/mine/members_test.rb +41 -0
- data/test/test_helper.rb +14 -0
- metadata +654 -0
@@ -0,0 +1,108 @@
|
|
1
|
+
module Org
|
2
|
+
module Model::JobTransfer
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attr_accessor :department_ancestors
|
7
|
+
attribute :state, :string, default: 'init'
|
8
|
+
attribute :transfer_on, :date
|
9
|
+
attribute :reason_note, :string, limit: 4096
|
10
|
+
|
11
|
+
belongs_to :member
|
12
|
+
belongs_to :to_office, class_name: 'Office', optional: true
|
13
|
+
belongs_to :to_department, class_name: 'Department', optional: true
|
14
|
+
belongs_to :to_job_title, class_name: 'JobTitle', optional: true
|
15
|
+
belongs_to :from_office, class_name: 'Office', optional: true
|
16
|
+
belongs_to :from_department, class_name: 'Department', optional: true
|
17
|
+
belongs_to :from_job_title, class_name: 'JobTitle', optional: true
|
18
|
+
|
19
|
+
enum state: {
|
20
|
+
init: 'init',
|
21
|
+
approved_sl: 'approved sl',
|
22
|
+
approved_om: 'approved om',
|
23
|
+
rejected: 'rejected'
|
24
|
+
}
|
25
|
+
|
26
|
+
validate :validate_select_option
|
27
|
+
validates :transfer_on, :reason_note, presence: true
|
28
|
+
|
29
|
+
after_initialize if: :new_record? do
|
30
|
+
self.from_office_id = self.member&.office_id
|
31
|
+
self.from_department_id = self.member&.department_id
|
32
|
+
self.from_job_title_id = self.member&.job_title_id
|
33
|
+
self.state = JobTransfer::states[:approved_sl] if self.member&.leading_department
|
34
|
+
end
|
35
|
+
after_create_commit :send_notification
|
36
|
+
|
37
|
+
acts_as_notify :default, only: []
|
38
|
+
end
|
39
|
+
|
40
|
+
def approve_config
|
41
|
+
{
|
42
|
+
approved_sl: member.department&.leader,
|
43
|
+
approved_om: member.office&.leader
|
44
|
+
}.with_indifferent_access
|
45
|
+
end
|
46
|
+
|
47
|
+
def next_operator
|
48
|
+
approve_config[next_state_state]
|
49
|
+
end
|
50
|
+
|
51
|
+
def next_state_state
|
52
|
+
next_state_states.first
|
53
|
+
end
|
54
|
+
|
55
|
+
def next_state_states
|
56
|
+
next_states(:state)
|
57
|
+
end
|
58
|
+
|
59
|
+
def do_trigger(params = {})
|
60
|
+
self.trigger_to state: params[:state]
|
61
|
+
|
62
|
+
self.class.transaction do
|
63
|
+
self.save!
|
64
|
+
to_notification(
|
65
|
+
member: self.member,
|
66
|
+
title: "Your Job Transfer request has been #{self.state_i18n}",
|
67
|
+
body: "Your Job Transfer request has been #{self.state_i18n}.",
|
68
|
+
link: url_helpers.my_job_transfers_url(id: self.id),
|
69
|
+
cc_emails: cc_emails(self.member.email)
|
70
|
+
)
|
71
|
+
if self.approved_sl?
|
72
|
+
send_notification
|
73
|
+
elsif self.approved_om? && transfer_on <= Date.today
|
74
|
+
member.update(department_id: self.to_department_id, office_id: self.to_office_id)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def send_notification
|
80
|
+
to = next_operator
|
81
|
+
to_notification(
|
82
|
+
member: to,
|
83
|
+
title: "#{self.member.name} has requested Job Transfer",
|
84
|
+
body: "#{self.member.name} has requested Job Transfer.",
|
85
|
+
code: self.state,
|
86
|
+
link: url_helpers.my_admin_job_transfers_url
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
def validate_select_option
|
91
|
+
self.errors.add :base, 'Please select the office you want to' if self.to_office.nil?
|
92
|
+
self.errors.add :base, 'Please select the department you want to' if self.to_department.nil?
|
93
|
+
end
|
94
|
+
|
95
|
+
def cc_emails(to)
|
96
|
+
cc = [
|
97
|
+
member.office.leader&.email,
|
98
|
+
member.department.leader&.email,
|
99
|
+
to_office.leader&.email,
|
100
|
+
to_department.leader&.email,
|
101
|
+
member.email
|
102
|
+
]
|
103
|
+
cc.delete(to)
|
104
|
+
cc.uniq.compact
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
module Org
|
2
|
+
module Model::Member
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
delegate :url_helpers, to: 'Rails.application.routes'
|
7
|
+
has_taxons :department
|
8
|
+
|
9
|
+
attribute :identity, :string, index: true
|
10
|
+
attribute :experience, :string
|
11
|
+
attribute :attendance_number, :string
|
12
|
+
attribute :owned, :boolean, default: false
|
13
|
+
attribute :organ_root_id, :integer
|
14
|
+
attribute :name, :string
|
15
|
+
attribute :number, :string
|
16
|
+
attribute :join_on, :date
|
17
|
+
attribute :enabled, :boolean, default: true
|
18
|
+
attribute :state, :string
|
19
|
+
|
20
|
+
belongs_to :account, -> { where(confirmed: true) }, class_name: 'Auth::Account', primary_key: :identity, foreign_key: :identity, optional: true
|
21
|
+
has_one :user, class_name: 'Auth::User', through: :account
|
22
|
+
belongs_to :profile, ->(o){ where(organ_id: o.organ_id) }, class_name: 'Profiled::Profile', primary_key: :identity, foreign_key: :identity, optional: true
|
23
|
+
|
24
|
+
belongs_to :organ, counter_cache: true, inverse_of: :members
|
25
|
+
|
26
|
+
has_many :member_departments, dependent: :delete_all
|
27
|
+
has_many :departments, through: :member_departments
|
28
|
+
has_many :job_titles, through: :member_departments
|
29
|
+
has_many :members, through: :member_departments, source: :members
|
30
|
+
accepts_nested_attributes_for :member_departments, reject_if: :all_blank, allow_destroy: true
|
31
|
+
|
32
|
+
has_many :inferior_member_departments, class_name: 'Org::MemberDepartment', foreign_key: :superior_id, primary_key: :department_ids
|
33
|
+
has_many :authorized_tokens, dependent: :nullify
|
34
|
+
|
35
|
+
has_one :resign
|
36
|
+
has_one :tutorial, ->{ order(created_at: :desc) }, dependent: :nullify
|
37
|
+
has_one :tutor, through: :tutorial
|
38
|
+
has_many :tutorials, dependent: :nullify
|
39
|
+
has_many :tutorings, class_name: 'Org::Tutorial', foreign_key: :tutor_id
|
40
|
+
has_many :tutees, through: :tutorings, source: :member
|
41
|
+
#has_many :job_transfers, dependent: :destroy
|
42
|
+
|
43
|
+
has_one_attached :avatar
|
44
|
+
has_one_attached :resume
|
45
|
+
|
46
|
+
scope :enabled, -> { where(enabled: true) }
|
47
|
+
|
48
|
+
validates :identity, uniqueness: { scope: :organ_id }
|
49
|
+
|
50
|
+
#before_save :sync_tutorials, if: -> { join_on_changed? }
|
51
|
+
before_save :sync_avatar_from_user, if: -> { identity_changed? }
|
52
|
+
#after_create :sync_member_roles, if: -> { owned? }
|
53
|
+
end
|
54
|
+
|
55
|
+
def admin?
|
56
|
+
owned?
|
57
|
+
end
|
58
|
+
|
59
|
+
def grade
|
60
|
+
member_departments.minimum(:grade)
|
61
|
+
end
|
62
|
+
|
63
|
+
def sync_avatar_from_user
|
64
|
+
if user
|
65
|
+
self.name ||= user.name
|
66
|
+
self.avatar_blob ||= user.avatar_blob
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def direct_follower_ids
|
71
|
+
member_departments.map do |md|
|
72
|
+
md.direct_followers.pluck(:member_id)
|
73
|
+
end.flatten.uniq
|
74
|
+
end
|
75
|
+
|
76
|
+
def direct_followers
|
77
|
+
Member.where(id: direct_follower_ids)
|
78
|
+
end
|
79
|
+
|
80
|
+
def all_follower_ids
|
81
|
+
(member_departments.map do |md|
|
82
|
+
md.self_and_descendants.pluck(:member_id)
|
83
|
+
end.flatten + [self.id]).uniq
|
84
|
+
end
|
85
|
+
|
86
|
+
def all_followers
|
87
|
+
Member.where(id: all_lower_ids)
|
88
|
+
end
|
89
|
+
|
90
|
+
def lower_job_title_ids
|
91
|
+
job_titles.map(&:lower_job_title_ids).flatten.uniq
|
92
|
+
end
|
93
|
+
|
94
|
+
def all_lower_ids
|
95
|
+
MemberDepartment.where(job_title_id: lower_job_title_ids).pluck(:member_id)
|
96
|
+
end
|
97
|
+
|
98
|
+
def leader
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
def get_organ_grant
|
103
|
+
at = account.authorized_token
|
104
|
+
at.update member_id: self.id
|
105
|
+
at
|
106
|
+
end
|
107
|
+
|
108
|
+
def mock_organ_grant(user_id)
|
109
|
+
grant = self.organ_grants.find_or_create_by(user_id: user_id)
|
110
|
+
unless grant.verify_token?
|
111
|
+
grant.update_token!
|
112
|
+
end
|
113
|
+
grant
|
114
|
+
end
|
115
|
+
|
116
|
+
def leading_members
|
117
|
+
Member.where(department_id: leading_department.self_and_descendant_ids)
|
118
|
+
end
|
119
|
+
|
120
|
+
def leading_member_ids
|
121
|
+
leading_members.pluck(:id)
|
122
|
+
end
|
123
|
+
|
124
|
+
def leading_highest_department
|
125
|
+
leading_departments = self.leading_departments
|
126
|
+
unless leading_departments.empty?
|
127
|
+
leading_departments = self.leading_departments.sort_by(&:depth)
|
128
|
+
end
|
129
|
+
leading_departments.first
|
130
|
+
end
|
131
|
+
|
132
|
+
def avatar_url
|
133
|
+
url_helpers.rails_blob_url(avatar) if avatar.attachment.present?
|
134
|
+
end
|
135
|
+
|
136
|
+
def sync_member_roles
|
137
|
+
role = Roled::Role.default_where('who_types-any': 'Member', code: RailsOrg.config.super_role_code).take
|
138
|
+
who_roles.create(role_id: role.id) if role
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Org
|
2
|
+
module Model::MemberDepartment
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
has_taxons :department
|
7
|
+
|
8
|
+
attribute :department_root_id, :integer
|
9
|
+
attribute :superior_id, :integer
|
10
|
+
attribute :grade, :integer, default: 0
|
11
|
+
|
12
|
+
belongs_to :member
|
13
|
+
belongs_to :department, counter_cache: true, inverse_of: :member_departments
|
14
|
+
belongs_to :job_title
|
15
|
+
has_many :descendant_hierarchies, class_name: 'DepartmentHierarchy', foreign_key: :ancestor_id, primary_key: :department_id
|
16
|
+
has_many :self_and_descendants, ->(o){ default_where('grade-gt': o.grade) }, through: :descendant_hierarchies, source: :member_department
|
17
|
+
has_many :members, through: :self_and_descendants, source: :member
|
18
|
+
|
19
|
+
validates :department_id, uniqueness: { scope: :member_id }
|
20
|
+
|
21
|
+
before_save :sync_from_job_title, if: -> { (changes.keys & ['job_title_id', 'department_id']).present? }
|
22
|
+
after_save_commit :sync_department_members_count, if: -> { saved_change_to_department_id? }
|
23
|
+
after_save_commit :sync_role_ids
|
24
|
+
end
|
25
|
+
|
26
|
+
def direct_followers
|
27
|
+
self.class.default_where(department_id: department_id, 'grade-gt': self.grade)
|
28
|
+
end
|
29
|
+
|
30
|
+
def job_title_options
|
31
|
+
if department
|
32
|
+
JobTitle.where(department_root_id: department.root.id)
|
33
|
+
else
|
34
|
+
JobTitle.none
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def sync_from_job_title
|
39
|
+
self.department_id = job_title.department_id
|
40
|
+
self.grade = job_title.grade
|
41
|
+
|
42
|
+
self.superior_id = department.superior_id
|
43
|
+
self.department_root_id = department.root.id
|
44
|
+
end
|
45
|
+
|
46
|
+
def sync_department_members_count
|
47
|
+
self.class.transaction do
|
48
|
+
Department.increment_counter :all_member_departments_count, department.self_and_ancestor_ids
|
49
|
+
|
50
|
+
if department_id_before_last_save
|
51
|
+
depart = Department.find(department_id_before_last_save)
|
52
|
+
Department.decrement_counter :all_member_departments_count, depart.self_and_ancestor_ids
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def sync_role_ids
|
58
|
+
r_ids = self.member.role_ids
|
59
|
+
if job_title
|
60
|
+
r_ids = r_ids | self.job_title.role_ids
|
61
|
+
end
|
62
|
+
self.member.role_ids = r_ids
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Org
|
2
|
+
module Model::Organ
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attribute :name, :string
|
7
|
+
attribute :name_short, :string
|
8
|
+
attribute :address, :string
|
9
|
+
attribute :members_count, :integer, default: 0
|
10
|
+
attribute :official, :boolean, default: false, comment: '是否官方'
|
11
|
+
attribute :joinable, :boolean, default: false, comment: '是否可搜索并加入'
|
12
|
+
attribute :domain, :string
|
13
|
+
|
14
|
+
has_taxons :area
|
15
|
+
belongs_to :area, class_name: 'Profiled::Area', optional: true
|
16
|
+
|
17
|
+
has_one :organ_domain, -> { where(default: true) }, inverse_of: :organ
|
18
|
+
has_many :supports, -> { where(department_id: nil) }, dependent: :destroy
|
19
|
+
has_many :departments, dependent: :destroy
|
20
|
+
has_many :members, dependent: :destroy
|
21
|
+
has_many :super_job_titles, dependent: :destroy
|
22
|
+
has_many :organ_domains, dependent: :destroy
|
23
|
+
accepts_nested_attributes_for :members
|
24
|
+
|
25
|
+
has_one_attached :logo
|
26
|
+
|
27
|
+
scope :official, -> { where(official: true) }
|
28
|
+
|
29
|
+
validates :name, presence: true
|
30
|
+
end
|
31
|
+
|
32
|
+
def host
|
33
|
+
if domain.blank?
|
34
|
+
init_organ_domain
|
35
|
+
save
|
36
|
+
end
|
37
|
+
# todo deal with port
|
38
|
+
ActionDispatch::Http::URL.url_for(
|
39
|
+
host: domain,
|
40
|
+
protocol: Rails.application.routes.default_url_options[:protocol]
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
def url_options
|
45
|
+
od = organ_domain || organ_domains.take || build_organ_domain
|
46
|
+
od.as_json(only: [:host, :port])
|
47
|
+
end
|
48
|
+
|
49
|
+
def init_organ_domain
|
50
|
+
organ_domain || build_organ_domain
|
51
|
+
end
|
52
|
+
|
53
|
+
def domains
|
54
|
+
organ_domains.pluck(:identifier)
|
55
|
+
end
|
56
|
+
|
57
|
+
def admin?
|
58
|
+
Array(cached_role_ids).compact.blank? && official?
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Org
|
2
|
+
module Model::OrganDomain
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attribute :subdomain, :string
|
7
|
+
attribute :domain, :string, default: Rails.application.routes.default_url_options[:host]
|
8
|
+
attribute :port, :string, default: Rails.application.routes.default_url_options[:port]
|
9
|
+
attribute :host, :string
|
10
|
+
attribute :identifier, :string, index: true
|
11
|
+
attribute :appid, :string
|
12
|
+
attribute :default, :boolean, default: false
|
13
|
+
|
14
|
+
belongs_to :organ
|
15
|
+
belongs_to :wechat_app, class_name: 'Wechat::App', foreign_key: :appid, primary_key: :appid, optional: true
|
16
|
+
|
17
|
+
validates :identifier, uniqueness: true
|
18
|
+
|
19
|
+
after_initialize :init_subdomain, if: -> { new_record? && subdomain.nil? }
|
20
|
+
before_validation :compute_identifier, if: -> { (changes.keys & ['domain', 'subdomain', 'port', 'host']).present? }
|
21
|
+
after_update :set_default, if: -> { default? && saved_change_to_default? }
|
22
|
+
after_save :sync_domain_to_organ, if: -> { saved_change_to_identifier? || (default? && saved_change_to_default?) }
|
23
|
+
end
|
24
|
+
|
25
|
+
def set_default
|
26
|
+
self.class.where.not(id: self.id).where(organ_id: self.organ_id).update_all(default: false)
|
27
|
+
end
|
28
|
+
|
29
|
+
def sync_domain_to_organ
|
30
|
+
organ.update domain: identifier
|
31
|
+
end
|
32
|
+
|
33
|
+
def compute_identifier
|
34
|
+
self.host = [subdomain.presence, domain].compact.join('.')
|
35
|
+
self.identifier = [host, port.presence].compact.join(':')
|
36
|
+
end
|
37
|
+
|
38
|
+
def init_subdomain
|
39
|
+
self.subdomain = ['org', organ_id].join('-')
|
40
|
+
compute_identifier
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Org
|
2
|
+
module Model::OrganHandle
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attribute :record_class, :string
|
7
|
+
attribute :record_column, :string
|
8
|
+
attribute :name, :string
|
9
|
+
attribute :description, :string
|
10
|
+
|
11
|
+
has_many :department_grants, dependent: :destroy
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Org
|
2
|
+
module Model::Resign
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attribute :leave_on, :date
|
7
|
+
attribute :reason_note, :string
|
8
|
+
attribute :handover_note, :string
|
9
|
+
attribute :comment, :string
|
10
|
+
|
11
|
+
validates :leave_on, :reason_note, presence: true
|
12
|
+
validate :validate_resign_reasons
|
13
|
+
|
14
|
+
belongs_to :member
|
15
|
+
has_many :resign_references
|
16
|
+
has_many :resign_reasons, through: :resign_references
|
17
|
+
|
18
|
+
enum state: {
|
19
|
+
init: 'init',
|
20
|
+
approved: 'approved',
|
21
|
+
rejected: 'rejected'
|
22
|
+
}, _default: 'init'
|
23
|
+
|
24
|
+
after_create_commit :send_notification
|
25
|
+
|
26
|
+
acts_as_notify only: [:reason_note, :leave_on]
|
27
|
+
end
|
28
|
+
|
29
|
+
def do_trigger(params = {})
|
30
|
+
self.trigger_to(params.slice(:state))
|
31
|
+
|
32
|
+
self.class.transaction do
|
33
|
+
self.save!
|
34
|
+
to_notification(
|
35
|
+
sender: self.member.office.leader,
|
36
|
+
member: self.member,
|
37
|
+
title: "Your resignation request has been #{self.state_i18n}.",
|
38
|
+
body: "Your resignation request has been #{self.state_i18n}.",
|
39
|
+
link: url_helpers.my_resign_url,
|
40
|
+
cc_emails: [
|
41
|
+
self.member.office.leader.email
|
42
|
+
],
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def send_notification
|
48
|
+
to_notification(
|
49
|
+
sender: self.member,
|
50
|
+
member: self.member.office.leader,
|
51
|
+
body: "#{self.member.name} has requested resignation",
|
52
|
+
title: "#{self.member.name} has requested resignation",
|
53
|
+
cc_emails: [
|
54
|
+
self.member.email
|
55
|
+
],
|
56
|
+
link: url_helpers.admin_resign_url(id: self.id),
|
57
|
+
verbose: true
|
58
|
+
)
|
59
|
+
end
|
60
|
+
|
61
|
+
def validate_resign_reasons
|
62
|
+
self.errors.add :base, 'Please select one reason at least' if self.resign_reasons.empty?
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|