memcached_alan
sw 10 years ago
commit 6edbb3c7ed

@ -2,6 +2,7 @@
module Mobile
module Apis
class Comments < Grape::API
include ApplicationHelper
resource :comments do
desc '课程通知评论'
params do
@ -82,8 +83,8 @@ module Mobile
memo: {:subject => params[:subject],:content => '该贴来自手机App意见反馈'},
}
cs = CommentService.new
memo = cs.create_feedback cs_params, current_user
raise "commit failed #{memo.errors.full_messages}" if memo.new_record?
memo,message = cs.create_feedback cs_params, current_user
raise message if memo.new_record?
present :status, 0
end

@ -82,7 +82,7 @@ module Mobile
desc "用户搜索"
params do
requires :name, type: String, desc: '用户名关键字'
requires :search_by, type: String,desc: '搜索依据0 昵称1 用户名2 邮箱'
requires :search_by, type: String,desc: '搜索依据0 昵称1 用户名2 邮箱,3 昵称和姓名'
end
get 'search/search_user' do
us = UsersService.new

@ -15,6 +15,8 @@ module Mobile
course_dynamic_expose :type
course_dynamic_expose :count
course_dynamic_expose :course_name
course_dynamic_expose :course_term
course_dynamic_expose :course_time
course_dynamic_expose :course_id
course_dynamic_expose :course_img_url
course_dynamic_expose :message

@ -1,5 +1,6 @@
class DiscussDemosController < ApplicationController
def index
@discuss_demo_list = DiscussDemo.where("body is not null").order("created_at desc").page(params[:page] || 1).per(10)
end
@ -24,7 +25,12 @@ class DiscussDemosController < ApplicationController
end
def destroy
DiscussDemo.delete_all(["id = ?",params[:id]])
asset = Kindeditor::Asset.find_by_owner_id(params[:id])
filepath = File.join(Rails.root,"public","files","uploads",
asset[:created_at].to_s.gsub("+0800","").to_datetime.strftime("%Y%m").to_s,
asset[:asset].to_s)
File.delete(filepath) if File.exist?filepath
DiscussDemo.destroy(params[:id])
redirect_to :controller=> 'discuss_demos',:action => 'index'
end

@ -91,6 +91,7 @@ class DocumentsController < ApplicationController
def update
@document.safe_attributes = params[:document]
@document.save_attachments(params[:attachments])
if request.put? and @document.save
flash[:notice] = l(:notice_successful_update)
redirect_to document_url(@document)

@ -20,7 +20,7 @@ class ForumsController < ApplicationController
#@memo.author_id = User.current.id
#@forum = @memo.forum
cs = CommentService.new
@memo = cs.create_feedback params,User.current
@memo,message = cs.create_feedback params,User.current
respond_to do |format|
if !@memo.new_record?
format.html { redirect_to forum_path(@memo.forum) }

@ -109,7 +109,7 @@ class MembersController < ApplicationController
end
if params[:flag]
unless members.present? && members.all? {|m| m.valid? }
flash[:error] = members.collect {|m| m.errors.full_messages}.flatten.uniq.join(', ')
flash[:error] = members.empty? ? l(:label_user_role_null) :members.collect {|m| m.errors.full_messages}.flatten.uniq.join(', ')
else
flash[:notice] = l(:label_invite_success)
end

@ -340,6 +340,7 @@ class ProjectsController < ApplicationController
@is_zhuce =false
flash[:notice] = l(:notice_email_sent, :value => email)
else
flash[:error] = l(:notice_registed_success, :value => email)
@is_zhuce = true
end
respond_to do |format|

@ -20,7 +20,7 @@ class WelcomeController < ApplicationController
include WelcomeHelper
helper :project_score
caches_action :robots
before_filter :find_first_page, :only => [:index]
#before_filter :find_first_page, :only => [:index]
# before_filter :fake, :only => [:index, :course]
before_filter :entry_select, :only => [:index]

@ -60,4 +60,8 @@ module ApiHelper
end
[count,is_teacher]
end
def get_user_language user
(user.language.nil? || user.language == "") ? 'zh':user.language
end
end

