diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 1e4d569b4..83a6d1ab1 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -453,7 +453,7 @@ class AccountController < ApplicationController end def apply_trail - apply_action = ApplyAction.where(:user_id => User.current.id, :container_type => "TrialAuthorization").first + apply_action = ApplyAction.where(:user_id => User.current.id, :container_type => "TrialAuthorization", :status => 0).first if apply_action.blank? ApplyAction.create(:user_id => User.current.id, :status => 0, :container_type => "TrialAuthorization") end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index a230ea47e..a974abce7 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1658,7 +1658,7 @@ class CoursesController < ApplicationController def search_not_students if !params[:search].nil? members = @course.members.select{|m| m.roles.to_s.include?("Student")} - member_ids = "(" + members.map(&:user_id).join(',') + ")" + member_ids = members.empty? ? "(-1)" : "(" + members.map(&:user_id).join(',') + ")" condition = "%#{params[:search].strip}%".gsub(" ","") @users = User.joins(:user_extensions).where("users.id not in #{member_ids} and status = 1 and (LOWER(concat(lastname, firstname)) LIKE '#{condition}' or user_extensions.student_id LIKE '#{condition}')") end diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 5bd33bc16..3d8b0f07a 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -272,6 +272,7 @@ class ManagementsController < ApplicationController @autu_pages = Paginator.new @autu_count, @limit, params['page'] || 1 @offset ||= @autu_pages.offset @authorizations = paginateHelper @authorizations, @limit + end # 批量授权 @@ -295,6 +296,12 @@ class ManagementsController < ApplicationController apply_action.update_attributes(:status => (params[:type] == "1" ? 2 : 1), :reason => params[:reject_reason], :dealer_id => User.current.id) user_id = User.find_by_sql("select id from users where concat(lastname,firstname) like '%#{search}%'") @authorizations = ApplyAction.where(:container_type => "TrialAuthorization", :status => 0, :user_id => user_id).includes(:user) + @autu_count = @authorizations.count + @limit = 15 + @is_remote = true + @autu_pages = Paginator.new @autu_count, @limit, params['page'] || 1 + @offset ||= @autu_pages.offset + @authorizations = paginateHelper @authorizations, @limit respond_to do |format| format.js end diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 66cf79586..82056c0ed 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -192,6 +192,7 @@ class MyController < ApplicationController #changed_login = (@user.login != params[:login]) #changed_mail = (@user.mail != params[:user][:mail]) #@user.safe_attributes = params[:user] + @user.nickname = params[:nickname] @user.lastname = params[:lastname] @user.firstname = "" @user.pref.attributes = params[:pref] diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 14fcc3a5b..37a3de9a0 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -489,6 +489,7 @@ class ShixunsController < ApplicationController render_403 return end + Subject.where(:id => @shixun.stage_shixuns.map(&:subject_id)).destroy_all @shixun.destroy respond_to do |format| format.html{ redirect_to shixuns_managements_path } diff --git a/app/controllers/syllabuses_controller.rb b/app/controllers/syllabuses_controller.rb index 5e69af17d..fae83cdc1 100644 --- a/app/controllers/syllabuses_controller.rb +++ b/app/controllers/syllabuses_controller.rb @@ -69,6 +69,7 @@ class SyllabusesController < ApplicationController @syllabus.major_level = params[:major_level].to_i @syllabus.discipline_category_id = params[:discipline_category_id].to_i @syllabus.first_level_discipline_id = params[:first_level_discipline_id].to_i + @syllabus.major_id = params[:major_id].to_i @syllabus.syllabus_type = params[:syllabus_type].to_i @syllabus.description = Message.where("id = 19412").first.nil? ? '' : Message.where("id = 19412").first.content if @syllabus && @syllabus.save @@ -116,6 +117,7 @@ class SyllabusesController < ApplicationController @syllabus.major_level = params[:major_level].to_i @syllabus.discipline_category_id = params[:discipline_category_id].to_i @syllabus.first_level_discipline_id = params[:first_level_discipline_id].to_i + @syllabus.major_id = params[:major_id].to_i @syllabus.syllabus_type = params[:syllabus_type].to_i if @syllabus.save if title != params[:title].to_s.strip @@ -450,6 +452,23 @@ class SyllabusesController < ApplicationController render :json =>data end + def get_major + data = {result:0,options:[]} + if params[:first_level_discipline_id] + if Major.where(:first_level_discipline_id => params[:first_level_discipline_id].to_i).count > 0 + data[:result] = 1 + Major.where(:first_level_discipline_id => params[:first_level_discipline_id].to_i).each do |dis| + option = [] + option << dis.name.to_s + option << dis.id + data[:options] << option + end + end + end + + render :json =>data + end + private def find_syllabus @syllabus = Syllabus.find params[:id] diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 8762639c9..10064d77b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1235,7 +1235,7 @@ class UsersController < ApplicationController #导入作业,确定按钮 def user_select_homework params[:checkMenu].each do |homework_bank| - homework = HomeworkBank.find_by_id params[:checkMenu] + homework = HomeworkBank.find_by_id homework_bank @select_course = Course.find params[:select_course] if homework && @select_course quote_homework_bank homework, @select_course diff --git a/app/helpers/syllabuses_helper.rb b/app/helpers/syllabuses_helper.rb index 3cf56b047..bfb5b199b 100644 --- a/app/helpers/syllabuses_helper.rb +++ b/app/helpers/syllabuses_helper.rb @@ -102,6 +102,21 @@ module SyllabusesHelper content end + def syllabus_major_option fir_dis = 213 + content = [] + option0 = [] + option0 << "选择课程所属专业" + option0 << 0 + content << option0 + Major.where(:first_level_discipline_id => fir_dis).each do |major| + option = [] + option << major.name.to_s + option << major.id + content << option + end + content + end + def syllabus_type_option content = [] option0 = [] diff --git a/app/models/game.rb b/app/models/game.rb index 93888fc2e..44129ac33 100644 --- a/app/models/game.rb +++ b/app/models/game.rb @@ -6,7 +6,7 @@ class Game < ActiveRecord::Base belongs_to :user belongs_to :challenge has_many :outputs, :dependent => :destroy - has_many :test_sets + has_many :test_sets, :dependent => :destroy has_many :challenge_samples has_one :game_code, :dependent => :destroy diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 4dba556be..e218ebb39 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -17,6 +17,7 @@ class Shixun < ActiveRecord::Base has_many :homework_commons_shixunses has_many :challenges, :dependent => :destroy, :order => "challenges.id ASC" has_many :myshixuns, :dependent => :destroy + has_many :stage_shixuns, :dependent => :destroy belongs_to :major belongs_to :major_course has_many :shixun_major_courses, :dependent => :destroy diff --git a/app/models/syllabus.rb b/app/models/syllabus.rb index 42af92576..f1d9cb34e 100644 --- a/app/models/syllabus.rb +++ b/app/models/syllabus.rb @@ -29,7 +29,8 @@ class Syllabus < ActiveRecord::Base has_one :praise_tread_cache, as: :object, dependent: :destroy belongs_to :discipline_category belongs_to :first_level_discipline - attr_accessible :description, :user_id, :title, :eng_name, :syllabus_type, :credit, :hours, :theory_hours, :practice_hours, :applicable_major, :pre_course, :major_level, :discipline_category_id, :first_level_discipline_id + belongs_to :major + attr_accessible :description, :user_id, :title, :eng_name, :syllabus_type, :credit, :hours, :theory_hours, :practice_hours, :applicable_major, :pre_course, :major_level, :discipline_category_id, :first_level_discipline_id, :major_id safe_attributes 'title','user', 'description', 'eng_name', 'syllabus_type', 'credit', 'hours', 'theory_hours', 'practice_hours', 'credit', 'applicable_major', 'pre_course', 'major_level', 'discipline_category_id', "first_level_discipline_id" validates :title, :user_id, presence: true @@ -91,6 +92,10 @@ class Syllabus < ActiveRecord::Base self.first_level_discipline ? self.first_level_discipline.name : '' end + def syllabus_major + self.major ? self.major.name : '' + end + ###添加回复 def self.add_syllabus_jour(user, notes, id, root_id, options = {}) syllabus = Syllabus.find(id) diff --git a/app/models/user.rb b/app/models/user.rb index 1baf02a60..1d43c477b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -208,6 +208,7 @@ class User < Principal has_one :user_wechat has_one :sso + has_many :apply_user_authentication # add by zjc has_one :level, :class_name => 'UserLevels', :dependent => :destroy @@ -647,10 +648,6 @@ class User < Principal end end - def nickname(formatter = nil) - login.nil? || (login && login.empty?) ? "AnonymousUser" : login - end - def name(formatter = nil) login end @@ -1253,7 +1250,8 @@ class User < Principal 'custom_fields', 'identity_url', 'phone', - 'authentication' + 'authentication', + 'nickname' safe_attributes 'status', 'auth_source_id', diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 4105051ec..5faad5cd7 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -110,7 +110,7 @@ class CoursesService #双重身份 学生列表中不显示 # unless (params[:role] == '2' && role_ids.length >= 2) - users << {:id => m.user.id, :img_url => img_url, :nickname => m.user.login, :gender => gender, + users << {:id => m.user.id, :img_url => img_url, :nickname => m.user.nickname, :gender => gender, :work_unit => work_unit, :mail => m.user.mail, :location => location, role_name: m.roles.first.name, name: m.user.show_name, @@ -138,7 +138,7 @@ class CoursesService work_unit = get_user_work_unit user location = get_user_location user roles_ids = m.content.split(",") - reviewers << {:id => user.id, :img_url => img_url, :nickname => user.login, :gender => gender, + reviewers << {:id => user.id, :img_url => img_url, :nickname => user.nickname, :gender => gender, :work_unit => work_unit, :mail => user.mail, :location => location, role_name: "", name: user.show_name, @@ -168,7 +168,7 @@ class CoursesService work_unit = get_user_work_unit user location = get_user_location user roles_ids = messages.content.split(",") - info = {:id => user.id, :img_url => img_url, :nickname => user.login, :gender => gender, + info = {:id => user.id, :img_url => img_url, :nickname => user.nickname, :gender => gender, :work_unit => work_unit, :mail => user.mail, :location => location, role_name: "", name: user.show_name, diff --git a/app/services/projects_service.rb b/app/services/projects_service.rb index f3679aa22..97f67e114 100644 --- a/app/services/projects_service.rb +++ b/app/services/projects_service.rb @@ -215,7 +215,7 @@ class ProjectsService gender = user.user_extensions.gender.nil? ? 0 : user.user_extensions.gender work_unit = get_user_work_unit user location = get_user_location user - review_members << {:id => user.id, :img_url => img_url, :nickname => user.login, :gender => gender, + review_members << {:id => user.id, :img_url => img_url, :nickname => user.nickname, :gender => gender, :work_unit => work_unit, :mail => user.mail, :location => location, role_name: "", name: user.show_name, @@ -244,7 +244,7 @@ class ProjectsService gender = user.user_extensions.gender.nil? ? 0 : user.user_extensions.gender work_unit = get_user_work_unit user location = get_user_location user - info = {:id => user.id, :img_url => img_url, :nickname => user.login, :gender => gender, + info = {:id => user.id, :img_url => img_url, :nickname => user.nickname, :gender => gender, :work_unit => work_unit, :mail => user.mail, :location => location, role_name: "", name: user.show_name, diff --git a/app/services/users_service.rb b/app/services/users_service.rb index 1a7601ec9..85f026537 100644 --- a/app/services/users_service.rb +++ b/app/services/users_service.rb @@ -99,7 +99,7 @@ class UsersService gender = @user.user_extensions.gender.nil? ? 0 : @user.user_extensions.gender work_unit = get_user_work_unit @user location = get_user_location @user - {:id => @user.id, :img_url => img_url,:realname => @user.realname, :nickname => @user.login, :gender => gender, :work_unit => work_unit, :mail => @user.mail, :location => location, :brief_introduction => @user.user_extensions.brief_introduction} + {:id => @user.id, :img_url => img_url,:realname => @user.realname, :nickname => @user.nickname, :gender => gender, :work_unit => work_unit, :mail => @user.mail, :location => location, :brief_introduction => @user.user_extensions.brief_introduction} end #忘记密码 diff --git a/app/views/account/apply_trail.js.erb b/app/views/account/apply_trail.js.erb index 0b921b7c3..c7b789ae5 100644 --- a/app/views/account/apply_trail.js.erb +++ b/app/views/account/apply_trail.js.erb @@ -1 +1 @@ -$("body").append('<%= j( render :partial => 'welcome/one_btn_mask_pop', :locals => {:btn => "确定", :tip1 => "申请成功,我们将在一个工作日内完成审核", :url => "javascript:void(0);"}) %>'); \ No newline at end of file +$("body").append('<%= j( render :partial => 'welcome/one_btn_mask_pop', :locals => {:btn => "确定", :tip1 => "申请成功,我们将在一个工作日内完成审核", :url => "#{my_account_path()}"}) %>'); \ No newline at end of file diff --git a/app/views/account/avatar.html.erb b/app/views/account/avatar.html.erb index c4cc39be3..266d6bbf1 100644 --- a/app/views/account/avatar.html.erb +++ b/app/views/account/avatar.html.erb @@ -34,14 +34,19 @@
+ <%= image_tag(url_to_avatar(@user), :width => 240, :height => 240, :alt => "头像") %>
尺寸:240*240像素
-
+
+ <%= image_tag(url_to_avatar(@user), :width => 100, :height => 100, :alt => "头像") %> +
尺寸:100*100像素 -
+
+ <%= image_tag(url_to_avatar(@user), :width => 40, :height => 40, :alt => "头像") %> +
尺寸:40*40像素
diff --git a/app/views/courses/_courseList.html.erb b/app/views/courses/_courseList.html.erb index c0a5e22f4..aa3ce1a50 100644 --- a/app/views/courses/_courseList.html.erb +++ b/app/views/courses/_courseList.html.erb @@ -1,7 +1,13 @@ <% if @syllabuses.count > 0 %> <% @syllabuses.each do | sy | %> - <% sy_author = User.find(sy.tea_id) %> -
+
+ <% unless (sy.is_public == 1 || User.current.admin? || User.current.member_of_course?(sy)) %> +
+
+
私有课堂,非成员不能访问
+
+ <% end %> + <% sy_author = User.find(sy.tea_id) %>
<% else %> -
+

没有数据可以显示!

-<% end %> \ No newline at end of file +<% end %> + + \ No newline at end of file diff --git a/app/views/courses/search_not_students.js.erb b/app/views/courses/search_not_students.js.erb index e7c3fb01f..b6c3cc65a 100644 --- a/app/views/courses/search_not_students.js.erb +++ b/app/views/courses/search_not_students.js.erb @@ -1,6 +1,7 @@ <% if params[:is_observe] %> $("#search_not_students_list").html("<%= j(render :partial => 'courses/settings/search_not_students_list') %>"); <% else %> +laststSearchCondition = ''; var htmlvalue = "<%= j(render :partial => 'courses/settings/add_students') %>"; pop_box_new(htmlvalue, 440, 490); <% end %> \ No newline at end of file diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index 4357be0b4..4076c14e6 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -1,7 +1,7 @@ <%= javascript_include_tag 'jquery.datetimepicker.js' %>
-
+
设置 <%= link_to '返回', course_path(@course), :class => 'fr mr15 link-color-grey' %>
@@ -24,7 +24,7 @@
-
+
<%= labelled_form_for @course, :html => {:remote => true} do |f| %>