Merge branch 'szzh' into develop

This commit is contained in:
sw 2015-03-09 17:38:13 +08:00
commit 8dcbc6a851
17 changed files with 174 additions and 80 deletions

View File

@ -1,16 +1,24 @@
module Mobile module Mobile
module Entities module Entities
class CourseDynamic < Grape::Entity class CourseDynamic < Grape::Entity
include Redmine::I18n
def self.course_dynamic_expose(field) def self.course_dynamic_expose(field)
expose field do |c,opt| expose field do |c,opt|
if field == :update_time
(format_time(c[field]) if (c.is_a?(Hash) && c.key?(field)))
else
c[field] if (c.is_a?(Hash) && c.key?(field)) c[field] if (c.is_a?(Hash) && c.key?(field))
end end
end
end end
course_dynamic_expose :type course_dynamic_expose :type
course_dynamic_expose :count course_dynamic_expose :count
course_dynamic_expose :course_name course_dynamic_expose :course_name
course_dynamic_expose :course_id course_dynamic_expose :course_id
course_dynamic_expose :course_img_url course_dynamic_expose :course_img_url
course_dynamic_expose :message
course_dynamic_expose :update_time
end end
end end
end end

View File

@ -177,6 +177,22 @@ class ApplicationController < ActionController::Base
end end
end end
def logged_user_by_apptoken
#从手机端传来apptoken则将当前登陆用户变为对应的用户
if params[:apptoken]
token = ApiKey.where(access_token: params[:apptoken]).first
if token && !token.expired?
@current_user = User.find(token.user_id)
end
unless @current_user.nil?
self.logged_user = @current_user
if @current_user
@current_user.update_column(:last_login_on, Time.now)
end
end
end
end
# Logs out current user # Logs out current user
def logout_user def logout_user
if User.current.logged? if User.current.logged?

View File

@ -17,6 +17,7 @@ class CoursesController < ApplicationController
menu_item l(:label_sort_by_influence), :only => :index menu_item l(:label_sort_by_influence), :only => :index
before_filter :can_show_course, :except => [] before_filter :can_show_course, :except => []
before_filter :logged_user_by_apptoken,:only => [:show,:new_homework,:feedback]
before_filter :find_course, :except => [ :index, :search,:list, :new,:join,:unjoin, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches,:join_private_courses] before_filter :find_course, :except => [ :index, :search,:list, :new,:join,:unjoin, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches,:join_private_courses]
before_filter :authorize_course, :only => [:show, :settings, :edit, :update, :modules, :close, :reopen, :view_homework_attaches, :course] before_filter :authorize_course, :only => [:show, :settings, :edit, :update, :modules, :close, :reopen, :view_homework_attaches, :course]
before_filter :authorize_course_global, :only => [:view_homework_attaches, :new,:create] before_filter :authorize_course_global, :only => [:view_homework_attaches, :new,:create]

View File

@ -6,7 +6,7 @@ class HomeworkAttachController < ApplicationController
############################### ###############################
before_filter :can_show_course,except: [] before_filter :can_show_course,except: []
#判断当前角色权限时需先找到当前操作的project #判断当前角色权限时需先找到当前操作的project
before_filter :find_course_by_bid_id, :only => [:new] before_filter :logged_user_by_apptoken,:find_course_by_bid_id, :only => [:new]
before_filter :find_bid_and_course,:only => [:get_not_batch_homework,:get_batch_homeworks,:get_homeworks,:get_homework_jours, :get_student_batch_homework, :get_my_homework] before_filter :find_bid_and_course,:only => [:get_not_batch_homework,:get_batch_homeworks,:get_homeworks,:get_homework_jours, :get_student_batch_homework, :get_my_homework]
before_filter :find_course_by_hoemwork_id, :only => [:edit,:update,:destroy,:show,:add_homework_users,:destory_homework_users, :praise_homework] before_filter :find_course_by_hoemwork_id, :only => [:edit,:update,:destroy,:show,:add_homework_users,:destory_homework_users, :praise_homework]
#判断当前角色是否有操作权限 #判断当前角色是否有操作权限

View File

@ -19,6 +19,7 @@ class UsersController < ApplicationController
layout :setting_layout layout :setting_layout
#Added by young #Added by young
before_filter :auth_login1, :only => [:show, :user_activities, :user_newfeedback] before_filter :auth_login1, :only => [:show, :user_activities, :user_newfeedback]
before_filter :logged_user_by_apptoken, :only => [:show,:user_newfeedback]
menu_item :activity menu_item :activity
menu_item :user_information, :only => :info menu_item :user_information, :only => :info
menu_item :user_course, :only => :user_courses menu_item :user_course, :only => :user_courses

