forked from Antiarchitect/taurus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from AmurSU/plans
Поддержка учебных планов и автогенерации карт нагрузок
- Loading branch information
Showing
39 changed files
with
690 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ gem "pdfkit" | |
gem "pg" | ||
gem 'whenever' | ||
gem 'unicode' | ||
gem 'nokogiri' | ||
|
||
group :production do | ||
gem 'unicorn' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
class Supervisor::DepartmentsController < Supervisor::BaseController | ||
active_scaffold do |config| | ||
config.actions << :delete | ||
config.columns = [:name, :short_name] | ||
config.columns = [:name, :short_name, :gosinsp_code] | ||
config.nested.add_link('Специальности', [:specialities]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Supervisor::TeachingPlansController < Supervisor::BaseController | ||
|
||
include GosinspParser | ||
|
||
def new | ||
end | ||
|
||
def fill | ||
if params[:plan] and params[:plan].class == Tempfile | ||
@speciality, @results, @errors = parse_and_fill_teaching_plan(params[:plan].read) | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
module DeptHead::SpecialitiesHelper | ||
|
||
def list_row_class(record) | ||
'alien-speciality' if record.department_id != current_dept_head.department_id | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module Supervisor::TeachingPlansHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,24 @@ | ||
class Speciality < ActiveRecord::Base | ||
belongs_to :department | ||
has_many :groups | ||
has_many :teaching_plans | ||
|
||
validates_presence_of :department | ||
|
||
def to_label | ||
"#{name} (#{code})" | ||
end | ||
|
||
protected | ||
|
||
def authorized_for_update? | ||
return true unless current_user | ||
self.department_id == current_user.department_id | ||
end | ||
|
||
def authorized_for_delete? | ||
return true unless current_user | ||
self.department_id == current_user.department_id | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
class TeachingPlan < ActiveRecord::Base | ||
belongs_to :speciality | ||
belongs_to :discipline | ||
|
||
validates_presence_of :speciality_id, :discipline_id, :course, :semester | ||
validates_numericality_of :course, :semester | ||
validates_numericality_of :lections, :practics, :lab_works, :allow_nil => true | ||
validates_inclusion_of :semester, :in => [1, 2] | ||
|
||
def create_charge_cards_for(groups) | ||
created = [] | ||
if self.lections | ||
card = ChargeCard.for_autocreation(self.discipline_id, 1, groups) | ||
card.weeks_quantity = 18 | ||
card.hours_per_week = self.lections / 18 | ||
if card.save | ||
created << card | ||
card.groups = groups unless card.groups == groups | ||
end | ||
end | ||
if self.practics | ||
groups.each do |group| | ||
card = ChargeCard.for_autocreation(self.discipline_id, 2, group) | ||
card.weeks_quantity = 18 | ||
card.hours_per_week = self.practics / 18 | ||
if card.save | ||
created << card | ||
card.groups = [group] unless card.groups == [group] | ||
end | ||
end | ||
end | ||
if self.lab_works | ||
groups.each do |group| | ||
card = ChargeCard.for_autocreation(self.discipline_id, 3, group) | ||
card.weeks_quantity = 18 | ||
card.hours_per_week = self.lab_works / 18 | ||
if card.save | ||
created << card | ||
card.groups = [group] unless card.groups == [group] | ||
end | ||
end | ||
end | ||
return created | ||
end | ||
|
||
end |
Oops, something went wrong.