diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 6c62c642a..4bfd9a514 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -598,6 +598,66 @@ class AdminController < ApplicationController format.html end end + + # 获取申请的高校列表 + # status: 0 未审批; 1 已批阅; + def applied_schools + @name = params[:name] + @apply_status = ApplyAddSchools.where(:status => 0).order('created_at desc') + @apply_count = @apply_status.count + + @apply_pages = Paginator.new @apply_count, 30, params['page'] || 1 + @apply_status = paginateHelper @apply_status, 30 + + @page = (params['page'] || 1).to_i - 1 + respond_to do |format| + format.html + end + end + + def has_applied_schools + @name = params[:name] + @has_apply_status = ApplyAddSchools.where(:status => 1).order('created_at desc') + @has_apply_count = @has_apply_status.count + + @has_apply_pages = Paginator.new @has_apply_count, 30, params['page'] || 1 + @has_apply_status = paginateHelper @has_apply_status, 30 + + @page = (params['page'] || 1).to_i - 1 + respond_to do |format| + format.html + end + end + + # 批准未审批的高校 + # 消息发送,发送对象为申请人 + # status: 0表示未批准; status:1表示已批准; status: 2表示已拒绝 + def approve_applied_schools + applied_school = ApplyAddSchools.find params[:id] + applied_school.update_column('status', 1) unless applied_school.nil? + AppliedMessage.create(:user_id => applied_school.user_id, :status => true, :applied_id => applied_school.id, :applied_type => "ApplyAddSchools") + respond_to do |format| + format.html{ redirect_to unapplied_schools_url } + end + end + + # 更改申请的高校名称 + # REDO: 修改该字段 + # REDO: 同步修改使用了改名称的用户单位 + def edit_applied_schools + @applied_schools = ApplyAddSchools.find params[:id] + @applied_schools.update_column('name', params[:name]) + end + + # 删除申请的高校 + # REDO: destroy关联删除 + # REDO: 删除确认提示,是否删除 + # REDO: 给申请人发送消息 + def delete_applied_schools + @applied_schools = ApplyAddSchools.find params[:id] + @applied_schools.destroy + end + #移动端版本管理 def mobile_version @versions = PhoneAppVersion.reorder('created_at desc') diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index dab752afb..bdd99de61 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -180,7 +180,7 @@ class SchoolController < ApplicationController applyschool.city = params[:city] applyschool.address = params[:address] applyschool.remarks = params[:remarks] - + applyschool.user_id = User.current.id if applyschool.save data[:school_id] = school.id else diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 1b93bdeba..e2dd23552 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -381,6 +381,7 @@ class StudentWorkController < ApplicationController @is_evaluation = @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status == 2 && !@is_teacher #是不是匿评 @show_all = false + # 0表示没有分组的学生,-1表示所有分组的学生 if @group if @group == "0" none_group_students = @course.members.select{ |member| member.course_group_id == 0 } @@ -389,6 +390,13 @@ class StudentWorkController < ApplicationController else student_in_group = '(' + none_group_students.map{ |member| member.user_id }.join(',') + ')' end + elsif @group == "-1" + all_group_students = @course.members.select{ |member| member.course_group_id } + if all_group_students.empty? + student_in_group = '(0)' + else + student_in_group = '(' + all_group_students.map{ |member| member.user_id }.join(',') + ')' + end else course_group = CourseGroup.find_by_id(@group) group_students = course_group.users diff --git a/app/controllers/syllabuses_controller.rb b/app/controllers/syllabuses_controller.rb index 9c69f5259..e77b19511 100644 --- a/app/controllers/syllabuses_controller.rb +++ b/app/controllers/syllabuses_controller.rb @@ -88,7 +88,7 @@ class SyllabusesController < ApplicationController end def destroy - if @syllabus && @syllabus.courses.empty? + if @syllabus && @syllabus.courses.not_deleted.empty? @syllabus.destroy redirect_to user_courselist_user_path(User.current.id) end diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 96e0d7683..e5066d0fe 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -595,19 +595,19 @@ module CoursesHelper def get_acts_list_type type case type when "homework" - ">" + l(:label_homework_acts) + l(:label_homework_acts) when "news" - ">" + l(:label_news_acts) + l(:label_news_acts) when "attachment" - ">" + l(:label_attachment_acts) + l(:label_attachment_acts) when "message" - ">" + l(:label_message_acts) + l(:label_message_acts) when "journalsForMessage" - ">" + l(:label_journalsForMessage_acts) + l(:label_journalsForMessage_acts) when "poll" - ">" + l(:label_poll_acts) + l(:label_poll_acts) else - ">" + l(:label_all_cats) + l(:label_all_cats) end end diff --git a/app/models/applied_message.rb b/app/models/applied_message.rb new file mode 100644 index 000000000..1c6b3a8e7 --- /dev/null +++ b/app/models/applied_message.rb @@ -0,0 +1,21 @@ +class AppliedMessage < ActiveRecord::Base + # status: 0表示未批准; status:1表示已批准; status: 2表示已拒绝 + attr_accessible :applied_id, :applied_type, :status, :user_id, :viewed + belongs_to :applied ,:polymorphic => true + belongs_to :apply_add_schools + belongs_to :user + has_many :message_alls, :class_name => 'MessageAll', :as =>:message, :dependent => :destroy + + validates :user_id,presence: true + validates :applied_id,presence: true + validates :applied_type, presence: true + after_create :add_user_message + + # 因为要排序所以需要写入总表 + def add_user_message + if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil? + self.message_alls << MessageAll.new(:user_id => self.user_id, :viewed => false) + end + end + +end diff --git a/app/models/apply_add_schools.rb b/app/models/apply_add_schools.rb index efa56e808..b7301af13 100644 --- a/app/models/apply_add_schools.rb +++ b/app/models/apply_add_schools.rb @@ -1,4 +1,16 @@ class ApplyAddSchools < ActiveRecord::Base + # status:0 未审批 ; 1 已批阅 attr_accessible :address, :city, :name, :province, :remarks, :school_id, :status + has_many :applied_messages, :class_name =>'AppliedMessage', :as => :applied, :dependent => :destroy belongs_to :school + + after_create :send_massage + + #给系统所有管理发送消息 + def send_massage + users = User.where(:admin => 1) + users.each do |user| + self.applied_messages << AppliedMessage.new(:user_id => user.id, :viewed => false, :status => false) + end + end end diff --git a/app/views/admin/_tab_has_applied_applied.erb b/app/views/admin/_tab_has_applied_applied.erb new file mode 100644 index 000000000..6ae501b0c --- /dev/null +++ b/app/views/admin/_tab_has_applied_applied.erb @@ -0,0 +1,6 @@ +
+ +
\ No newline at end of file diff --git a/app/views/admin/applied_schools.html.erb b/app/views/admin/applied_schools.html.erb new file mode 100644 index 000000000..f14f8100a --- /dev/null +++ b/app/views/admin/applied_schools.html.erb @@ -0,0 +1,78 @@ +

+ <%=l(:label_applied_shcools)%> +

+ +<%= render 'tab_has_applied_applied' %> + +<%= form_tag({}, :method => :get) do %> +
+ + <%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '输入单位名称进行搜索' %> + <%= submit_tag l(:button_apply ), :class => "small", :name => nil %> + <%= link_to l(:button_clear), {:controller => 'admin', :action => 'applied_shcools'}, :class => 'icon icon-reload' %> +
+<% end %> +  + +
+ + + + + + + + + + + + + + <% @apply_status.each do |apply| %> + <% if apply.status == 0 %> + + + + + + + + + + <% end %> + <% end %> + +
+ 序号 + + 单位名称 + + 地区 + + 详细地址 + + 用户 + + 创建时间 + + 操作 +
+ <%= apply.id %> + + <%= apply.name %> + + <%= apply.province + apply.city %> + + <%= apply.address %> + + <%= apply.user_id %> + + <%= format_date(apply.created_at) %> + + <%= link_to( l(:label_approve), { :controller => 'admin', :action => 'approve_applied_schools', :id => apply.id }, :class => 'icon-del') %> + <%= link_to( l(:button_delete), { :controller => 'admin', :action => 'delete_applied_schools', :id => apply.id }, :class => 'icon-del') %> + <%= link_to( l(:button_change), { :controller => 'admin', :action => 'edit_applied_schools', :id => apply.id, :name => apply.name }, :class => 'icon-del') %> +
+
\ No newline at end of file diff --git a/app/views/admin/has_applied_schools.html.erb b/app/views/admin/has_applied_schools.html.erb new file mode 100644 index 000000000..a68deb0bc --- /dev/null +++ b/app/views/admin/has_applied_schools.html.erb @@ -0,0 +1,77 @@ +

+ <%=l(:label_applied_shcools)%> +

+ +<%= render 'tab_has_applied_applied' %> + +<%= form_tag({}, :method => :get) do %> +
+ + <%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '输入单位名称进行搜索' %> + <%= submit_tag l(:button_apply ), :class => "small", :name => nil %> + <%= link_to l(:button_clear), {:controller => 'admin', :action => 'applied_shcools'}, :class => 'icon icon-reload' %> +
+<% end %> +  + +
+ + + + + + + + + + + + + + <% @has_apply_status.each do |apply| %> + <% if apply.status == 1 %> + + + + + + + + + + <% end %> + <% end %> + +
+ 序号 + + 单位名称 + + 地区 + + 详细地址 + + 用户 + + 创建时间 + + 操作 +
+ <%= apply.id %> + + <%= apply.name %> + + <%= apply.province + apply.city %> + + <%= apply.address %> + + <%= apply.user_id %> + + <%= format_date(apply.created_at) %> + + <%= link_to( l(:button_delete), { :controller => 'admin', :action => 'delete_applied_schools', :id => apply.id }, :class => 'icon-del') %> + <%= link_to( l(:button_change), { :controller => 'admin', :action => 'edit_applied_schools', :id => apply.id, :name => apply.name }, :class => 'icon-del') %> +
+
\ No newline at end of file diff --git a/app/views/boards/_course_new.html.erb b/app/views/boards/_course_new.html.erb index 32cec24d5..90f0d9c7e 100644 --- a/app/views/boards/_course_new.html.erb +++ b/app/views/boards/_course_new.html.erb @@ -132,12 +132,12 @@