memcached_alan
huang 11 years ago
commit 085302e0f7

@ -3,16 +3,23 @@
module Mobile
module Apis
class Upgrade < Grape::API
include ApplicationHelper
resource :upgrade do
desc "get update info"
params do
requires :platform, type: String, desc: '平台名android, ios'
end
get do
@current_version = ::PhoneAppVersion.reorder('created_at desc').first
attachment = @current_version.attachments.first
if attachment.nil?
raise '未发现客户端!'
end
url = Setting.host_name + "/attachments/download/" + attachment.id.to_s + "/" + attachment.filename
{
version: '2',
url: 'http://u06.shellinfo.cn/trustie/Trustie_Beta1.0.0_201412310917.apk',
desc: '更新了什么功能'
version: @current_version.version,
url: url,
desc: @current_version.description
}
end
end

@ -1,9 +1,15 @@
module Mobile
module Entities
class CourseDynamic < Grape::Entity
include Redmine::I18n
def self.course_dynamic_expose(field)
expose field do |c,opt|
c[field] if (c.is_a?(Hash) && c.key?(field))
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))
end
end
end
course_dynamic_expose :type
@ -11,6 +17,8 @@ module Mobile
course_dynamic_expose :course_name
course_dynamic_expose :course_id
course_dynamic_expose :course_img_url
course_dynamic_expose :message
course_dynamic_expose :update_time
end
end
end

@ -337,6 +337,40 @@ class AdminController < ApplicationController
end
def create_version
@versions = PhoneAppVersion.reorder('created_at desc')
@new_version = PhoneAppVersion.new
@new_version.version = params[:version]
@new_version.description = params[:description]
if params[:attachments][:dummy][:file].nil? || params[:attachments][:dummy][:file] == ""
respond_to do |format|
flash.now[:error] = "#{l :label_version_create_fail}: #{l(:label_client_need)}"
#flash.now[:error] = "#{l :label_first_page_create_fail}: #{@course_page.errors.full_messages[0]}"
format.html {
render :action => 'mobile_version'
}
format.api { render_validation_errors(@new_version) }
end
else
@new_version.save_attachments(params[:attachments] || (params[:version] && params[:version][:uploads]))
if @new_version.save
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_create)
redirect_to mobile_version_url
}
format.api { render_api_ok }
end
else
respond_to do |format|
flash.now[:error] = "#{l :label_version_create_fail}: #{@new_version.errors.full_messages[0]}"
#flash.now[:error] = "#{l :label_first_page_create_fail}: #{@course_page.errors.full_messages[0]}"
format.html {
render :action => 'mobile_version'
}
format.api { render_validation_errors(@new_version) }
end
end
end
end

@ -177,6 +177,25 @@ class ApplicationController < ActionController::Base
end
end
def logged_user_by_apptoken
#从手机端传来apptoken则将当前登陆用户变为对应的用户
if params[:apptoken]
token = ApiKey.where(access_token: params[:apptoken]).first
if token.expired?
return
end
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
def logout_user
if User.current.logged?

@ -233,6 +233,8 @@ class AttachmentsController < ApplicationController
format.html { redirect_to_referer_or softapplications_path(@attachment.container) }
elsif !@attachment.container.nil? && @attachment.container.is_a?(Bid)
format.html { redirect_to_referer_or respond_path(@attachment.container) }
elsif !@attachment.container.nil? && @attachment.container.is_a?(PhoneAppVersion)
format.html { redirect_to_referer_or mobile_version_path }
else
if @project.nil?
format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) }
@ -417,7 +419,7 @@ private
@attachment.container.board.course)
@course = @attachment.container.board.course
else
unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication'
unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion'
@project = @attachment.project
end
end

@ -17,6 +17,7 @@ class CoursesController < ApplicationController
menu_item l(:label_sort_by_influence), :only => :index
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 :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]

@ -6,7 +6,7 @@ class HomeworkAttachController < ApplicationController
###############################
before_filter :can_show_course,except: []
#判断当前角色权限时需先找到当前操作的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_course_by_hoemwork_id, :only => [:edit,:update,:destroy,:show,:add_homework_users,:destory_homework_users, :praise_homework]
#判断当前角色是否有操作权限

