Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

создание группы с неделями обучения

  • Loading branch information...
commit 66006bab4dbb1038c6d50a0a0539382edffe404f 1 parent b03f8e0
@jenkek jenkek authored
View
8 app/assets/stylesheets/_form.sass
@@ -79,6 +79,14 @@
cursor: pointer
margin-left: 5px
+ &.bordered
+ +inline-block
+ border: 1px solid #ccc
+ padding: 5px 10px
+ margin-right: 10px
+ legend
+ font-size: 14px
+
.actions
+clearfix
margin-top: 10px
View
14 app/controllers/manage/dicts/faculty_group/courses_controller.rb
@@ -0,0 +1,14 @@
+#encoding: utf-8
+class Manage::Dicts::FacultyGroup::CoursesController < Manage::ApplicationController
+
+ before_filter :find_faculty, :only => :index
+
+ def index
+ @courses = @faculty.courses.all
+ end
+
+ private
+ def find_faculty
+ @faculty = @current_semester.faculties.find(params[:faculty_id])
+ end
+end
View
6 app/controllers/manage/dicts/faculty_group/faculties_controller.rb
@@ -0,0 +1,6 @@
+#encoding: utf-8
+class Manage::Dicts::FacultyGroup::FacultiesController < Manage::ApplicationController
+ def index
+ @faculties = @current_semester.faculties.all
+ end
+end
View
49 app/controllers/manage/dicts/faculty_group/groups_controller.rb
@@ -0,0 +1,49 @@
+#encoding: utf-8
+class Manage::Dicts::FacultyGroup::GroupsController < Manage::ApplicationController
+
+ before_filter :find_faculty_and_course
+
+ def index
+ @groups = @course.groups.all
+ end
+
+ def new
+ @group = Group.new(:course => @course)
+ end
+
+ def create
+ @group = Group.new(params[:group])
+ if @group.save
+ redirect_to manage_dicts_faculty_group_faculty_course_groups_path(params[:faculty_id], params[:course_id]), :notice => "Группа создана"
+ else
+ render :action => :new
+ end
+ end
+
+ def edit
+ @group = Group.find(params[:id])
+ end
+
+ def update
+ @group = Group.find(params[:id])
+ if @group.update_attributes(params[:group])
+ redirect_to manage_dicts_faculty_group_faculty_course_groups_path(params[:faculty_id], params[:course_id]), :notice => "Информация о группе изменена"
+ else
+ render :action => :edit
+ end
+ end
+
+ def destroy
+ @group = Group.find(params[:id])
+ @group.destroy
+ redirect_to manage_dicts_faculty_group_faculty_course_groups_path(params[:faculty_id], params[:course_id]), :notice => 'Группа "#{@group}" удалена'
+ end
+
+ private
+
+ def find_faculty_and_course
+ @faculty = Faculty.find(params[:faculty_id])
+ @course = Course.find(params[:course_id])
+ end
+
+end
View
6 app/models/group.rb
@@ -15,7 +15,9 @@ class Group < ActiveRecord::Base
has_many :trainings, :through => :educations
has_many :periods, :dependent => :destroy
has_one :before_breaking, :class_name => "Period", :conditions => {:kind => "before_breaking"}
+ accepts_nested_attributes_for :before_breaking
has_one :after_breaking, :class_name => "Period", :conditions => {:kind => "after_breaking"}
+ accepts_nested_attributes_for :after_breaking
has_many :disciplines, :through => :educations, :order => :name
validates_uniqueness_of :number, :scope => :course_id
@@ -73,10 +75,6 @@ def weeks_for_period(period)
semester.academic_year.weeks.where("number between ? and ?", period.starts_at_week.number, period.completes_at_week.number)
end
- def weeks
- semester.academic_year.weeks.where("number between ? and ?", self.before_breaking.starts_at_week.number, self.after_breaking.completes_at_week.number)
- end
-
def period_for(week)
week.number > self.before_breaking.completes_at_week.number ? :after_breaking : :before_breaking
end
View
4 app/models/week.rb
@@ -15,6 +15,10 @@ def to_s
self.number
end
+ def full_name
+ "#{number} с #{I18n.l(starts_at.beginning_of_week, :format => '%d %B')} по #{I18n.l(completes_at, :format => '%d %B')}"
+ end
+
private
def set_parity
View
1  app/views/manage/dicts/academic_years/_form.html.erb
@@ -16,4 +16,3 @@
</li>
<%= yield :destroy_button %>
<% end %>
-
View
10 app/views/manage/dicts/faculty_group/courses/index.html.erb
@@ -0,0 +1,10 @@
+<ul class="compressed_list">
+ <% @courses.each do |course| %>
+ <li>
+ <h2><%= link_to course, manage_dicts_faculty_group_faculty_course_groups_path(@faculty, course) %></h2>
+ <p class="groups">
+ <%= t "faculty.groups", :count => course.groups.count %>
+ </p>
+ </li>
+ <% end %>
+</ul>
View
14 app/views/manage/dicts/faculty_group/faculties/index.html.erb
@@ -0,0 +1,14 @@
+<ul class="faculties">
+ <li class="line_wrapper">
+ <% @faculties.each_slice(5) do |fc| %>
+ <ul class="line">
+ <% fc.each do |faculty| %>
+ <li class="faculty_<%= faculty.eng_abbr %>">
+ <%= link_to(content_tag(:span, faculty.abbr, :class => "link"), manage_dicts_faculty_group_faculty_courses_path(faculty)) %>
+ <h2><%= link_to content_tag(:abbr, faculty.abbr, :title => faculty.name), manage_dicts_faculty_group_faculty_courses_path(faculty) %></h2>
+ </li>
+ <% end %>
+ </ul>
+ <% end %>
+ </li>
+</ul>
View
29 app/views/manage/dicts/faculty_group/groups/_form.html.erb
@@ -0,0 +1,29 @@
+<%= form.semantic_errors %>
+<%= form.inputs do %>
+ <%= form.input :course_id, :as => :hidden %>
+ <%= form.input :number, :input_html => { :autofocus => true } %>
+ <%= form.input :free_count %>
+ <%= form.input :paying_count %>
+<% end %>
+<% @group.build_before_breaking unless @group.before_breaking %>
+<%= form.semantic_fields_for :before_breaking do |breaking_form| %>
+ <%= form.inputs :name => "Обучение до ломки", :class => "inputs bordered" do %>
+ <%= breaking_form.input :starts_at_week, :collection => @current_semester.academic_year.weeks, :label => "Первая неделя" %>
+ <%= breaking_form.input :completes_at_week, :collection => @current_semester.academic_year.weeks, :label => "Последняя неделя" %>
+ <% end %>
+<% end %>
+<% @group.build_after_breaking unless @group.after_breaking %>
+<%= form.semantic_fields_for :after_breaking do |breaking_form| %>
+ <%= form.inputs :name => "Обучение после ломки", :class => "inputs bordered" do %>
+ <%= breaking_form.input :starts_at_week, :collection => @current_semester.academic_year.weeks, :label => "Первая неделя" %>
+ <%= breaking_form.input :completes_at_week, :collection => @current_semester.academic_year.weeks, :label => "Последняя неделя" %>
+ <% end %>
+<% end %>
+<%= form.actions do %>
+ <%= form.action :submit, :label => "Сохранить", :button_html => { :class => "button" } %>
+ <!-- TODO buttons cancel -->
+ <li class="cancel">
+ <%= link_to t(:cancel), manage_dicts_faculty_group_faculty_course_groups_path(@faculty, @course), :class => "button" %>
+ </li>
+ <%= yield :destroy_button %>
+<% end %>
View
9 app/views/manage/dicts/faculty_group/groups/edit.html.erb
@@ -0,0 +1,9 @@
+<% content_for :destroy_button do %>
+ <li class="destroy floatr">
+ <%= link_to t(:destroy), manage_dicts_faculty_group_faculty_course_group_path(@faculty, @course, @group), :method => :delete, :data => { :confirm => t(:confirm) }, :class => 'button light danger icon trash' %>
+ </li>
+<% end %>
+
+<%= semantic_form_for @group, :url => manage_dicts_faculty_group_faculty_course_group_path(@faculty, @course) do |form| %>
+ <%= render :partial => "form", :locals => { :form => form } %>
+<% end %>
View
16 app/views/manage/dicts/faculty_group/groups/index.html.erb
@@ -0,0 +1,16 @@
+<p><%= link_to t('new'), new_manage_dicts_faculty_group_faculty_course_group_path(@faculty, @course), :class => "button" %></p>
+
+<% unless @groups.blank? %>
+ <ul class="compressed_list">
+ <% @groups.each do |group| %>
+ <li>
+ <h2>
+ <%= group.number %>
+ <%= link_to image_tag("icon_edit.png", :width => "16", :height => "16", :alt => t(:edit)), edit_manage_dicts_faculty_group_faculty_course_group_path(@faculty, @course, group) %>
+ </h2>
+ </li>
+ <% end %>
+ </ul>
+<% else %>
+ <p>Нет групп</p>
+<% end %>
View
3  app/views/manage/dicts/faculty_group/groups/new.html.erb
@@ -0,0 +1,3 @@
+<%= semantic_form_for @group, :url => manage_dicts_faculty_group_faculty_course_groups_path(@faculty, @course) do |form| %>
+ <%= render :partial => "form", :locals => { :form => form } %>
+<% end %>
View
2  app/views/manage/dicts/welcomes/show.html.erb
@@ -2,4 +2,4 @@
<h2><%= link_to 'Дисциплины', manage_dicts_disciplines_path %></h2>
<h2><%= link_to 'Аудиторный фонд', manage_dicts_buildings_path %></h2>
<h2><%= link_to 'Учебные годы', manage_dicts_academic_years_path %></h2>
-
+<h2><%= link_to 'Управление группами', manage_dicts_faculty_group_faculties_path %></h2>
View
11 config/locales/ru.yml
@@ -45,6 +45,7 @@ ru:
faculty:
groups:
+ zero: "нет групп"
one: "%{count} группа"
few: "%{count} группы"
many: "%{count} групп"
@@ -125,6 +126,16 @@ ru:
"manage/dicts/disciplines":
index: Дисциплины
edit: Редактирование дисциплины
+ "manage/dicts/faculty_group/faculties":
+ index: Факультеты
+ "manage/dicts/faculty_group/courses":
+ index: Курсы
+ "manage/dicts/faculty_group/groups":
+ index: Группы
+ new: &new Добаление группы
+ create: *new
+ edit: &edit Редактирование группы
+ update: *edit
"manage/timetables/auditoriums":
show: Расписание занятий в аудитории
"manage/timetables/faculties":
View
32 config/navigation.rb
@@ -6,7 +6,7 @@
primary.item :timetables, "Расписание", manage_timetables_faculties_path,
:highlights_on => /^\/manage$|\/timetables/ do | timetables |
- timetables.item :faculty, @faculty.abbr,
+ timetables.item :faculty, content_tag(:abbr, @faculty.abbr, :title => @faculty.name),
manage_timetables_faculty_courses_path(@faculty), :highlights_on => /\/timetables/ do |faculty|
faculty.item :reports, "Печать расписания",
@@ -36,7 +36,7 @@
auditorium.item :auditorium, @auditorium.label, manage_timetables_auditorium_path(@auditorium) if @auditorium && !@auditorium.new_record?
end
- timetables.item :building, @building.abbr, manage_timetables_building_path(@building) if @building
+ timetables.item :building, content_tag(:abbr, @building.abbr, :title => @building.name), manage_timetables_building_path(@building) if @building
end
primary.item :plans, "РПЗ", manage_plans_faculties_path do | faculty |
@@ -71,7 +71,7 @@
dicts.item :faculties, "Факультеты и кафедры", manage_dicts_faculties_path,
:highlights_on => /\/dicts\/(chairs|faculties)/ do | dict |
dict.item :edit_chair, @chair.abbr, edit_manage_dicts_chair_path(@chair) if @chair && !@chair.new_record?
- dict.item :edit_faculty, @faculty.abbr, edit_manage_dicts_faculty_path(@faculty) if @faculty && !@faculty.new_record?
+ dict.item :edit_faculty, content_tag(:abbr, @faculty.abbr, :title => @faculty.name), edit_manage_dicts_faculty_path(@faculty) if @faculty && !@faculty.new_record?
end
dicts.item :disciplines, "Дисциплины", manage_dicts_disciplines_path,
@@ -85,15 +85,33 @@
building.item :building, @building.name, manage_dicts_building_auditoriums_path(@building),
:highlights_on => /\/dicts\/buildings/ do | auditorium |
auditorium.item :new_auditorium, "Добавление аудитории", new_manage_dicts_building_auditorium_path(@building), :highlights_on => /\/dicts\/buildings\/\d+\/auditoriums\/new/
- auditorium.item :edit_auditorium, @auditorium.number, edit_manage_dicts_building_auditorium_path(@building, @auditorium), :highlights_on => /\/dicts\/buildings/ if @auditorium && !@auditorium.new_record?
+ auditorium.item :edit_auditorium, @auditorium.number, edit_manage_dicts_building_auditorium_path(@building, @auditorium), :highlights_on => /\/dicts\/buildings/ if @auditorium && !@auditorium.new_record?
end if @building
end
dicts.item :academic_yearss, "Учебные годы", manage_dicts_academic_years_path,
- :highlights_on => /\/dicts\/academic_years/ do | academic_year |
+ :highlights_on => /\/dicts\/academic_years/ do | academic_year |
academic_year.item :new_academic_year, "Создание учебного года", new_manage_dicts_academic_year_path
- academic_year.item :edit_academic_year, @academic_year.name, edit_manage_dicts_academic_year_path(@academic_year) if @academic_year && !@academic_year.new_record?
- end
+ academic_year.item :edit_academic_year, @academic_year.name, edit_manage_dicts_academic_year_path(@academic_year) if @academic_year && !@academic_year.new_record?
+ end
+
+ dicts.item :faculty_group, "Управление группами",
+ manage_dicts_faculty_group_faculties_path,
+ :highlights_on => /\/faculty_group\/faculties/ do |faculty_group|
+ faculty_group.item :faculty, content_tag(:abbr, @faculty.abbr, :title => @faculty.name),
+ manage_dicts_faculty_group_faculty_courses_path(@faculty),
+ :highlights_on => /\/faculty_group\/faculties\/\d+\/courses/ do |faculty|
+ faculty.item :cource, @course,
+ manage_dicts_faculty_group_faculty_course_groups_path(@faculty, @course),
+ :highlights_on => /\/faculty_group\/faculties\/\d+\/courses\/\d+/ do |course|
+ course.item :new_group, "Добавление группы",
+ new_manage_dicts_faculty_group_faculty_course_group_path(@faculty, @course)
+ course.item :edit_group, @group,
+ edit_manage_dicts_faculty_group_faculty_course_group_path(@faculty, @course, @group) if @group && !@group.new_record?
+ end if @course
+ end if @faculty
+ end
+
end
primary.dom_class = 'breadcrumbs'
end
View
7 config/routes.rb
@@ -42,6 +42,13 @@ def self.default_period
resources :auditoriums
end
resources :academic_years
+ namespace :faculty_group do
+ resources :faculties, :only => :index do
+ resources :courses, :only => :index do
+ resources :groups
+ end
+ end
+ end
end
namespace :teachers do
Please sign in to comment.
Something went wrong with that request. Please try again.