Skip to content
Snippets Groups Projects
Commit cca62b0f authored by Arnaud Levy's avatar Arnaud Levy
Browse files

wip

parent b880088c
No related branches found
No related tags found
No related merge requests found
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
<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>
<% content_for :title, Education::AcademicYear.model_name.human(count: 2) %>
<%= render 'admin/education/academic_years/list', academic_years: @academic_years %>
<% content_for :title, @academic_year %>
<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>
<% 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 %>
class AddTextToUniversityOrganization < ActiveRecord::Migration[6.1]
def change
add_column :university_organizations, :text, :text
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment