diff --git a/.gitignore b/.gitignore index e9f6c8b13..ba7890841 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ vendor/cache /tags /config/initializers/gitlab_config.rb 1234567 +public/javascripts/wechat/node_modules/ diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index 23014b0c1..c86a36d05 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -1,3 +1,5 @@ +#coding=utf-8 + module Mobile require_relative 'middleware/error_handler' require_relative 'apis/auth' @@ -29,16 +31,22 @@ module Mobile end def authenticate! - raise('Unauthorized. Invalid or expired token.') unless current_user + raise('Unauthorized. 用户认证失败.') unless current_user end def current_user + openid = params[:openid] + if openid + uw = UserWechat.find_by_openid(params[:openid]) + return uw.user if uw + end + token = ApiKey.where(access_token: params[:token]).first if token && !token.expired? - @current_user = User.find(token.user_id) - else - nil + return User.find(token.user_id) end + + nil end end diff --git a/app/api/mobile/apis/activities.rb b/app/api/mobile/apis/activities.rb index af17e0f44..49fdaff8f 100644 --- a/app/api/mobile/apis/activities.rb +++ b/app/api/mobile/apis/activities.rb @@ -12,7 +12,9 @@ module Mobile requires :openid, type: String end post do - user = UserWechat.find_by_openid(params[:openid]).user + authenticate! + + user = current_user shield_project_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id) shield_course_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id) diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index 591a4e288..3a36a9e37 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -97,7 +97,6 @@ module Mobile desc "加入课程" params do - requires :token, type: String requires :course_password, type: String end post ":id" do diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index fa084e349..22b7f1f52 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -106,7 +106,7 @@ class WordsController < ApplicationController elsif @journal_destroyed.jour_type == 'HomeworkCommon' @homework = HomeworkCommon.find @journal_destroyed.jour_id if params[:user_activity_id] - @user_activity_id = params[:user_activity_id] + @user_activity_id = params[:user_activity_id].to_i else @user_activity_id = -1 end diff --git a/app/views/courses/_new_member_list.html.erb b/app/views/courses/_new_member_list.html.erb index 747b37c03..720dfceea 100644 --- a/app/views/courses/_new_member_list.html.erb +++ b/app/views/courses/_new_member_list.html.erb @@ -24,8 +24,10 @@ - <% if User.current.allowed_to?(:as_teacher, @course) || User.current.admin? %> - <% if @course.course_groups.nil? || @group %> + <% unless @course.course_groups.empty? %> + <% if User.current.allowed_to?(:as_teacher, @course) || User.current.admin? %> + <% if @course.course_groups.nil? || @group %> +
+ +
+ <% else %> + <%= form_tag({:controller => 'courses', :action => 'teacher_assign_group', :id => @course.id,:user_id => member.user_id},:remote=>'true', :method => 'post', :id=>"join_group_form_#{member.id}", :class => 'query_form') do %> +
+ +
+ <%= select( :name,:group_id, course_group_option(@course), + { :include_blank => false,:selected => member.course_group_id}, + {:onchange=>"join_group_function('#join_group_form_#{member.id}');", :id =>"course_group_id", :name => "course_group_id",:class=>"w125 undis class-edit fl", :style => "margin-left: 5px;"}) %> + <% end %> + <% end %> + <% else %>
- <% else %> - <%= form_tag({:controller => 'courses', :action => 'teacher_assign_group', :id => @course.id,:user_id => member.user_id},:remote=>'true', :method => 'post', :id=>"join_group_form_#{member.id}", :class => 'query_form') do %> -
- -
- <%= select( :name,:group_id, course_group_option(@course), - { :include_blank => false,:selected => member.course_group_id}, - {:onchange=>"join_group_function('#join_group_form_#{member.id}');", :id =>"course_group_id", :name => "course_group_id",:class=>"w125 undis class-edit fl", :style => "margin-left: 5px;"}) %> - <% end %> <% end %> - <% else %> -
- -
<% end %> <%= link_to format("%0.2f",member.score.nil? ? 0 : member.score.to_s), { :action => 'show_member_score', :member_id => member.id, :remote => true}, - :class => 'st_list_score c_red' %> + :class => "st_list_score c_red #{@course.course_groups.empty? ? 'ml130' : ''}" %> <%= link_to member.act_score.nil? ? 0 : member.act_score.to_s, { :action => 'show_member_act_score', :member_id => member.id, diff --git a/app/views/organizations/_org_activities.html.erb b/app/views/organizations/_org_activities.html.erb index 8696cd426..cc1404eb5 100644 --- a/app/views/organizations/_org_activities.html.erb +++ b/app/views/organizations/_org_activities.html.erb @@ -57,7 +57,7 @@ <% when 'Message' %> <%= render :partial => 'users/project_message', :locals => {:activity => Message.find(act.org_act_id),:user_activity_id =>act.id, :is_course=>0, :is_board=>0} %> <% when 'Project'%> - <%= render :partial => 'users/project_create', :locals => {:activity => act,:user_activity_id =>act.id} %> + <%= render :partial => 'organizations/project_create', :locals => {:activity => act,:user_activity_id =>act.id} %> <% end %> <% end %> <% if act.container_type == 'Course' %> diff --git a/app/views/organizations/_show_custom_org_subfield.html.erb b/app/views/organizations/_show_custom_org_subfield.html.erb index 54416b6f0..aad0d0c84 100644 --- a/app/views/organizations/_show_custom_org_subfield.html.erb +++ b/app/views/organizations/_show_custom_org_subfield.html.erb @@ -1,14 +1,15 @@ -<% if @subfield_acts.blank? %> -

该模块暂时没有相关内容

-<% else %> -
-
-
-
- 您的位置:<%= link_to "首页", organization_path(@organization), :class => "sn-link-grey2" %> > - <%= @org_subfield.name %> -
-
+
+
+
+
+ 您的位置:<%= link_to "首页", organization_path(@organization), :class => "sn-link-grey2" %> > + <%= @org_subfield.name %> +
+
+ <% if @subfield_acts.blank? %> +

该模块暂时没有相关内容

+ <% else %> +

<%= @org_subfield.name %>

    @@ -34,12 +35,13 @@
- - - - + + + +
-
-
-<% end %> + <% end %> +
+
+ diff --git a/app/views/organizations/_subfield_list.html.erb b/app/views/organizations/_subfield_list.html.erb index aa1084304..d84f1299d 100644 --- a/app/views/organizations/_subfield_list.html.erb +++ b/app/views/organizations/_subfield_list.html.erb @@ -73,7 +73,7 @@
  • <%= org_subfield_type field %>