@ -43,7 +43,7 @@ module WatchersHelper
)
method = watched ? 'delete' : 'post'
link_to text, url, :remote => true, :method => method, :class => css
link_to text, url, :remote => true, :method => method, :style => "color: #fff; display:block; padding: 0px 5px; margin-right: 10px; height: 22px; line-height: 21px;padding-top:1px; background: none repeat scroll 0% 0% #64BDD9; TES"
end
############## added by linchun
@ -278,11 +278,11 @@ module WatchersHelper
)
method = applied ? 'delete' : 'post'
link_to text, url, :remote => true, :method => method ,:class=>css
link_to text, url, :remote => true, :method => method ,:style => "color: #fff; display:block; padding: 0px 5px; margin-right: 10px; height: 21px; line-height: 22px;padding-top:1px; background: none repeat scroll 0% 0% #64BDD9; TES"
end
def exit_project_link(project)
link_to(l(:label_exit_project),exit_cur_project_path(project.id),
:remote => true, :confirm => l(:lable_sure_exit_project), :style => "color: #fff; display:block; padding: 0px 5px; margin-right: 10px; height: 22px; line-height: 22px; background: none repeat scroll 0% 0% #64BDD9; TES" )
:remote => true, :confirm => l(:lable_sure_exit_project), :style => "color: #fff; display:block; padding: 0px 5px; margin-right: 10px; height: 21px; line-height: 22px; background: none repeat scroll 0% 0% #64BDD9; TES;padding-top:1px;" )
end
end

@ -1,4 +1,4 @@
class DiscussDemo < ActiveRecord::Base
attr_accessible :title, :body
has_many_kindeditor_assets :attachments, :dependent => :destroy
has_many_kindeditor_assets :assets, :dependent => :destroy
end

@ -214,6 +214,8 @@ class User < Principal
where(" LOWER(login) LIKE '#{pattern}' ")
elsif type == "1"
where(" LOWER(concat(lastname, firstname)) LIKE '#{pattern}' ")
elsif type == "3"
where(" LOWER(concat(lastname, firstname,login)) LIKE '#{pattern}' ")
else
where(" LOWER(mail) LIKE '#{pattern}' ")
end

@ -33,39 +33,41 @@ class UserExtensions < ActiveRecord::Base
return self.brief_introduction
end
# added by meng
def show_identity
if self.identity == 0
if User.current.language == 'zh'
user_identity = '教师'
else
user_identity = 'Teacher'
end
elsif self.identity == 1
if User.current.language == 'zh'
user_identity = '学生'
else
user_identity = 'Student'
end
elsif self.identity == 2
if User.current.language == 'zh'
user_identity = '企业'
if User.current.language == 'zh'||User.current.language == ''
case self.identity
when 0
user_identity = l(:label_account_identity_teacher)
when 1
user_identity = l(:label_account_identity_student)
when 2
user_identity = l(:label_account_identity_enterprise)
when 3
user_identity = l(:label_account_identity_developer)
else
user_identity = 'Enterprise'
user_identity = ''
end
elsif self.identity == 3
if User.current.language == 'zh'
user_identity = '开发者'
else
user_identity = 'Developer'
end
case self.identity
when 0
user_identity = l(:label_account_identity_teacher)
when 1
user_identity = l(:label_account_identity_student)
when 2
user_identity = l(:label_account_identity_enterprise)
when 3
user_identity = l(:label_account_identity_developer)
else
user_identity = ''
end
end
return user_identity
end
# end
def self.introduction(user, message)
unless user.user_extensions.nil?
info = user.user_extensions

@ -1,4 +1,6 @@
class CommentService
include ApiHelper
include Redmine::I18n
#评论
def news_comments params,current_user
@news = News.find(params[:id])
@ -84,7 +86,8 @@ class CommentService
@memo.forum_id = "1"
@memo.author_id = current_user.id
@memo.save
@memo
message = "#{l(:label_commit_failed,:locale => get_user_language(current_user))}: #{@memo.errors.full_messages}" if @memo.new_record?
[@memo,message]
end
#课程留言列表