View File

@ -1,3 +1,4 @@
#coding=utf-8
class CoursesService class CoursesService
include ApplicationHelper include ApplicationHelper
include CoursesHelper include CoursesHelper
@ -344,27 +345,67 @@ class CoursesService
else else
membership = @user.coursememberships.all(:conditions => Course.visible_condition(current_user)) membership = @user.coursememberships.all(:conditions => Course.visible_condition(current_user))
end end
if membership.nil? || membership.count == 0
raise l(:label_no_courses,:locale => current_user.language.nil? ? 'zh':current_user.language)
end
membership.sort! {|older, newer| newer.created_on <=> older.created_on } membership.sort! {|older, newer| newer.created_on <=> older.created_on }
result = [] result = []
membership.each do |mp| membership.each do |mp|
course = mp.course course = mp.course
unless current_user.nil? || !(current_user.admin? || course.is_public == 1 || (course.is_public == 0 && current_user.member_of_course?(course))) latest_course_dynamics = []
count,is_teacher = get_course_anonymous_evaluation current_user,course latest_news = course.news.order("created_on desc").first
if is_teacher unless latest_news.nil?
student_commit_number = count latest_course_dynamics << {:type => 1,:time => latest_news.created_on,:message => '最近更新了通知' }#l(:label_recently_updated_notification,:locale => current_user.language.nil? ? 'zh':current_user.language)}
else
need_anonymous_comments_count = count
end end
news_count = course.news.count latest_message = course.journals_for_messages.order("created_on desc").first
message_count = course.journals_for_messages.count unless latest_message.nil?
latest_course_dynamics << {:type => 2,:time => latest_message.created_on,:message => '最近更新了留言'}#l(:label_recently_updated_message,:locale => current_user.language.nil? ? 'zh':current_user.language)}
result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 1,:count => message_count} end
result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 2,:count => need_anonymous_comments_count} latest_attachment = course.attachments.order("created_on desc").first
result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 3,:count => student_commit_number} unless latest_attachment.nil?
result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 4,:count => news_count} latest_course_dynamics << {:type => 3,:time => latest_attachment.created_on,:message => '最近更新了课件'}#l(:label_recently_updated_courseware,:locale => current_user.language.nil? ? 'zh':current_user.language)}
#{:course_name => course.name,:need_anonymous_comments_count=>need_anonymous_comments_count,:student_commit_number=>student_commit_number,:news_count=> news_count,:message_count=>message_count} end
latest_bid = course.homeworks.order('updated_on DESC').first
unless latest_bid.nil?
latest_course_dynamics << {:type => 4,:time => latest_bid.updated_on,:message => '最近更新了作业'}#l(:label_recently_updated_homework,:locale => current_user.language.nil? ? 'zh':current_user.language)}
end
#每个作业中的最新留言
messages = []
course.homeworks.each do |bid|
jour = bid.journals_for_messages.order("created_on desc").first
unless jour.nil?
messages << jour
end end
end end
unless messages.count == 0
messages.sort!{|order,newer| newer.created_on <=> order.created_on}
end
latest_bid_message = messages.first
unless latest_bid_message.nil?
latest_course_dynamics << {:type => 2,:time => latest_bid_message.created_on,:message => '最近更新了留言'}#l(:label_recently_updated_message,:locale => current_user.language.nil? ? 'zh':current_user.language)}
end
#每个作业中学生最后提交的作业
homeworks = []
course.homeworks.each do |bid|
homework_attach = bid.homeworks.order('updated_at DESC').first
unless homework_attach.nil?
homeworks << homework_attach
end
end
unless homeworks.count == 0
homeworks.sort!{|order,newer| newer.updated_at <=> order.updated_at}
end
latest_homework_attach = homeworks.first
unless latest_homework_attach.nil?
latest_course_dynamics << {:type => 4,:time => latest_homework_attach.updated_at,:message => '最近更新了作业'}#l(:label_recently_updated_homework,:locale => current_user.language.nil? ? 'zh':current_user.language)}
end
latest_course_dynamics.sort!{|order,newer| newer[:time] <=> order[:time]}
latest_course_dynamic = latest_course_dynamics.first
unless latest_course_dynamic.nil?
result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => latest_course_dynamic[:type],:update_time => latest_course_dynamic[:time],:message => latest_course_dynamic[:message],:count => nil}
end
end
result.sort!{|order,newer| newer[:update_time] <=> order[:update_time]}
result result
end end

View File

