diff --git a/app/controllers/admin/education/academic_years_controller.rb b/app/controllers/admin/education/academic_years_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..91346203a9d6233162bc6af9aff253e2a11eba2a --- /dev/null +++ b/app/controllers/admin/education/academic_years_controller.rb @@ -0,0 +1,60 @@ +class Admin::Education::AcademicYearsController < Admin::Education::ApplicationController + load_and_authorize_resource class: Education::AcademicYear, + through: :current_university, + through_association: :academic_years + + def index + breadcrumb + end + + def show + breadcrumb + end + + def new + breadcrumb + end + + def edit + breadcrumb + end + + def create + @academic_year.university = current_university + if @academic_year.save + redirect_to [:admin, @academic_year], + notice: t('admin.successfully_created_html', model: @academic_year.to_s) + else + breadcrumb + render :new, status: :unprocessable_entity + end + end + + def update + if @academic_year.update(academic_year_params) + redirect_to [:admin, @academic_year], + notice: t('admin.successfully_updated_html', model: @academic_year.to_s) + else + render :edit, status: :unprocessable_entity + end + end + + def destroy + @academic_year.destroy + redirect_to education_academic_years_url, + notice: t('admin.successfully_destroyed_html', model: @academic_year.to_s) + end + + protected + + def breadcrumb + super + add_breadcrumb Education::AcademicYear.model_name.human(count: 2), admin_education_academic_years_path + breadcrumb_for @academic_year + end + + def academic_year_params + params.require(:education_academic_year) + .permit(:year) + end +end diff --git a/app/views/admin/education/academic_years/_list.html.erb b/app/views/admin/education/academic_years/_list.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..fb8a61ce54151f747be38153e0e62bcfa06b65ae --- /dev/null +++ b/app/views/admin/education/academic_years/_list.html.erb @@ -0,0 +1,27 @@ +<table class="<%= table_classes %>"> + <thead> + <tr> + <th><%= Education::AcademicYear.human_attribute_name('year') %></th> + <th><%= Education::AcademicYear.human_attribute_name('cohorts') %></th> + <th><%= Education::AcademicYear.human_attribute_name('alumni') %></th> + <th></th> + </tr> + </thead> + <tbody> + <% academic_years.ordered.each do |academic_year| %> + <tr> + <td> + <%= link_to academic_year, [:admin, academic_year] %> + </td> + <td><%= academic_year.cohorts.count %></td> + <td><%= academic_year.people.count %></td> + <td class="text-end"> + <div class="btn-group" role="group"> + <%= edit_link academic_year %> + <%= destroy_link academic_year %> + </div> + </td> + </tr> + <% end %> + </tbody> +</table> diff --git a/app/views/admin/education/academic_years/index.html.erb b/app/views/admin/education/academic_years/index.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..9a8d599090681d2ecbcb496a85563fc73d2bbdff --- /dev/null +++ b/app/views/admin/education/academic_years/index.html.erb @@ -0,0 +1,3 @@ +<% content_for :title, Education::AcademicYear.model_name.human(count: 2) %> + +<%= render 'admin/education/academic_years/list', academic_years: @academic_years %> diff --git a/app/views/admin/education/academic_years/show.html.erb b/app/views/admin/education/academic_years/show.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..a5cfbc21c4ccbc9346cbb264e1acfef9e9fe1c7e --- /dev/null +++ b/app/views/admin/education/academic_years/show.html.erb @@ -0,0 +1 @@ +<% content_for :title, @academic_year %> diff --git a/app/views/admin/education/cohorts/_list.html.erb b/app/views/admin/education/cohorts/_list.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..678f6525577f18ad7321e7b83cb0dc36da5283f9 --- /dev/null +++ b/app/views/admin/education/cohorts/_list.html.erb @@ -0,0 +1,30 @@ +<table class="<%= table_classes %>"> + <thead> + <tr> + <th><%= Education::Cohort.human_attribute_name('year') %></th> + <th><%= Education::Cohort.human_attribute_name('program') %></th> + <th><%= Education::Cohort.human_attribute_name('alumni') %></th> + <th></th> + </tr> + </thead> + <tbody> + <% cohorts.ordered.each do |cohort| %> + <tr> + <td> + <%= link_to [:admin, cohort] do %> + <%= cohort.academic_year %> + <%= cohort.name %> + <% end %> + </td> + <td><%= link_to cohort.program, [:admin, cohort.program] %></td> + <td><%= cohort.people.count %></td> + <td class="text-end"> + <div class="btn-group" role="group"> + <%= edit_link cohort %> + <%= destroy_link cohort %> + </div> + </td> + </tr> + <% end %> + </tbody> +</table> diff --git a/app/views/admin/education/programs/show/_cohorts.html.erb b/app/views/admin/education/programs/show/_cohorts.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..85fe5fad1f4f9f9189b09582278427d296c96d2b --- /dev/null +++ b/app/views/admin/education/programs/show/_cohorts.html.erb @@ -0,0 +1,28 @@ +<% if @program.cohorts.any? %> + <div class="card flex-fill w-100"> + <div class="card-header"> + <h5 class="card-title mb-0"><%= Education::Cohort.model_name.human(count: 2) %></h5> + </div> + <table class="<%= table_classes %>"> + <thead> + <tr> + <th><%= Education::Cohort.human_attribute_name('year') %></th> + <th><%= Education::Cohort.human_attribute_name('alumni') %></th> + </tr> + </thead> + <tbody> + <% @program.cohorts.ordered.each do |cohort| %> + <tr> + <td> + <%= link_to [:admin, cohort] do %> + <%= cohort.academic_year %> + <%= cohort.name %> + <% end %> + </td> + <td><%= cohort.people.count %></td> + </tr> + <% end %> + </tbody> + </table> + </div> +<% end %> diff --git a/db/migrate/20220324081520_add_text_to_university_organization.rb b/db/migrate/20220324081520_add_text_to_university_organization.rb new file mode 100644 index 0000000000000000000000000000000000000000..b53b56ab6c9f0e01963247bc7185c0a4f86046ff --- /dev/null +++ b/db/migrate/20220324081520_add_text_to_university_organization.rb @@ -0,0 +1,5 @@ +class AddTextToUniversityOrganization < ActiveRecord::Migration[6.1] + def change + add_column :university_organizations, :text, :text + end +end