@ -19,6 +19,7 @@ class UsersController < ApplicationController
layout :setting_layout
#Added by young
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 :user_information, :only => :info
menu_item :user_course, :only => :user_courses
@ -445,12 +446,13 @@ class UsersController < ApplicationController
activity = Activity.where(where_condition).where('user_id = ?', @user.id).order('id desc')
end
activity = activity.reject { |e|
!User.current.admin? &&
e.act.nil? ||
(!User.current.admin? && !e.act.nil?
(((e.act_type == "Issue") && !e.act.project.visible?(User.current)) ||
(e.act_type == "Bid" && !e.act.courses.first.nil? && e.act.courses.first.is_public == 0 && !User.current.member_of_course?(e.act.courses.first)) ||
(e.act_type == "Journal" && e.act.respond_to?("Project") && !e.act.project.visible?(User.current)) ||
(e.act_type == "News" && ((!e.act.project.nil? && !e.act.project.visible?(User.current)) || (!e.act.course.nil? && e.act.course.is_public == 0 && !User.current.member_of_course?(e.act.course)))) ||
(e.act_type == "Message" && !e.act.board.nil? && ((!e.act.board.project.nil? && !e.act.board.project.visible?(User.current)) || (!e.act.board.course.nil? && e.act.board.course.is_public == 0 && !User.current.member_of_course?(e.act.board.course)))))
(e.act_type == "Message" && !e.act.board.nil? && ((!e.act.board.project.nil? && !e.act.board.project.visible?(User.current)) || (!e.act.board.course.nil? && e.act.board.course.is_public == 0 && !User.current.member_of_course?(e.act.board.course))))))
}
@activity_count = activity.count
@activity_pages = Paginator.new @activity_count, pre_count, params['page']

@ -351,10 +351,28 @@ module CoursesHelper
str
end
# added by nwb
# added by meng
# 课程time+term简写2014.春/2014.秋)国际化输出
def get_course_term course
str = ( course.try(:time).to_s << '.' << course.try(:term).to_s )
str[0..-4]
strterm = course.try(:term).to_s
if !(User.current.language == 'zh')
strterm == '春季学期' ? strterm = 'spring term' : strterm = 'autumn term'
str = ( course.try(:time).to_s << '.' << strterm )
str[0..-6]
else
str = ( course.try(:time).to_s << '.' << strterm )
str[0..-4]
end
end
# added by meng
# 课程term春季学期/秋季学期)国际化输出
def get_course_term_locales course
str = course.try(:term).to_s
if !(User.current.language == 'zh')
str == '春季学期' ? str = ' ' + 'spring term' : str = ' ' + 'autumn term'
end
return str
end
def members_to_user_ids members

@ -341,7 +341,7 @@ module WelcomeHelper
end
str
rescue Exception => e
str << content_tag("span", l(:field_user_active_unknow))
str << content_tag("span", l('user.active.unknow'))
end
def show_event_reply event

@ -1,3 +1,6 @@
class PhoneAppVersion < ActiveRecord::Base
attr_accessible :description, :version
validates_presence_of :description, :version
validates_uniqueness_of :version
acts_as_attachable
end

@ -131,7 +131,7 @@ class Project < ActiveRecord::Base
#ActiveModel::Dirty 这里有一个changed方法。对任何对象都可以用
after_save :update_inherited_members, :if => Proc.new {|project| project.inherit_members_changed?}
# 创建project之后默认创建一个board之后的board去掉了board的概念
after_create :create_board_sync
after_create :create_board_sync,:acts_as_forge_activities
before_destroy :delete_all_members
def remove_references_before_destroy
return if self.id.nil?
@ -1154,6 +1154,13 @@ class Project < ActiveRecord::Base
end
end
# Time 2015-03-10 15:33:16
# Author lizanle
# Description 新建项目要在ForgeActivities中加一条数据。
def acts_as_forge_activities
fa = ForgeActivity.new(:user_id => User.current.id,:project_id => self.id,
:forge_act_id => self.id,:forge_act_type => "ProjectCreateInfo")
fa.save!
end
end