@ -9,5 +9,5 @@
<%= link_to_unless page.current?, page, url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} <%= link_to_unless page.current?, page, url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil}
-%> -%>
<%= link_to_unless page.current?, page, url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %> <%= link_to page, url, page.current? ? {:remote => remote,:class => 'current-page', :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} : {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %>

View File

@ -39,8 +39,7 @@
var name = $.trim($("#name").val()); var name = $.trim($("#name").val());
if(name.length == 0) if(name.length == 0)
{ {
$("#project_name_span").text("<%= l(:label_search_conditions_not_null) %> $("#project_name_span").text("<%= l(:label_search_conditions_not_null) %>");
");
$("#project_name_span").css('color','#ff0000'); $("#project_name_span").css('color','#ff0000');
$("#project_name_span").focus(); $("#project_name_span").focus();
return false; return false;
@ -103,9 +102,10 @@
</div> </div>
<!-- 项目得分 --> <!-- 项目得分 -->
<div class="cl"></div> <div class="cl"></div>
<div class="pr_info_name><%= link_to @project.name, project_path(@project) %> <div class="pr_info_name">
<%= link_to @project.name, project_path(@project) %>
<% if !@project.is_public? %> <% if !@project.is_public? %>
<span class="img_private ">私有</span> <span class="img_private">私有</span>
<% end %> <% end %>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
@ -135,10 +135,10 @@
</ul> </ul>
<% end %> <% end %>
<div class="subNav"> <div class="subNav">
<%= link_to "动态", {:controller => 'projects', :action => 'show', :id => @project.id}, :style => "color:#3CA5C6" %> <%= link_to l(:label_activity), {:controller => 'projects', :action => 'show', :id => @project.id}, :style => "color:#3CA5C6" %>
</div> </div>
<div class="subNav"> <div class="subNav">
<%= link_to "问题跟踪", project_issues_path(@project), :style => "color:#3CA5C6" %><span class="subnav_num">(<%= @project.issues.count %>)</span> <%= link_to l(:label_issue_tracking), project_issues_path(@project), :style => "color:#3CA5C6" %><span class="subnav_num">(<%= @project.issues.count %>)</span>
<span> <span>
<% if User.current.logged? && User.current.member_of?(@project) %> <% if User.current.logged? && User.current.member_of?(@project) %>
<%= link_to "+发布问题", new_project_issue_path(@project) , :style => "font-size:12px;color:#fff; padding:1px 3px 3px 3px;height:18px;margin-top:3px;background:#28be6c;float:right;line-height:20px;" %></span> <%= link_to "+发布问题", new_project_issue_path(@project) , :style => "font-size:12px;color:#fff; padding:1px 3px 3px 3px;height:18px;margin-top:3px;background:#28be6c;float:right;line-height:20px;" %></span>
@ -148,24 +148,24 @@
<%= link_to "讨论区", project_boards_path(@project), :style => "color:#3CA5C6" %> <%= link_to "讨论区", project_boards_path(@project), :style => "color:#3CA5C6" %>
<span class="subnav_num">(<%= @project.boards.first.topics.count %>)</span> <span class="subnav_num">(<%= @project.boards.first.topics.count %>)</span>
<% if User.current.logged? && User.current.member_of?(@project) %> <% if User.current.logged? && User.current.member_of?(@project) %>
<%= link_to "+发贴", new_board_message_path(@project.boards.first), :layout => 'base_projects',:style => "font-size:12px;color:#fff; padding:1px 3px 3px 3px;height:18px;margin-top:4px;background:#28be6c;float:right;line-height:20px;" %> <%= link_to "+发贴", new_board_message_path(@project.boards.first, true), :layout => 'base_projects',:style => "font-size:12px;color:#fff; padding:1px 3px 3px 3px;height:18px;margin-top:4px;background:#28be6c;float:right;line-height:20px;" %>
<% end %> <% end %>
</div> </div>
<div class="subNav"> <div class="subNav">
<%= link_to "资源库", project_files_path(@project), :style => "color:#3CA5C6" %><span class="subnav_num">(<%= @project.attachments.count %>)</span> <%= link_to l(:label_course_file), project_files_path(@project), :style => "color:#3CA5C6" %><span class="subnav_num">(<%= @project.attachments.count %>)</span>
<% if User.current.logged? && User.current.member_of?(@project) %> <% if User.current.logged? && User.current.member_of?(@project) %>
<%= link_to "+上传资源", new_project_file_path(@project),:style => "font-size:12px;color:#fff; padding:1px 3px 3px 3px;height:18px;margin-top:3px;background:#28be6c;float:right;line-height:20px;" %> <%= link_to "+上传资源", new_project_file_path(@project),:style => "font-size:12px;color:#fff; padding:1px 3px 3px 3px;height:18px;margin-top:3px;background:#28be6c;float:right;line-height:20px;" %>
<% end %> <% end %>
</div> </div>
<div class="subNav"> <div class="subNav">
<%= link_to "版本库", {:controller => 'repositories', :action => 'show', :id => @project.id}, :style => "color:#3CA5C6" %> <%= link_to l(:field_user_active_changeset), {:controller => 'repositories', :action => 'show', :id => @project.id}, :style => "color:#3CA5C6" %>
<span class="subnav_num">(<%= @project.repositories.count %>)</span> <span class="subnav_num">(<%= @project.repositories.count %>)</span>
<% if User.current.logged? && User.current.member_of?(@project) %> <% if User.current.logged? && User.current.member_of?(@project) %>
<%= link_to "+创建版本库", new_project_repository_path(@project),:style => "font-size:12px;color:#fff; padding:1px 3px 3px 3px;height:18px;margin-top:3px;background:#28be6c;float:right;line-height:20px;" %> <%= link_to "+创建版本库", new_project_repository_path(@project),:style => "font-size:12px;color:#fff; padding:1px 3px 3px 3px;height:18px;margin-top:3px;background:#28be6c;float:right;line-height:20px;" %>
<% end %> <% end %>
</div> </div>
<div class="subNav subNav_jiantou">更多</div> <div class="subNav subNav_jiantou"><%= l(:label_more) %></div>
<ul class="navContent" style="padding-left: 0px"> <ul class="navContent" style="padding-left: 0px">
<%= render 'projects/tools_expand' %> <%= render 'projects/tools_expand' %>
</ul> </ul>

View File

@ -1,24 +0,0 @@
<div class="floatbox" style="margin:100px;">
<div ><a href="#" class="box_close"></a></div>
<div class="cl"></div>
<div class="box_main">
<h3 class="box_h3">发送邮件邀请新用户</h3>
<p class="box_p">输入好友邮箱地址Trustie帮您免费发送</p>
<div id="is_registed">
<%= render :partial => 'regested', locals: { :isregisted => false} %>
</div>
<%= form_tag('send_mail_to_member', :controller => 'projects',:action => 'send_mail_to_member', method: 'get',:remote=>true) do %>
<ul>
<li >
<%= text_field_tag 'mail', '邮箱', :class => "fb_item fl" %>
</li>
<div class="cl"></div>
<div class="cl"></div>
</ul>
<%= submit_tag '免费发送', :class=> "btn_free" %>
<% end %>
</div>
</div>

View File

@ -44,11 +44,7 @@
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">

View File

@ -1 +1,24 @@
<%= render :partial => "invite_members_by_mail"%> <div class="project_r_h">
<h2 class="project_h2">邀请加入</h2>
</div>
<div class="floatbox" style="margin:130px;">
<div >
<a href="#" class="box_close"></a>
</div>
<div class="cl"></div>
<div class="box_main">
<h3 class="box_h3">发送邮件邀请新用户</h3>
<p class="box_p">
输入好友邮箱地址Trustie帮您免费发送
</p>
<div id="is_registed">
<%= render :partial => 'regested', locals: { :isregisted => false} %>
</div>
<%= form_tag('send_mail_to_member', :controller => 'projects',:action => 'send_mail_to_member', method: 'get',:remote=>true) do %>
<%= text_field_tag 'mail', '邮箱', :class => "fb_item fl" %>
<div class="cl"></div>
<div class="cl"></div>
<%= submit_tag '免费发送', :style => "display:block; width:80px; text-align:center; color:#fff; height:26px; padding-top:3px; margin-bottom:10px;" %>
<% end %>
</div>
</div>

View File

@ -1,10 +0,0 @@
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'invite_members_by_mail') %>');
showModal('ajax-modal', '513px');
$('#ajax-modal').css('height','569px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;padding-left: 513px;'>" +
"<a href='#' onclick='hidden_homework_atert_form();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().removeClass("alert_praise");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("alert_box");

View File

@ -180,4 +180,4 @@
</div> </div>
</div> </div>
<%= paginate @events_pages %> <%= paginate @events_pages, :window => 3%>

View File

@ -9,18 +9,35 @@
<tr> <tr>
<td class="r1" style="word-break: break-all;word-wrap: break-word;"> <td class="r1" style="word-break: break-all;word-wrap: break-word;">
<div class="cb"> <div class="cb">
<strong><%= l(:label_attachment) %>:&nbsp;&nbsp;<%= file.filename %></strong> <strong>
<%= l(:label_attachment) %>:
&nbsp;&nbsp;
<%= file.filename %>
</strong>
<span style="margin-left: 4px;"> <span style="margin-left: 4px;">
<%= link_to_attachment file, {:download => true, :text => image_tag("/images/button/dl.png", width: "70px", alt: l(:button_download), :class => 'download_icon')}%> <%= link_to_attachment file, {:download => true, :text => image_tag("/images/button/dl.png", width: "70px", alt: l(:button_download), :class => 'download_icon')}%>
</span> </span>
</div> </div>
<strong><%= l(:field_description) %></strong>:&nbsp;&nbsp;<%= file.description %> <strong>
<div class="c9 gray-color"> <%= l('attachment.category')%><%=result_come_from file%> </div> <%= l(:field_description) %>
</strong>:
&nbsp;&nbsp;
<%= file.description %>
<div class="c9 gray-color">
<%= l('label_attachment_category')%>
<%=result_come_from file%>
</div>
<span class="gray blue-color"> <span class="gray blue-color">
<%= l('attachment.download_num')%><%= file.downloads%>| <%= l('label_attachment_download_num')%>
<%= l('attachment.size')%><%= number_to_human_size(file.filesize) %>| <%= file.downloads%>|
<%= l('attachment.sharer')%><a class="gray" ><%= link_to file.author, user_path(file.author), target: "_blank" unless file.author.blank? %></a>| <%= l('label_attachment_size')%>
<%= l('attachment.upload_time')%><%= format_time(file.created_on) %> <%= number_to_human_size(file.filesize) %>|
<%= l('label_attachment_sharer')%>
<a class="gray" >
<%= link_to file.author, user_path(file.author), target: "_blank" unless file.author.blank? %>
</a>|
<%= l('label_attachment_upload_time')%>
<%= format_time(file.created_on) %>
</span> </span>
<div style="display: none"></div> <div style="display: none"></div>
</td> </td>

View File

@ -16,8 +16,8 @@
<div class="menu"> <div class="menu">
<%= link_to "#{l(:label_course_new)}", new_course_path, class: 'icon icon-add' if @user == User.current %> <%= link_to "#{l(:label_course_new)}", new_course_path, class: 'icon icon-add' if @user == User.current %>
<ul> <ul>
<li mode='doing' class="on"><%= l('user.courses.doing')%></li> <li mode='doing' class="on"><%= l(:label_course_doing)%></li>
<li mode='end'><%= l('user.courses.done')%></li> <li mode='end'><%= l(:label_course_done)%></li>
</ul> </ul>
</div> </div>

View File

@ -1876,3 +1876,12 @@ en:
label_submit_comments: Submit_comments label_submit_comments: Submit_comments
label_course_empty_select: You have not selected course label_course_empty_select: You have not selected course
label_enterprise_page_made: enterprise_page label_enterprise_page_made: enterprise_page
label_add_tag: Add Tag
#api
label_recently_updated_notification: Recently updated notification
label_recently_updated_homework: Recently updated the homework
label_recently_updated_message: Recently updated the message
label_recently_updated_courseware: Recently updated the courseware
label_no_courses: You do not participate in any course, please search the curriculum, course, or create a course!

View File

@ -696,8 +696,8 @@ zh:
label_limit_time: 截止日期 label_limit_time: 截止日期
label_commit_homework: 提交作业 label_commit_homework: 提交作业
label_course_homework: 对应课程 label_course_homework: 对应课程
label_course_doing: 进行中的课程 label_course_doing: 进行中
label_course_done: 已结束的课程 label_course_done: 已结束
label_homework_response: 作业咨询 label_homework_response: 作业咨询
label_bidding_homework: 提交作业 label_bidding_homework: 提交作业
label_add_homework: 添加作业 label_add_homework: 添加作业
@ -2580,3 +2580,19 @@ zh:
label_part_enterprise_tips: 您可能对系统的其它项目感兴趣! label_part_enterprise_tips: 您可能对系统的其它项目感兴趣!
label_enterprise_nil: 该模块为最新上线模块,目前还没有创建企业项目! label_enterprise_nil: 该模块为最新上线模块,目前还没有创建企业项目!
label_enterprises: 组织 label_enterprises: 组织
label_add_tag: 添加标签
label_tags_opensource: 开源项目
label_attachment_category: 所属分类
label_attachment_download_num: 下载
label_attachment_size: 大小
label_attachment_sharer: 共享者
label_attachment_upload_time: 上传时间
#api
label_recently_updated_notification: 最近更新了通知
label_recently_updated_homework: 最近更新了作业
label_recently_updated_message: 最近更新了留言
label_recently_updated_courseware: 最近更新了课件
label_no_courses: 您没有参与任何课程,请搜索课程、加入课程,或者创建课程吧!