Permalink
Browse files

Allow dept_heads to import GosInsp teaching plans

  • Loading branch information...
1 parent 799564a commit dcb04a4276a66f11edacb3bcd4c8ac504390cc54 @Envek committed Mar 6, 2012
@@ -1,9 +1,12 @@
class DeptHead::SpecialitiesController < DeptHead::BaseController
+ include GosinspParser
+
active_scaffold do |config|
config.actions << :delete
config.columns = [:code, :name]
config.nested.add_link('Группы', [:groups])
config.action_links.add :teaching_plan, :label => "Учебный план", :type => :member, :page => true
+ config.action_links.add :teaching_plan_import, :label => "Импорт учебного плана", :type => :collection, :page => true
end
def teaching_plan
@@ -15,6 +18,15 @@ def teaching_plan
render "application/specialities/teaching_plans/show"
end
+ def teaching_plan_import
+ if params[:plan] and params[:plan].class == Tempfile
+ @specialities = current_dept_head.department.specialities
+ @speciality, @results, @errors = parse_and_fill_teaching_plan(params[:plan].read, @specialities)
+ render "supervisor/teaching_plans/fill"
+ return
+ end
+ end
+
protected
def before_create_save(record)
@@ -0,0 +1,7 @@
+%h1 Импорт учебных планов
+%p Пожалуйста, обратите внимание, что система принимает к разбору <strong>только</strong> файлы учебных планов <strong><em>универсального</em> пакета GosInsp</strong>.
+%p Это файлы с расширениями <code>PLI.XML</code> и <code>PLM.XML</code>.
+%fieldset
+ - form_tag("/dept_head/specialities/teaching_plan_import", :method => :post, :multipart => true) do
+ = file_field_tag :plan, :accept => "application/xml"
+ = submit_tag "Импортировать"
View
@@ -46,7 +46,7 @@
d.resources :disciplines, :active_scaffold => true, :collection => {:browse => :get}, :member => {:select => :post}
d.resources :groups, :active_scaffold => true, :collection => {:browse => :get}, :member => {:select => :post, :teaching_plan => :get}
d.resources :lecturers, :active_scaffold => true, :collection => {:browse => :get}, :member => {:select => :post}
- d.resources :specialities, :active_scaffold => true, :member => {:teaching_plan => :get}
+ d.resources :specialities, :active_scaffold => true, :member => {:teaching_plan => :get}, :collection => {:teaching_plan_import => [:get, :post]}
d.root :controller => 'teaching_places'
end

0 comments on commit dcb04a4

Please sign in to comment.