@ -33,16 +33,32 @@ class UserExtensions < ActiveRecord::Base
return self.brief_introduction
end
# added by bai
# added by meng
def show_identity
if self.identity == 0
user_identity = '教师'
if User.current.language == 'zh'
user_identity = '教师'
else
user_identity = 'Teacher'
end
elsif self.identity == 1
user_identity = '学生'
if User.current.language == 'zh'
user_identity = '学生'
else
user_identity = 'Student'
end
elsif self.identity == 2
user_identity = '企业'
if User.current.language == 'zh'
user_identity = '企业'
else
user_identity = 'Enterprise'
end
elsif self.identity == 3
user_identity = '开发者'
if User.current.language == 'zh'
user_identity = '开发者'
else
user_identity = 'Developer'
end
else
user_identity = ''
end

@ -1,3 +1,4 @@
#coding=utf-8
class CoursesService
include ApplicationHelper
include CoursesHelper
@ -344,27 +345,67 @@ class CoursesService
else
membership = @user.coursememberships.all(:conditions => Course.visible_condition(current_user))
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 }
result = []
membership.each do |mp|
course = mp.course
unless current_user.nil? || !(current_user.admin? || course.is_public == 1 || (course.is_public == 0 && current_user.member_of_course?(course)))
count,is_teacher = get_course_anonymous_evaluation current_user,course
if is_teacher
student_commit_number = count
else
need_anonymous_comments_count = count
latest_course_dynamics = []
latest_news = course.news.order("created_on desc").first
unless latest_news.nil?
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)}
end
latest_message = course.journals_for_messages.order("created_on desc").first
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)}
end
latest_attachment = course.attachments.order("created_on desc").first
unless latest_attachment.nil?
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)}
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
news_count = course.news.count
message_count = course.journals_for_messages.count
result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 1,:count => message_count}
result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 2,:count => need_anonymous_comments_count}
result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 3,:count => student_commit_number}
result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 4,:count => news_count}
#{: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
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
end

@ -1,9 +1,20 @@
<h3><%= l(:label_mobile_version) %></h3>
<a href="javascript:void(0)" onclick="$('#new_version').slideToggle(400); ">发布新版本</a>
<div>
<form id="new_version" style="display: none">
发布新版本
</form>
<%= form_tag({:controller => 'admin', :action => 'create_version'},{:id => 'new_version',:style=>'display:none'}) do %>
<p style="margin-left:60px;padding-right: 20px;">
<label for='version'><%= l(:label_version_number) %>:</label>
<%= text_field_tag 'version', params[:version],:value => @new_version.version, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<p style="margin-left:60px;padding-right: 20px;">
<label for='description'><%= l(:label_version_description)%>:</label>
<%= text_field_tag 'description', params[:description],:value => @new_version.description,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<p style="margin-left:60px;padding-right: 20px;">
<%= render :partial => 'attachments/form', :locals => {:container => @new_version} %>
</p>
<%= submit_tag l(:button_save), :class => "small", :name => nil %>
<% end %>
</div>
<br/>
<div>当前版本:</div>
@ -25,7 +36,10 @@
<% end %>
</tbody>
</table>
<% if @versions.first.attachments.any?%>
<% options = {:author => true, :deletable => true } %>
<%= render :partial => 'attachments/links', :locals => {:attachments => @versions.first.attachments, :options => options, :is_float => true} %>
<% end %>
<br/>
<div>历史版本:</div>

@ -12,7 +12,7 @@
<tr>
<td class="info_font" style="width: 240px;" rowspan="2">
<a href="http://<%= Setting.host_course%>" style="color: #15bccf;">
高校课程实践社区
<%= l(:label_courses_community)%>
</a>
</td>
<td class="location-list">