@ -38,7 +38,7 @@ class CoursesService
if name.blank?
raise 'sumbit empty'
end
@courses = courses_all.visible
@courses = courses_all.visible(current_user)
if params[:name].present?
@courses_all = @courses.like(params[:name])
else
@ -346,7 +346,7 @@ class CoursesService
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)
raise l(:label_no_courses,:locale => get_user_language(current_user))
end
membership.sort! {|older, newer| newer.created_on <=> older.created_on }
result = []
@ -355,19 +355,19 @@ class CoursesService
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)}
latest_course_dynamics << {:type => 1,:time => latest_news.created_on,:message => l(:label_recently_updated_notification,:locale => get_user_language(current_user))}
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)}
latest_course_dynamics << {:type => 2,:time => latest_message.created_on,:message => l(:label_recently_updated_message,:locale => get_user_language(current_user))}
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)}
latest_course_dynamics << {:type => 3,:time => latest_attachment.created_on,:message => l(:label_recently_updated_courseware,:locale => get_user_language(current_user))}
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)}
latest_course_dynamics << {:type => 4,:time => latest_bid.updated_on,:message => l(:label_recently_updated_homework,:locale => get_user_language(current_user))}
end
#每个作业中的最新留言
messages = []
@ -382,7 +382,7 @@ class CoursesService
end
latest_bid_message = messages.first
unless latest_bid_message.nil?
latest_course_dynamics << {:type => 4,:time => latest_bid_message.created_on,:message => l(:label_recently_updated_message,:locale => current_user.language.nil? ? 'zh':current_user.language)}
latest_course_dynamics << {:type => 4,:time => latest_bid_message.created_on,:message => l(:label_recently_updated_message,:locale => get_user_language(current_user))}
end
#每个作业中学生最后提交的作业
homeworks = []
@ -397,12 +397,12 @@ class CoursesService
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)}
latest_course_dynamics << {:type => 4,:time => latest_homework_attach.updated_at,:message => l(:label_recently_updated_homework,:locale => get_user_language(current_user))}
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}
result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:course_time => course.time,:course_term => course.term,: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]}

@ -193,7 +193,6 @@ class UsersService
@current_user.save
#raise @current_user.errors.full_message
#return @current_user
else
raise 'wrong password'
end

@ -49,7 +49,7 @@
<span class="add_attachment" style="font-weight:normal;">
<%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %>
<!--%= link_to image_tag(),"javascript:void(0)", :onclick => "_file.click()"%-->
<%= button_tag "浏览", :type=>"button", :onclick=>"_file.click()",:onmouseover => 'this.focus()' %>
<%= button_tag l(:button_browse), :type=>"button", :onclick=>"_file.click()",:onmouseover => 'this.focus()' %>
<%= file_field_tag 'attachments[dummy][file]',
:id => '_file',
:class => 'file_selector',

@ -38,7 +38,7 @@
<span class="add_attachment">
<%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %>
<!--%= link_to image_tag(),"javascript:void(0)", :onclick => "_file.click()"%-->
<%= button_tag "浏览", :type=>"button", :onclick=>"_file.click()" %>
<%= button_tag l(:button_browse), :type=>"button", :onclick=>"_file.click()" %>
<%= file_field_tag 'attachments[dummy][file]',
:id => '_file',
:class => 'file_selector',

