diff --git a/.gitignore b/.gitignore index af337a4e7..93c7eb248 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ .rbenv-gemsets .DS_Store public/api_doc/ +/.metadata diff --git a/Gemfile b/Gemfile index 3f07ad408..299af4509 100644 --- a/Gemfile +++ b/Gemfile @@ -22,7 +22,7 @@ gem 'spreadsheet' gem 'ruby-ole' #gem 'email_verifier', path: 'lib/email_verifier' gem 'rufus-scheduler' -gem 'dalli', path: 'lib/dalli-2.7.2' +#gem 'dalli', path: 'lib/dalli-2.7.2' group :development do gem 'grape-swagger' gem 'grape-swagger-ui', git: 'https://github.com/guange2015/grape-swagger-ui.git' diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 1efbb665f..69aae8008 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -329,4 +329,11 @@ class AdminController < ApplicationController format.html end end + #移动端版本管理 + def mobile_version + @versions = PhoneAppVersion.reorder('created_at desc') + @new_version = PhoneAppVersion.new + + end + end diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 383da0bbe..67355fdfa 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -57,6 +57,7 @@ class BoardsController < ApplicationController def show respond_to do |format| + format.js format.html { sort_init 'updated_on', 'desc' sort_update 'created_on' => "#{Message.table_name}.created_on", diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 932ffaa7a..545d61155 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -61,6 +61,10 @@ class DocumentsController < ApplicationController if @project.project_type ==1 render :action => 'show', :layout => 'base_courses' end + respond_to do |format| + format.html + format.api + end end def new diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 5336ab54d..474f199a2 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -148,7 +148,11 @@ class FilesController < ApplicationController show_attachments @containers - render :layout => !request.xhr? + + respond_to do |format| + format.html + format.js + end elsif params[:course_id] @isproject = false diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 5dc945cc7..6a251a80c 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -90,6 +90,7 @@ class IssuesController < ApplicationController respond_to do |format| + format.js format.html { render :template => 'issues/index', :layout => @project_base_tag }#by young format.api { Issue.load_visible_relations(@issues) if include_in_api_response?('relations') @@ -103,6 +104,7 @@ class IssuesController < ApplicationController format.html { render(:template => 'issues/index', :layout => @project_base_tag) }#by young format.any(:atom, :csv, :pdf) { render(:nothing => true) } format.api { render_validation_errors(@query) } + format.js end end rescue ActiveRecord::RecordNotFound @@ -154,7 +156,7 @@ class IssuesController < ApplicationController call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue }) @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads])) # 给该issue在它所在的项目中所有的issues中所在的位置给一个序号 - @issue.project_issues_index = @issue.project.issues.last.project_issues_index + 1 + @issue.project_issues_index = @issue.project.issues.last.nil? ? 1 : @issue.project.issues.last.project_issues_index + 1 if @issue.save call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue}) respond_to do |format| diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 88ebbb1c1..6ab757336 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -249,7 +249,7 @@ class ProjectsController < ApplicationController # Author lizanle # Description 项目动态展示方法,删除了不必要的代码 def show -=begin + # 试图跳转到请求的按钮 if params[:login] login = params[:login] @@ -265,7 +265,7 @@ class ProjectsController < ApplicationController if params[:jump] && redirect_to_project_menu_item(@project, params[:jump]) return end - +=begin cond = @project.project_condition(Setting.display_subprojects_issues?) has = { "show_issues" => true , @@ -307,7 +307,6 @@ class ProjectsController < ApplicationController # @events = @activity.events(@date_from, @date_to, :is_public => 1) end - =begin @events_pages = Paginator.new events.count, 10, params['page'] # 总的数据中取出某一页 @@ -315,11 +314,13 @@ class ProjectsController < ApplicationController # 按天分组 @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)} =end - + boards = @project.boards.includes(:last_message => :author).all + @topic_count = @project.boards.count # 根据对应的请求,返回对应的数据 respond_to do |format| format.html format.api + format.js end end @@ -331,6 +332,25 @@ class ProjectsController < ApplicationController @wiki ||= @project.wiki end + def send_mail_to_member + unless params[:mail].nil? + email = params[:mail] + Mailer.send_invite_in_project(email, @project, User.current).deliver + end + end + #发送邮件邀请新用户 + def invite_members_by_mail + respond_to do |format| + format.html + format.js + end + end + + # 邀请Trustie注册用户 + def invite_members + @member ||= @project.members.new + end + def edit end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index b3e808b19..48c08e2fc 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -442,16 +442,24 @@ class UsersController < ApplicationController watcher.push(User.current) activity = Activity.where(where_condition).where('user_id in (?)', watcher).order('id desc') else - activity = Activity.where(where_condition).where('user_id = ?', @user.id).order('id desc') + activity = Activity.where(where_condition).where('user_id = ?', @user.id).order('id desc') end + activity = activity.reject { |e| + !User.current.admin? && + (((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))))) + } @activity_count = activity.count @activity_pages = Paginator.new @activity_count, pre_count, params['page'] - @activity = activity.slice(@activity_pages.offset,@activity_pages.per_page ) - @activity = @activity.reject { |e| - ((e.act_type=="Issue") && ( !e.act.visible?(User.current))) || - ((e.act_type == "Journal") && (!e.act.project.visible?(User.current))) || - ((e.act_type == "Bid") && ((!User.current.member_of_course?(e.act.courses.first) || !User.current.admin?))) - } + @activity = activity.slice(@activity_pages.offset,@activity_pages.per_page) + # @activity = @activity.reject { |e| + # ((e.act_type=="Issue") && ( !e.act.visible?(User.current))) || + # ((e.act_type == "Journal") && (!e.act.project.visible?(User.current))) || + # ((e.act_type == "Bid") && ((!User.current.member_of_course?(e.act.courses.first) || !User.current.admin?))) + # } @state = 0 end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5579fe79b..30b2e7a21 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -48,7 +48,7 @@ module ApplicationHelper def authorize_for(controller, action) User.current.allowed_to?({:controller => controller, :action => action}, @project) end - + # add by nwb def authorize_for_course(controller, action) User.current.allowed_to?({:controller => controller, :action => action}, @course) @@ -1841,7 +1841,7 @@ module ApplicationHelper # course_all_course_link = link_to l(:label_course_all), {:controller => 'courses', :action => 'index'} course_teacher_all_link = link_to l(:label_teacher_all), {:controller => 'users', :action => 'index', :role => 'teacher', :host => Setting.course_domain} # courses_link = link_to l(:label_course_practice), {:controller => 'courses', :action => 'index'} - users_link = link_to l(:label_software_user), {:controller => 'users', :action => 'index', :host => Setting.user_domain} + #users_link = link_to l(:label_software_user), {:controller => 'users', :action => 'index', :host => Setting.user_domain} # contest_link = link_to l(:label_contest_innovate), {:controller => 'contests', :action => 'index'} bids_link = link_to l(:label_requirement_enterprise), {:controller => 'bids', :action => 'index'} forum_link = link_to l(:label_forum_all), {:controller => "forums", :action => "index"} @@ -1860,7 +1860,7 @@ module ApplicationHelper nav_list.push(courses_link) if @nav_dispaly_course_label && @show_course == 1 # nav_list.push(projects_link) if @nav_dispaly_project_label - nav_list.push(users_link) if @nav_dispaly_user_label + #nav_list.push(users_link) if @nav_dispaly_user_label # nav_list.push(contest_link) if @nav_dispaly_contest_label && @show_contest == 1 nav_list.push(bids_link) if @nav_dispaly_bid_label nav_list.push(forum_link) if @nav_dispaly_forum_label diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 842e1f1b7..971bf603d 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -31,7 +31,7 @@ module WatchersHelper watched = objects.any? {|object| object.watched_by?(user)} @watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or objects.first.instance_of?(Contest) or (objects.first.instance_of?(Bid))) - css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) : + css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) : ([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s) text = @watch_flag ? @@ -283,6 +283,6 @@ module WatchersHelper 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) ) + :remote => true, :confirm => l(:lable_sure_exit_project), :style => "color: #fff; display:block; padding: 0px 5px;margin-right:10px;height:22px;background:none repeat scroll 0% 0% #64BDD9;TES" ) end end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 14c01b93d..b404ea531 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -31,10 +31,11 @@ class Mailer < ActionMailer::Base # 发送邀请未注册用户加入项目邮件 # 功能: 在加入项目的同时自动注册用户 def send_invite_in_project(email, project, invitor) + @email = email @subject = "#{invitor.name} #{l(:label_invite_project)} #{project.name} " - password = newpass(6) + @password = newpass(6) @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, - :password => password, :login => email) + :password => @password, :login => email) mail :to => email, :subject => @subject end diff --git a/app/models/message.rb b/app/models/message.rb index 413a4f91c..85a87132d 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -164,8 +164,11 @@ class Message < ActiveRecord::Base # Author lizanle # Description def act_as_forge_activity - self.forge_acts << ForgeActivity.new(:user_id => self.author_id, - :project_id => self.board.project.id) + # 如果project为空,那么就是课程相关的消息 + if !self.board.project.nil? + self.forge_acts << ForgeActivity.new(:user_id => self.author_id, + :project_id => self.board.project.id) + end end #更新用户分数 -by zjc diff --git a/app/models/news.rb b/app/models/news.rb index fa9f31712..d2547fc02 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -98,8 +98,11 @@ class News < ActiveRecord::Base # Author lizanle # Description 公用表中也要记录 def act_as_forge_activity - self.forge_acts << ForgeActivity.new(:user_id => self.author_id, - :project_id => self.project.id) + # 如果是project为空,那么是课程相关的,不需要保存 + if !self.project.nil? + self.forge_acts << ForgeActivity.new(:user_id => self.author_id, + :project_id => self.project.id) + end end end diff --git a/app/models/phone_app_version.rb b/app/models/phone_app_version.rb new file mode 100644 index 000000000..abf4c54e3 --- /dev/null +++ b/app/models/phone_app_version.rb @@ -0,0 +1,3 @@ +class PhoneAppVersion < ActiveRecord::Base + attr_accessible :description, :version +end diff --git a/app/views/admin/enterprise_page_made.html.erb b/app/views/admin/enterprise_page_made.html.erb index 566f09bb8..607017f59 100644 --- a/app/views/admin/enterprise_page_made.html.erb +++ b/app/views/admin/enterprise_page_made.html.erb @@ -33,7 +33,4 @@ <%= submit_tag l(:button_save), :class => "small", :name => nil %> <% end %>
- - -
\ No newline at end of file diff --git a/app/views/admin/mobile_version.html.erb b/app/views/admin/mobile_version.html.erb new file mode 100644 index 000000000..f8fd4ad6c --- /dev/null +++ b/app/views/admin/mobile_version.html.erb @@ -0,0 +1,56 @@ +

<%= l(:label_mobile_version) %>

+发布新版本 +
+ + +
+
+
当前版本:
+ + + + + + + + + <% if @versions.count > 0 %> + "> + + + + <% end %> + +
<%=l(:label_version_number)%><%=l(:label_version_description)%>
<%= @versions.first.version %> + <%= @versions.first.description %> +
+ +
+ +
历史版本:
+ + + + + + + + + <% if @versions.count > 0 %> + <% for version in @versions %> + "> + + + + <% end %> + <% end %> + +
<%=l(:label_version_number)%><%=l(:label_version_description)%>
<%= version.version %> + <%= version.description %> +
+ + + +<% html_title(l(:label_mobile_version)) -%> \ No newline at end of file diff --git a/app/views/boards/_project_show.html.erb b/app/views/boards/_project_show.html.erb index 1a5cbd2fa..9a3b79051 100644 --- a/app/views/boards/_project_show.html.erb +++ b/app/views/boards/_project_show.html.erb @@ -9,11 +9,8 @@