@ -7,7 +7,7 @@
<tr>
<td class="info_font" style="width: 240px;" rowspan="2">
<a href="http://<%= Setting.host_course%>" style="color: #15bccf;">
高校课程实践社区
<%= l(:label_courses_community)%>
</a>
</td>
<td class="location-list">

@ -37,7 +37,7 @@
:description_placeholder => l(:label_optional_description)
} %>
<!--<input type="submit" name="" value="上传文件" class="f_l ml10" style="width:80px; height:26px;">-->
<label class="f_l ml10 c_grey">
<label class="f_l ml10 c_grey" style=" margin-top: 3px;">
<span id="upload_file_count">
<%= l(:label_no_file_uploaded)%>
</span>

@ -1,6 +1,6 @@
$(function(){
$("#button1").click(function(){
myTips("您的意见已经反馈到公共贴吧的新手讨论吧,我们会第一时间解决您的问题,谢谢支持!","success");
myTips(<%= l(:label_feedback_success)%>,"success");
});
})

@ -1,13 +1,13 @@
<%= form_tag({:controller => 'homework_attach', :action => 'add_jour_reply'}, :remote => true) do %>
<%= text_area_tag 'user_notes', "", :class => 'noline',
:style => "resize: none;", :rows => 4,
:placeholder => l(:label_projects_feedback_respond_content),
:placeholder => l(:label_feedback_respond_content),
:maxlength => 250 %>
<span style="float: left; margin-top: 1px; margin-right: 4px;"></span>
<%= hidden_field_tag 'reference_id', params[:reference_id], :value => journal.id %>
<%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => m_reply_id.user.id %>
<%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => m_reply_id.id %>
<%= submit_tag l(:button_projects_feedback_respond),
<%= submit_tag l(:button_feedback_respond),
:name => nil , :class => "enterprise", :style => "float: right; margin-top: 1px; margin-right: 4px;"%>
<% end %>

@ -25,7 +25,7 @@
:homework_id =>homework.id },
:remote => true, :confirm => l(:text_are_you_sure), :title => l(:button_delete)) %>
<% end %>
<%= link_to l(:label_projects_feedback_respond),'',
<%= link_to l(:button_reply),'',
{:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), ''); $('##{ids} textarea') ;return false;"}
%>
</span>

@ -11,7 +11,7 @@
<div class="recall_con">
<% id = 'project_respond_form_'+ reply.id.to_s %>
<%= link_to reply.user.name, user_path(reply.user) %>
回复
<%= l(:label_reply_to)%>
<% parent_jour = JournalsForMessage.find reply.m_reply_id %>
<% if show_name && parent_jour %>
<%= link_to parent_jour.user.name, user_path(parent_jour.user) %>
@ -34,7 +34,7 @@
:remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) %>
<% end %>
<% if reply_allow %>
<%= link_to l(:label_projects_feedback_respond),'',
<%= link_to l(:button_reply),'',
{:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{id}'), $('##{id} textarea'), ''); return false;"} %>
<% end %> <!-- #{l(:label_reply_plural)} #{m_reply_id.user.name}: -->
</span>

@ -42,7 +42,7 @@
<% ids = 'project_respond_form_'+ jour.id.to_s%>
<div class="ping_disfoot">
<span>
<%= link_to l(:label_projects_feedback_respond),'',
<%= link_to l(:label_newfeedback_respond),'',
{:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), ''); $('##{ids} textarea') ;return false;"}
%>
</span>

@ -65,7 +65,7 @@
</span>
<% ids = 'project_respond_form_'+ journal.id.to_s%>
<span>
<%= link_to l(:label_projects_feedback_respond),'',
<%= link_to l(:button_reply),'',
{:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.name}: '); $('##{ids} textarea') ;return false;"}
%>
<% if journal.user==User.current|| User.current.admin? %>

@ -7,7 +7,7 @@
<tr>
<td class="info_font" style="width: 240px;" rowspan="2">
<a href="http://<%= Setting.host_course%>" style="color: #15bccf;">
高校课程实践社区
<%= l(:label_courses_community)%>
</a>
</td>
<td style="width: auto; color: #15bccf">

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save