@ -1,7 +1,7 @@
$('#attachments_<%= j params[:attachment_id] %>').remove();
var count=$('#attachments_fields>span').length;
if(count<=0){
$("#upload_file_count").text("未上传文件");
$("#upload_file_count").text(<%= l(:label_no_file_uploaded)%>);
$(".remove_all").remove();
}else{
$("#upload_file_count").html("已上传"+"<span id=\"count\">"+count+"</span>"+"个文件");

@ -24,10 +24,6 @@
</div>
<!--display the board-->
<div class="project_r_h">
<h2 class="project_h2"><%= h @board.name %></h2>
</div>
<% if !User.current.logged? %>
<div style="font-size: 14px;margin:20px;">
<% if @project.project_type == 1 %>
@ -39,62 +35,52 @@
<hr/>
</div>
<% end %>
<div class="borad-setitle">
<span class="borad-topic-count">
共有
<%= link_to @topic_count,:controller => 'boards',:action => 'index' %>
个贴子
</span>
<!-- 内容显示部分 -->
<div class="project_right">
<div class="project_r_h">
<h2 class="project_h2"><%= h @board.name %></h2>
</div>
<div class="talk_top">
<div class="fl">项目讨论区共有<span><%= @topic_count %></span>个帖子 </div>
<% if @project.enabled_modules.where("name = 'boards'").count > 0 && User.current.member_of?(@project) %>
<span>
<%= link_to l(:label_message_new),
new_board_message_path(@board),
:class => 'icon icon-add',
:onclick => 'showAndScrollTo("add-message", "message_subject"); return false;' if User.current.logged? %>
</span>
<span><%= link_to l(:label_message_new), new_board_message_path(@board),
:class => 'problem_new_btn fl',
:onclick => 'showAndScrollTo("add-message", "message_subject"); return false;' if User.current.logged? %></span>
<% end %>
</div>
<div style="width: 100%;word-break: break-all;word-wrap: break-word;">
<div class="cl"></div>
</div>
<!-- 帖子内容显示 -->
<% if @topics.any? %>
<% @topics.each do |topic| %>
<table class="content-text-list">
<tr>
<td colspan="2" valign="top" width="50">
<%= link_to image_tag(url_to_avatar(topic.author), :class => "avatar"), user_path(topic.author) %>
</td>
<td>
<table width="640px" border="0">
<tr>
<td valign="top" width="500px" class=" <%= topic.sticky? ? 'sticky' : '' %>
<%= topic.locked? ? 'locked' : '' %>">
<%= link_to h(topic.subject.truncate(40,ommision:'...')), board_message_path(@board, topic),title:topic.subject.to_s %>
</td>
<td align="right" rowspan="3">
<table class="borad-count">
<tr>
<td align="center" class="borad-count-digit"><%= link_to (topic.replies_count), board_message_path(@board, topic) %></td>
</tr>
<tr>
<td align="center">回答</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" colspan="2">
<span class="font_lighter"><%= authoring topic.created_on, topic.author %><br/></span></td>
</tr>
</table>
</td>
</tr>
</table>
<div class="problem_main">
<a>
<%= link_to image_tag(url_to_avatar(topic.author), :class => "problem_pic talk_pic fl"), user_path(topic.author) %>
</a>
<div class="talk_txt fl">
<div>
<span><%= link_to h(topic.subject), board_message_path(@board, topic), title:topic.subject.to_s, :class =>"problem_tit fl" %></span>
<% if topic.sticky? %>
<span class="talk_up">置顶</span>
<% end %>
<div class="pagination">
<%= pagination_links_full @topic_pages, @topic_count %>
</div>
<div class="problem_line">
<span>由<%= link_to topic.author, user_path(topic.author), :class =>"problem_name" %></span>
<span>添加于<%= format_time topic.created_on %></span>
</div>
</div>
<span class="talk_btn fr">回复<%= link_to (topic.replies_count), board_message_path(@board, topic), :style =>"color:#fff;" %></span>
<div class="cl"></div>
</div><!--讨论主类容 end-->
<% end %>
<ul class="wlist">
<%= pagination_links_full @topic_pages, @topic_count, :per_page_links => false, :remote => false, :flag => true %>
</ul>
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>
<!--讨论主类容 end-->
<div class="cl"></div>
</div>
<% other_formats_links do |f| %>

@ -11,8 +11,8 @@
<%= wikitoolbar_for 'document_description' %>
<% if @document.new_record? %>
<div class="box tabular">
<p><label><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form', :locals => {:container => @document} %></p>
</div>
<% end %>

@ -1,4 +1,6 @@
<h3><%=l(:label_document)%></h3>
<div class="project_r_h">
<h2 class="project_h2"><%=l(:label_document_plural)%></h2>
</div>
<%= labelled_form_for @document do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>

@ -8,10 +8,10 @@
<table>
<tr>
<% if versions.any? %>
<td><p><%= l(:field_version) %></p></td>
<td><p style="padding-left: 50px;"><%= l(:field_version) %></p></td>
<td>
<%= select_tag "version_id", content_tag('option', '') +
options_from_collection_for_select(versions, "id", "name"), {style: 'width:100px'} %>
options_from_collection_for_select(versions, "id", "name"), {style: 'width:230px'} %>
</td>
<% if attachmenttypes.any? %>
<td><%= l(:attachment_type) %></label></td>
@ -31,14 +31,10 @@
<% end %>
</p>
<% end %>
</tr>
</table>
<p style="padding-left: 54px;"> <%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form', locals: {project: project} %></p>
</p>
<p><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form', locals: {project: project} %></p>
</div>
<%= submit_tag l(:button_add) %>
<% end %>

@ -1,7 +1,7 @@
<% attachmenttypes = @project.attachmenttypes %>
<% sufixtypes = @project.contenttypes %>
<div class="project_r_h">
<h2 class="project_h2">资源共享区</h2>
<h2 class="project_h2"><%= l(:lable_file_sharingarea) %></h2>
</div>
<div class="content-title-top">
@ -16,12 +16,12 @@
</div>
<div id="relation_file_div" class="relation_file_div hidden">
<fieldset>
<legend>搜索</legend>
<legend><%= l(:label_search)%></legend>
<%= form_tag(
attachments_autocomplete_path(:format => 'js'),
:remote => true,
:method => :post) do %>
<%= label_tag(:attach_search, "按关键字搜索:") %>
<%= label_tag(:attach_search, l(:label_search_by_keyword)) %>
<%= text_field_tag(:attach_search) %>
<%#= submit_tag("Search") %>
<% end -%>

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

Loading…
Cancel
Save