diff --git a/ReadMe.txt b/ReadMe.txt index 35e56515d..722b4cd37 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -1,65 +1,72 @@ -===================================[2014-04-09]================================= -kw: 域名, 二级域名, subdomain, forge, course, contest -域名跳转(forge/course/contest)这几个设置在settings.yml中 -但是跳转在development模式下会导致无法开发 - -app/models/setting.rb :165 - # fixed domain url in development. tantantan's bug - if Rails.env.development? - methods.map do |m| - define_singleton_method m do; nil; end if m.to_s =~ /([a-zA-Z]+_domain)$/ - end - end - 程序部分链接中制定了subdomain参数,使链接在二级域名中来回跳转。 - 为了开发方便,使之功能在development模式下失效。 - - -===================================[2014-04-09]================================= -kw: 菜单, 导航栏, layout -网页上方的导航条没有用Redmine::MenuManager -MenuManager的样式无法定制,菜单显示条件if中的proc执行行为没有了解 - -#导航栏匹配域名显示和改变 -app\helper\application_helper.rb -render_dynamic_nav 方法中,利用变量,可以设置在layout中具体显示哪些条目 - -app\views\layouts\_base_header.html.erb -需要显示的条目,由具体的实例变量设置(在各个layout中) - - -===================================[2014-04-09]================================= -kw: home_path, 首页, 跳转, 二级域名, welcome -#首页根据域名匹配进入不同的页面 -app\controller\welcome_controller.rb -#entry_select 放射设置二级域名所显示的首页 - - - -===================================[2014-06-06]================================= -kw: user_scores -user_scores表结构有问题,需要运行 -bundle exec rake db:migrate:down VERSION=20140410021724 -bundle exec rake db:migrate:up VERSION=20140410021724 - - - -===================================[2014-07-08]================================= -kw: CKEditor, 富文本, 编辑器 -CKEditor插件加载方法 -1.把插件文件夹拷入plugins文件夹,确保文件夹名为redmine_ckeditor -2.运行 bundle install --without development test -3.运行 rake redmine:plugins:migrate RAILS_ENV=production -4.启动服务器 -5.配置CKEditor插件(Administration > Plugins > Configure) -6.把文本格式 (Administration > Settings > General > Text formatting)改为CKEditor -注意:一定要先配置CKEditor插件再见文本格式更改,不然,数据库不会生成对应记录,会报错。。 - - - -===================================[2014-07-19]================================= -kw: 首页, 定制, forge, course, contest, 排序 -若遇到首页定制报错问题请尝试如下操作 -如果运行迁移文件有报错与‘sort_type’相关 先运行 bundle exec rake db:migrate:down version=20140716021202 bundle exec rake db:migrate:up version=20140716021202 -在按如下步骤执行,未报与之相关的则直接按如下步骤执行 -1.运行 bundle exec rake db:migrate:down version=20140719080032 -2.运行 bundle exec rake db:migrate:up version=20140719080032 +===================================[2014-04-09]================================= +kw: , , subdomain, forge, course, contest +תforge/course/contest⼸settings.yml +תdevelopmentģʽ»ᵼ޷ + +app/models/setting.rb :165 + # fixed domain url in development. tantantan's bug + if Rails.env.development? + methods.map do |m| + define_singleton_method m do; nil; end if m.to_s =~ /([a-zA-Z]+_domain)$/ + end + end + 򲿷ƶsubdomainʹڶת + Ϊ˿㣬ʹ֮developmentģʽʧЧ + + +===================================[2014-04-09]================================= +kw: ˵, , layout +ҳϷĵûRedmine::MenuManager +MenuManagerʽ޷ƣ˵ʾifеprocִΪû˽ + +#ƥʾ͸ı +app\helper\application_helper.rb +render_dynamic_nav УñlayoutоʾЩĿ + +app\views\layouts\_base_header.html.erb +ҪʾĿɾʵãڸlayoutУ + + +===================================[2014-04-09]================================= +kw: home_path, ҳ, ת, , welcome +#ҳƥ벻ͬҳ +app\controller\welcome_controller.rb +#entry_select öʾҳ + + + +===================================[2014-06-06]================================= +kw: user_scores +user_scoresṹ⣬Ҫ +bundle exec rake db:migrate:down VERSION=20140410021724 +bundle exec rake db:migrate:up VERSION=20140410021724 + + + +===================================[2014-07-08]================================= +kw: CKEditor, ı, ༭ +CKEditorط +1.ѲļпpluginsļУȷļΪredmine_ckeditor +2. bundle install --without development test +3. rake redmine:plugins:migrate RAILS_ENV=production +4. +5.CKEditor(Administration > Plugins > Configure) +6.ıʽ (Administration > Settings > General > Text formatting)ΪCKEditor +ע⣺һҪCKEditorټıʽģȻݿⲻɶӦ¼ᱨ + + + +===================================[2014-07-19]================================= +kw: ҳ, , forge, course, contest, +ҳƱ볢² +Ǩļб롮sort_type + bundle exec rake db:migrate:down version=20140716021202 bundle exec rake db:migrate:up version=20140716021202 +ڰ²ִУδ֮صֱӰ²ִ +1. bundle exec rake db:migrate:down version=20140719080032 +2. bundle exec rake db:migrate:up version=20140719080032 +===================================[2014-07-30]================================= +kw: ҳ, , forge, course, contest, image_width + +undefined image_width +bundle exec rake db:migrate:down version=20140725062302 +bundle exec rake db:migrate:up version=20140725062302 diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 36b7e8598..aac107cfb 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -153,6 +153,8 @@ class AdminController < ApplicationController @first_page.image_width = params[:image_width] @first_page.image_height = params[:image_height] @first_page.sort_type = params[:sort_type] + @first_page.show_course = params[:show_course] + @first_page.show_contest = params[:show_contest] if @first_page.save respond_to do |format| flash[:notice] = l(:notice_successful_update) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 110974b77..c4b72f584 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -41,6 +41,7 @@ class ApplicationController < ActionController::Base cookies.delete(autologin_cookie_name) end + before_filter :find_first_page before_filter :session_expiration, :user_setup, :check_if_login_required, :set_localization before_filter :user_agent @@ -720,4 +721,11 @@ class ApplicationController < ActionController::Base raise RuntimeError, 'unknow type, Please input you type into this helper.' end end + + #查找首页相关信息 + def find_first_page + @first_page = FirstPage.where("page_type = 'project'").first + @show_course = @first_page.show_course + @show_contest = @first_page.show_contest + end end diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 026a12e9a..44d68de26 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -26,6 +26,7 @@ class AttachmentsController < ApplicationController accept_api_auth :show, :download, :upload require 'iconv' + def show respond_to do |format| format.html { @@ -41,6 +42,13 @@ class AttachmentsController < ApplicationController render :action => 'diff' elsif @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte @content = File.new(@attachment.diskfile, "rb").read + # 编码为非 UTF-8先进行间接转码 + # 部分unicode编码不直接支持转为 UTF-8 + # modify by nwb + if @content.encoding.name != 'UTF-8' + @content = @content.force_encoding('GBK') + @content = @content.encode('UTF-8') + end render :action => 'file' else download @@ -173,8 +181,11 @@ class AttachmentsController < ApplicationController respond_to do |format| # modify by nwb - if !@attachment.container.nil? && (@attachment.container.is_a?(Course) || @attachment.container.course) - if @course.nil? + if !@attachment.container.nil? && + (@attachment.container.is_a?(Course) || ((@attachment.container.has_attribute?(:course) ||@attachment.container.has_attribute?(:course_id) ) && @attachment.container.course ) ) + if @attachment.container.is_a?(News) + format.html { redirect_to_referer_or news_path(@attachment.container) } + elsif @course.nil? format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) } else format.html { redirect_to_referer_or course_path(@course) } @@ -206,6 +217,17 @@ class AttachmentsController < ApplicationController end end + #删除竞赛作品的附件 + def delete_softapplications + @attachment = Attachment.find params[:id] + @softapplication = @attachment.container if @attachment!=nil + @attachment.container.attachments.delete(@attachment) if @attachment!=nil + respond_to do |format| + format.html { redirect_to_referer_or edit_softapplication_path(@softapplication) } + #format.js + end + end + def autocomplete # modify by nwb if params[:project_id] @@ -233,6 +255,9 @@ class AttachmentsController < ApplicationController attach_copied_obj.container = obj attach_copied_obj.created_on = Time.now attach_copied_obj.author_id = User.current.id + if attach_copied_obj.attachtype == nil + attach_copied_obj.attachtype = 1 + end @obj = obj @save_flag = attach_copied_obj.save @save_message = attach_copied_obj.errors.full_messages @@ -262,6 +287,9 @@ class AttachmentsController < ApplicationController attach_copied_obj.container = obj attach_copied_obj.created_on = Time.now attach_copied_obj.author_id = User.current.id + if attach_copied_obj.attachtype == nil + attach_copied_obj.attachtype = 4 + end @obj = obj @save_flag = attach_copied_obj.save @save_message = attach_copied_obj.errors.full_messages diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index ef0be71ac..49ee47327 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -7,6 +7,9 @@ class BidsController < ApplicationController menu_item :project, :only => [:show_project,:show_results, :new_submit_homework] menu_item :homework_respond, :only => :homework_respond menu_item :homework_statistics, :only => :homework_statistics + + before_filter :can_show_course,only: [] + before_filter :can_show_contest,only: [] #Ended by young before_filter :find_bid, :only => [:show, :show_project, :create,:destroy,:more,:back,:add,:delete,:new,:show_results,:set_reward, :add_homework, :fork, :create_fork, :show_course, :show_courseEx,:show_bid_project, :show_bid_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings] @@ -983,5 +986,21 @@ class BidsController < ApplicationController render_403 unless currentUser.member_of_course?(@bid.courses.first) end + #验证是否显示课程 + def can_show_course + @first_page = FirstPage.where("page_type = 'project'").first + if @first_page.show_course == 2 + render_404 + end + end + + #验证是否显示竞赛 + def can_show_contest + @first_page = FirstPage.where("page_type = 'project'").first + if @first_page.show_contest == 2 + render_404 + end + end + end diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index cf8750b5d..e2f5e3731 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -7,6 +7,8 @@ class ContestsController < ApplicationController menu_item :application, :only => :show_softapplication menu_item :attendingcontests, :only => :show_attendingcontest menu_item :contestnotifications, :only => :index + + before_filter :can_show_contest,except: [] before_filter :find_contest, :only => [:show_contest, :show_project, :show_softapplication, :show_attendingcontest, :index, :set_reward_project, :set_reward_softapplication, :create,:destroy,:more,:back,:add,:add_softapplication,:new,:show_results, :set_reward, :show_contest_project, :show_contest_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings] @@ -27,8 +29,9 @@ class ContestsController < ApplicationController # @contests = Contest.visible # @contests ||= [] @offset, @limit = api_offset_and_limit({:limit => 10}) - @contests = Contest.visible - @contests = @contests.like(params[:name]) if params[:name].present? + #@contests = Contest.visible + #@contests = @contests.like(params[:name]) if params[:name].present? + @contests = Contest.visible.where("name like '%#{params[:name]}%'") if params[:contests_search] (redirect_to contests_path, :notice => l(:label_sumbit_empty);return) if params[:name].blank? end @@ -645,5 +648,13 @@ end render_404 end + #验证是否显示竞赛 + def can_show_contest + @first_page = FirstPage.where("page_type = 'project'").first + if @first_page.show_contest == 2 + render_404 + end + end + end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 9db479eb5..85dfba8cf 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -13,6 +13,7 @@ class CoursesController < ApplicationController menu_item l(:label_sort_by_active), :only => :index menu_item l(:label_sort_by_influence), :only => :index + before_filter :can_show_course, :except => [] before_filter :find_course, :except => [ :index, :search,:list, :new,:join,:unjoin, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches] 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] @@ -494,7 +495,7 @@ class CoursesController < ApplicationController if (User.current.logged? && User.current.member_of_course?(Course.find params[:id] )) render :layout => 'base_courses' else - render_404 + render_403 end end @@ -711,7 +712,13 @@ class CoursesController < ApplicationController end end - + #验证是否显示课程 + def can_show_course + @first_page = FirstPage.where("page_type = 'project'").first + if @first_page.show_course == 2 + render_404 + end + end diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 1cb3fa197..920cd9d4d 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -2,6 +2,7 @@ class HomeworkAttachController < ApplicationController layout "course_base" include CoursesHelper ############################### + before_filter :can_show_course,except: [] #判断当前角色权限时需先找到当前操作的project before_filter :find_course_by_bid_id, :only => [:new] before_filter :find_course_by_hoemwork_id, :only => [:edit,:update,:destroy,:show,:add_homework_users,:destory_homework_users] @@ -352,5 +353,13 @@ class HomeworkAttachController < ApplicationController } end end + + #验证是否显示课程 + def can_show_course + @first_page = FirstPage.where("page_type = 'project'").first + if @first_page.show_course == 2 + render_404 + end + end end diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index e974936eb..b364440c9 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -18,7 +18,7 @@ class MessagesController < ApplicationController menu_item :boards default_search_scope :messages - before_filter :find_board, :only => [:new, :preview] + before_filter :find_board, :only => [:new, :preview,:edit] before_filter :find_attachments, :only => [:preview] before_filter :find_message, :except => [:new, :preview] before_filter :authorize, :except => [:preview, :edit, :destroy, :new] @@ -85,7 +85,7 @@ class MessagesController < ApplicationController @reply.board = @board @reply.safe_attributes = params[:reply] @topic.children << @reply - @topic.update_attribute(:updated_on, Time.now) + #@topic.update_attribute(:updated_on, Time.now) if !@reply.new_record? call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply}) attachments = Attachment.attach_files(@reply, params[:attachments]) @@ -107,7 +107,15 @@ class MessagesController < ApplicationController flash[:notice] = l(:notice_successful_update) @message.reload redirect_to board_message_path(@message.board, @message.root, :r => (@message.parent_id && @message.id)) + elsif request.get? + respond_to do |format| + format.html { + layout_file = @project ? 'base_projects' : 'base_courses' + render :layout => layout_file + } + end end + end # Delete a messages diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index ca75f488b..b46bff2ff 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -16,6 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class ProjectsController < ApplicationController layout :select_project_layout + menu_item :overview menu_item :roadmap, :only => :roadmap menu_item :settings, :only => :settings @@ -102,6 +103,8 @@ class ProjectsController < ApplicationController end def index + #调用存储过程更新提交次数 + ActiveRecord::Base.connection.execute("CALL sp_project_status_cursor();") #Modified by nie @project_type = params[:project_type].to_i per_page_option = 10 @@ -149,6 +152,7 @@ class ProjectsController < ApplicationController end @projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page) + respond_to do |format| format.html { render :layout => 'base' @@ -447,24 +451,10 @@ class ProjectsController < ApplicationController end def new - @project_type = params[:project_type] ||= params[:course] @issue_custom_fields = IssueCustomField.sorted.all @trackers = Tracker.sorted.all - - case @project_type - when '0' # Project - @project = Project.new - @project.safe_attributes = params[:project] - when '1' # Course - @project = Project.new - @project.safe_attributes = params[:project] - @course_tag = params[:course] - @course = Course.new - @course.safe_attributes = params[:course] - else # default Project - @project = Project.new - @project.safe_attributes = params[:project] - end + @project = Project.new + @project.safe_attributes = params[:project] render :layout => 'base' end @@ -478,128 +468,43 @@ class ProjectsController < ApplicationController end def create - - @course_tag = params[:project][:project_type] - if(@course_tag=="1") - if User.current.user_extensions.identity#.include?(UserExtensions::TEACHER,UserExtensions::DEVELOPER) - @course = Course.new - @course.extra='course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s - @course.safe_attributes = params[:project][:course] - @course.tea_id = User.current.id - # added by bai - @course.term = params[:term] - @course.time = params[:time] - #@course.school_id = params[:occupation] - @course.school_id = User.current.user_extensions.school_id - @course.setup_time = params[:setup_time] - @course.endup_time = params[:endup_time] - @course.class_period = params[:class_period] - end - end @issue_custom_fields = IssueCustomField.sorted.all @trackers = Tracker.sorted.all @project = Project.new - @project.user_id = User.current.id - @project.dts_test = params[:project][:dts_test] @project.safe_attributes = params[:project] - if @course_tag == '1' - @project.identifier = @course.extra - end - if @course_tag == '1' - if User.current.user_extensions.identity == 0 - if@course.save - if validate_parent_id && @project.save - @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') - # Add current user as a project member if he is not admin - unless User.current.admin? - r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first - m = Member.new(:user => User.current, :roles => [r]) - project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id) - user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id) - if params[:project][:is_public] == '1' - project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :project_type => @course_tag) - end - @project.members << m - @project.project_infos << project - end - respond_to do |format| - format.html { - flash[:notice] = l(:notice_successful_create) - if params[:continue] - attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?} - redirect_to new_project_path(attrs, :course => '0') - #Added by young - - elsif params[:course_continue] - redirect_to new_project_path(:course => '1') - #Ended by young - else - redirect_to settings_project_path(@project,:project_type => 1) - end - } - format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) } - end + if validate_parent_id && @project.save + @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') + # Add current user as a project member if he is not admin + #unless User.current.admin? + r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first + m = Member.new(:user => User.current, :roles => [r]) + project_info = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id) + user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id) + Rails.logger.debug "UserGrade created: #{user_grades.to_json}" + if params[:project][:is_public] == '1' + project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => @project.project_type) + Rails.logger.debug "ProjectStatus created: #{project_status.to_json}" + end + @project.members << m + @project.project_infos << project_info + #end + respond_to do |format| + format.html { + flash[:notice] = l(:notice_successful_create) + if params[:continue] + attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?} + redirect_to new_project_path(attrs, :course => '0') else - @course.destroy - respond_to do |format| - format.html { render :action => 'new', :layout => 'base'}#Added by young - format.api { render_validation_errors(@project) } - end + redirect_to settings_project_path(@project) end - else - if validate_parent_id && @project.save - @project.delete - respond_to do |format| - format.html { render :action => 'new', :layout => 'base'}#Added by young - format.api { render_validation_errors(@project) } - end - else - respond_to do |format| - format.html { render :action => 'new', :layout => 'base'}#Added by young - format.api { render_validation_errors(@project) } - end - end - end + } + format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) } end else - #@project.memberships.create - if validate_parent_id && @project.save - @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') - # Add current user as a project member if he is not admin - #unless User.current.admin? - r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first - m = Member.new(:user => User.current, :roles => [r]) - project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id) - user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id) - if params[:project][:is_public] == '1' || @course_tag=="1" - project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => @project.project_type) - end - @project.members << m - @project.project_infos << project - #end - respond_to do |format| - format.html { - flash[:notice] = l(:notice_successful_create) - if params[:continue] - attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?} - redirect_to new_project_path(attrs, :course => '0') - #Added by young - - elsif params[:course_continue] - redirect_to new_project_path(:course => '1') - #Ended by young - else - redirect_to settings_project_path(@project) - end - } - format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) } - end - else - respond_to do |format| - format.html { render :action => 'new', :layout => 'base'}#Added by young - format.api { render_validation_errors(@project) } - end - end + respond_to do |format| + format.html { render :action => 'new', :layout => 'base'}#Added by young + format.api { render_validation_errors(@project) } + end end end @@ -833,7 +738,7 @@ class ProjectsController < ApplicationController def update @project.safe_attributes = params[:project] - @project.dts_test = params[:project][:dts_test] + #@project.dts_test = params[:project][:dts_test] if validate_parent_id && @project.save @course = Course.find_by_extra(@project.identifier) unless @course.nil? diff --git a/app/controllers/softapplications_controller.rb b/app/controllers/softapplications_controller.rb index 1808a3eaa..f2b0a0c83 100644 --- a/app/controllers/softapplications_controller.rb +++ b/app/controllers/softapplications_controller.rb @@ -172,8 +172,8 @@ class SoftapplicationsController < ApplicationController # PUT /softapplications/1.json def update # @softapplication = Softapplication.find(params[:id]) - @softapplication.attachments.map{|attach| attach.destroy } - @softapplication.save_attachments(params[:attachments]) + #@softapplication.attachments.map{|attach| attach.destroy } + @softapplication.save_attachments(params[:attachments]) if params[:attachments] #@softapplication.deposit_project = params[:project] @softapplication.project = Project.find_by_id(params[:project]) @@ -304,6 +304,36 @@ class SoftapplicationsController < ApplicationController end end + def search + @softapplications = Softapplication.where("name like '%#{params[:name]}%'") + + #new added fenyefunction + @limit = 5 + @softapplication_count = @softapplications.count + @softapplication_pages = Paginator.new @softapplication_count, @limit, params['page'] + @offset ||= @softapplication_pages.offset + + #new added sort + if params[:softapplication_sort_type].present? + case params[:softapplication_sort_type] + when '0' + @softapplications = @softapplications[@offset, @limit] + @s_state = 0 + when '1' + @softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit] + @s_state = 1 + end + else + @softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit] + @s_state = 1 + end + #new added end + + respond_to do |format| + format.html + end + end + private def find_softapplication @softapplication = Softapplication.find_by_id(params[:id]) diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index ba01aa990..1318e40a5 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -71,8 +71,8 @@ class TagsController < ApplicationController @projects_results, @issues_results, @bids_results, - @forums_results, - attachments_results, + @forums_results, + @attachments_results, @contests_results, @courses_results, @open_source_projects_results= refresh_results(@obj_id,@obj_flag,@selected_tags) @@ -107,8 +107,8 @@ class TagsController < ApplicationController @projects_results, @issues_results, @bids_results, - @forums_results, - attachments_results, + @forums_results, + @attachments_results, @contests_results, @courses_results, @open_source_projects_results= refresh_results(@obj_id,@show_flag) @@ -130,8 +130,8 @@ class TagsController < ApplicationController @projects_results, @issues_results, @bids_results, - @forums_results, - attachments_results, + @forums_results, + @attachments_results, @contests_results, @courses_results, @open_source_projects_results= refresh_results(@obj_id,@show_flag) @@ -199,7 +199,7 @@ class TagsController < ApplicationController @bids_results = nil @contests_results = nil @forums_results = nil - attachments_results = nil + @attachments_results = nil @open_source_projects_results = nil @obj_pages = nil @obj = nil @@ -228,8 +228,9 @@ class TagsController < ApplicationController # modifed by Long Jun # this is used to find the attachments that came from the same project and tagged with the same tag. - @result = get_attachments_by_project_tag(selected_tags, @obj) - @obj_pages, attachments_results, @results_count = for_pagination(@result) + #@result = get_attachments_by_project_tag(selected_tags, @obj) + @result = get_attachments_by_tag(selected_tags) + @obj_pages, @attachments_results, @results_count = for_pagination(@result) when '7' @obj = Contest.find_by_id(obj_id) @obj_pages,@contests_results,@results_count = for_pagination(get_contests_by_tag(selected_tags)) @@ -249,8 +250,8 @@ class TagsController < ApplicationController @projects_results, @issues_results, @bids_results, - @forums_results, - attachments_results, + @forums_results, + @attachments_results, @contests_results, @courses_results, @open_source_projects_results] diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a3bb96aa9..7220f3ccb 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -29,7 +29,7 @@ class UsersController < ApplicationController #Ended by young - + before_filter :can_show_course, :only => [:user_courses,:user_homeworks] before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_bids, :watch_contests, :info, :user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index, :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, @@ -41,6 +41,7 @@ class UsersController < ApplicationController :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, :activity_new_score_index, :influence_new_score_index, :score_new_index] before_filter :auth_user_extension, only: :show + #before_filter :rest_user_score, only: :show accept_api_auth :index, :show, :create, :update, :destroy,:tag_save , :tag_saveEx #william @@ -54,6 +55,7 @@ class UsersController < ApplicationController include AvatarHelper include WordsHelper include GitlabHelper + include UserScoreHelper # added by liuping 关注 @@ -263,9 +265,6 @@ class UsersController < ApplicationController sort_init 'login', 'asc' sort_update %w(login firstname lastname mail admin created_on last_login_on) - # Deprecation - @project_type = params[:project_type] - case params[:format] when 'xml', 'json' @offset, @limit = api_offset_and_limit({:limit => 15}) @@ -274,16 +273,9 @@ class UsersController < ApplicationController end # retrieve all users - scope = UserStatus.visible - - # if role has something, change scope. - case params[:role] - when 'teacher' - scope = UserStatus.teacher - when 'student' - scope = UserStatus.student - else - end + # 先内连一下statuses 保证排序之后数量一致 + scope = User.visible. + joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id") # unknow scope = scope.in_group(params[:group_id]) if params[:group_id].present? @@ -295,25 +287,32 @@ class UsersController < ApplicationController # users classify case params[:user_sort_type] when '0' + # 创建时间排序 @s_type = 0 - @us_ordered = scope. - joins("LEFT JOIN users ON user_statuses.user_id = users.id"). - reorder('users.created_on DESC') + @users = scope.reorder('users.created_on DESC') when '1' + # 活跃度排序, 就是所谓的得分情况 @s_type = 1 - @us_ordered = scope.reorder('user_statuses.grade DESC') + @users = scope. + joins("LEFT JOIN user_scores ON users.id = user_scores.user_id"). + reorder('user_scores.active DESC') when '2' + # 粉丝数排序 @s_type = 2 - @us_ordered = scope.reorder('user_statuses.watchers_count DESC') + @users = scope. + #joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id"). + reorder('user_statuses.watchers_count DESC') + else + # 默认活跃度排序 @s_type = 1 - @us_ordered = scope.reorder('user_statuses.grade DESC') + @users = scope. + joins("LEFT JOIN user_scores ON users.id = user_scores.user_id"). + reorder('user_scores.active DESC') end # limit and offset - @users_statuses = @us_ordered.offset(@user_pages.offset).limit(@user_pages.per_page) - # get users ActiveRecord - @users = @users_statuses.includes(:user).map(&:user) + @users = @users.limit(@user_pages.per_page).offset(@user_pages.offset) @user_base_tag = params[:id] ? 'base_users':'users_base' respond_to do |format| @@ -784,4 +783,25 @@ class UsersController < ApplicationController redirect_to my_account_path end end + + #重置用户得分 + def rest_user_score + memo_num(@user) + messges_for_issue_num(@user) + issues_status_num(@user) + replay_for_memo_num(@user) + tread_num(@user) + praise_num(@user) + changeset_num(@user) + document_num(@user) + + end + + #验证是否显示课程 + def can_show_course + @first_page = FirstPage.where("page_type = 'project'").first + if @first_page.show_course == 2 + render_404 + end + end end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 0cca7be6e..c7cbf217d 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -18,12 +18,14 @@ class WelcomeController < ApplicationController include ApplicationHelper include WelcomeHelper + caches_action :robots # before_filter :fake, :only => [:index, :course] before_filter :entry_select, :only => [:index] def index @first_page = FirstPage.where("page_type = 'project'").first + #@show_course = @first_page.show_course if @first_page.nil? || @first_page.sort_type.nil? @projects = find_miracle_project(10, 3,"grade desc") else @@ -146,16 +148,27 @@ class WelcomeController < ApplicationController private # 判断网站的入口,是课程 course 则跳过index去渲染 course 方法 def entry_select + @first_page = FirstPage.where("page_type = 'project'").first url = request.original_url - if url.include?("course.trustie.net") - course - render :course + if url.include?(Setting.host_course) + if @first_page.show_course == 1 + course + render :course + else + render_404 + end + return 0 - elsif url.include?("contest.trustie.net") - contest - render :contest + elsif url.include?(Setting.host_contest) + if @first_page.show_contest == 1 + contest + render :contest + else + render_404 + end + return 0 - elsif url.include?("user.trustie.net") + elsif url.include?(Setting.host_user) redirect_to(:controller => "users", :action => "index") end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b6cd47924..9f8b8fff5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -68,6 +68,10 @@ module ApplicationHelper link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action]) end + def link_to_if_authorized_course(name, options = {}, html_options = nil, *parameters_for_method_reference) + link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for_course(options[:controller] || params[:controller], options[:action]) + end + def link_to_if_authorized_contest(name, options = {}, html_options = nil, *parameters_for_method_reference) link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for_contest(options[:controller] || params[:controller], options[:action]) end @@ -823,8 +827,11 @@ module ApplicationHelper def select_option_helper option tmp = Hash.new tmp={"" => ""} - option.each do |project| - tmp[project.name] = project.id + if option.nil? + else + option.each do |project| + tmp[project.name] = project.id + end end tmp end @@ -1168,25 +1175,27 @@ module ApplicationHelper objects = objects.first end # end - objects = objects.map {|o| o.is_a?(String) ? instance_variable_get("@#{o}") : o}.compact - errors = objects.map {|o| o.errors.full_messages}.flatten - if errors.any? - html << "
\n" end html.html_safe end @@ -1729,18 +1738,18 @@ module ApplicationHelper #@nav_dispaly_project_label nav_list = Array.new - nav_list.push(school_all_school_link) if @nav_dispaly_course_all_label - nav_list.push(course_all_course_link) if @nav_dispaly_course_all_label - nav_list.push(course_teacher_all_link) if @nav_dispaly_teacher_all_label + nav_list.push(school_all_school_link) if @nav_dispaly_course_all_label && @show_course == 1 + nav_list.push(course_all_course_link) if @nav_dispaly_course_all_label && @show_course == 1 + nav_list.push(course_teacher_all_link) if @nav_dispaly_teacher_all_label && @show_course == 1 nav_list.push(main_project_link) if @nav_dispaly_main_project_label - nav_list.push(main_course_link) if @nav_dispaly_main_course_label - nav_list.push(main_contest_link) if @nav_dispaly_main_contest_label + nav_list.push(main_course_link) if @nav_dispaly_main_course_label && @show_course == 1 + nav_list.push(main_contest_link) if @nav_dispaly_main_contest_label && @show_contest == 1 - nav_list.push(courses_link) if @nav_dispaly_course_label + 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(contest_link) if @nav_dispaly_contest_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 nav_list.push(stores_link) if @nav_dispaly_store_all_label diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index b43eb22f1..ee9d2a70d 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -87,8 +87,9 @@ module AttachmentsHelper @project_id = obj.container_id end - Attachment.tagged_with(tag_name).order('created_on desc').where("(container_id = :project_id and container_type = 'Project') or + attachments = Attachment.tagged_with(tag_name).order('created_on desc').where("(container_id = :project_id and container_type = 'Project') or (container_id in (select id from versions where project_id =:project_id) and container_type = 'Version')", {:project_id => @project_id}) + return attachments end diff --git a/app/helpers/user_score_helper.rb b/app/helpers/user_score_helper.rb index 720919369..ba055ddf4 100644 --- a/app/helpers/user_score_helper.rb +++ b/app/helpers/user_score_helper.rb @@ -408,19 +408,47 @@ module UserScoreHelper update_score(option_number) end + #发帖数 + def memo_num(user,project=nil) + if project.nil? + Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id != -1").all.count + else + Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id = #{project.id}").all.count + end + + end + #更新对缺陷留言数 def update_messges_for_issue(user,type) option_number = get_option_number(user,type) - option_number.messages_for_issues = Journal.includes(:user).where("user_id = '#{user.id}'").all.count + option_number.messages_for_issues = Journal.includes(:user).where("user_id = '#{user.id}' and notes != '' and notes is not null").all.count update_score(option_number) end + def messges_for_issue_num(user,project=nil) + if project.nil? + Journal.includes(:user).where("user_id = '#{user.id}' and notes != '' and notes is not null").all.count + else + Journal.includes(:user).joins(:issue).where("#{Journal.table_name}.user_id = '#{user.id}' and #{Issue.table_name}.project_id = '#{project.id}' and #{Journal.table_name}.notes != '' and #{Journal.table_name}.notes is not null").all.count + end + end + #更新更改缺陷状态状态次数 def update_issues_status(user,type) option_number = get_option_number(user,type) option_number.issues_status = Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count update_score(option_number) end + + def issues_status_num(user,project=nil) + if project.nil? + Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count + else + Journal.joins(:issue,:details,:user).where("#{Issue.table_name}.project_id = '#{project.id}' and #{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count + end + + end + #更新对留言的回复数量 def update_replay_for_message(user,type) option_number = get_option_number(user,type) @@ -428,13 +456,25 @@ module UserScoreHelper update_score(option_number) end + def replay_for_message_num(user) + JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id}").count + end + #更新对帖子的回复数量 def update_replay_for_memo(user,type) option_number = get_option_number(user,type) - option_number.replay_for_memo = Message.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count + Memo.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count + option_number.replay_for_memo = Message.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count #+ Memo.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count update_score(option_number) end + def replay_for_memo_num(user,project=nil) + if project.nil? + Message.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count + else + Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NOT NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id = #{project.id}").all.count + end + end + #更新被关注的人数 def update_follow(user,type) option_number = get_option_number(user,type) @@ -442,11 +482,15 @@ module UserScoreHelper update_score(option_number) end + def follow_num(user) + Watcher.includes(:watchable).where("watchable_type = 'Principal' and watchable_id = '#{user.id}'").count + end + #更新帖子踩各项数量 def update_tread(user,type) option_number = get_option_number(user,type) - option_number.tread = PraiseTread.where("praise_tread_object_type = 'Memo' || praise_tread_object_type = 'Message' and praise_or_tread = 0 and user_id = '#{user.id}'").all.count - pts = PraiseTread.where("praise_tread_object_type = 'Memo' || praise_tread_object_type = 'Message' and praise_or_tread = 0").all + option_number.tread = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0 and user_id = '#{user.id}'").all.count + pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0").all result = [] result1 = [] result2 = [] @@ -472,10 +516,64 @@ module UserScoreHelper update_score(option_number) end + def tread_num(user,project=nil) + if project.nil? + result0 = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0 and user_id = '#{user.id}'").all.count + pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0").all + result = [] + result1 = [] + result2 = [] + pts.each do |pt| + obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id) + if obj.nil? + next + end + target_user = obj.author + level = UserLevels.get_level(pt.user)#pt.user.get_level + project = pt.project + if level == 1 && target_user.id = user.id + result << pt + elsif level == 2 && target_user.id = user.id + result1 << pt + elsif level == 3 && target_user.id = user.id + result2 << pt + end + end + [:tread=>result0,:tead_by_one => result.count,:tread_by_two => result1.count,:tread_by_three =>result2.count] + else + result0 = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0 and user_id = '#{user.id}'").all.count + pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0").all + result = [] + result1 = [] + result2 = [] + pts.each do |pt| + obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id) + if obj.nil? + next + end + if !(pt.praise_tread_object_type == "Issue" && obj.project.id == project.id) && !(pt.praise_tread_object_type == "Message" && obj.board.project.id == project.id) + next + end + target_user = obj.author + level = UserLevels.get_level(pt.user)#pt.user.get_level + project = pt.project + if level == 1 && target_user.id = user.id + result << pt + elsif level == 2 && target_user.id = user.id + result1 << pt + elsif level == 3 && target_user.id = user.id + result2 << pt + end + end + [:tread=>result0,:tead_by_one => result.count,:tread_by_two => result1.count,:tread_by_three =>result2.count] + end + + end + #更新帖子顶数量 def update_praise(user,type) option_number = get_option_number(user,type) - pts = PraiseTread.where("praise_tread_object_type = 'Memo' || praise_tread_object_type = 'Message' and praise_or_tread = 1").all + pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 1").all result = [] result1 = [] result2 = [] @@ -501,6 +599,58 @@ module UserScoreHelper update_score(option_number) end + def praise_num(user,project=nil) + if project.nil? + pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 1").all + result = [] + result1 = [] + result2 = [] + pts.each do |pt| + obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id) + if obj.nil? + next + end + if !(pt.praise_tread_object_type == "Issue" && obj.project.id == project.id) && !(pt.praise_tread_object_type == "Message" && obj.board.project.id == project.id) + next + end + target_user = obj.author + level = UserLevels.get_level(pt.user)#pt.user.get_level + project = pt.project + if level == 1 && target_user.id = user.id + result << pt + elsif level == 2 && target_user.id = user.id + result1 << pt + elsif level == 3 && target_user.id = user.id + result2 << pt + end + end + [:praise_by_one => result.count,:praise_by_two => result1.count,:praise_by_three => result2.count] + else + pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 1").all + result = [] + result1 = [] + result2 = [] + pts.each do |pt| + obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id) + if obj.nil? + next + end + target_user = obj.author + level = UserLevels.get_level(pt.user)#pt.user.get_level + project = pt.project + if level == 1 && target_user.id = user.id + result << pt + elsif level == 2 && target_user.id = user.id + result1 << pt + elsif level == 3 && target_user.id = user.id + result2 << pt + end + end + [:praise_by_one => result.count,:praise_by_two => result1.count,:praise_by_three => result2.count] + end + + end + #更新提交代码次数 def update_changeset(user,type) option_number = get_option_number(user,type) @@ -508,6 +658,15 @@ module UserScoreHelper update_score(option_number) end + def changeset_num(user,project=nil) + if project.nil? + Changeset.includes(:user).where("user_id = '#{user.id}'").all.count + else + Changeset.includes(:user).joins(:repository).where("#{Changeset.table_name}.user_id = '#{user.id}' and #{Repository.table_name}.project_id = #{project.id}").all.count + end + + end + #更新文档提交次数 def update_document(user,type) option_number = get_option_number(user,type) @@ -515,12 +674,30 @@ module UserScoreHelper update_score(option_number) end + def document_num(user,project=nil?) + if project.nil? + Document.includes(:user).where("user_id = '#{user.id}'").all.count + else + Document.includes(:user,:project).where("user_id = '#{user.id}' and project_id = '#{project.id}'").all.count + end + + end + #更新附件提交数量 def update_attachment(user,type) option_number = get_option_number(user,type) option_number.attachment = Attachment.includes(:author).where("author_id = '#{user.id}'").all.count update_score(option_number) end + #===================here to continue============================ + def attachment_num(user,project=nil) + if project.nil? + Attachment.includes(:author).where("author_id = '#{user.id}'").all.count + else + Attachment.includes(:author,:container).where("author_id = '#{user.id}' and container_type = 'Project' and container_id = #{project.id}").all.count + end + + end #更新缺陷完成度次数 def update_issue_done_ratio(user,type) @@ -529,10 +706,18 @@ module UserScoreHelper update_score(option_number) end + def issue_done_ratio_num(user,project) + Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'done_ratio' and #{User.table_name}.id = '#{user.id}'").count + end + #更新发布缺陷次数 def update_post_issue(user,type) option_number = get_option_number(user,type) option_number.post_issue = Issue.includes(:author).where("author_id = '#{user.id}'").all.count update_score(option_number) end + + def post_issue_num(user,project=nil) + Issue.includes(:author).where("author_id = '#{user.id}'").all.count + end end diff --git a/app/models/contest.rb b/app/models/contest.rb index e1706b166..f1503f593 100644 --- a/app/models/contest.rb +++ b/app/models/contest.rb @@ -6,7 +6,7 @@ class Contest < ActiveRecord::Base has_many :contesting_projects, :dependent => :destroy has_many :projects, :through => :contesting_projects has_many :contesting_softapplications, :dependent => :destroy - has_many :softapplications, :through => :contesting_softapplications + has_many :softapplications, :through => :contesting_softapplications, :dependent => :destroy has_many :projects_member, :class_name => 'User', :through => :projects has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy diff --git a/app/models/contesting_softapplication.rb b/app/models/contesting_softapplication.rb index f880818d9..f91c16f69 100644 --- a/app/models/contesting_softapplication.rb +++ b/app/models/contesting_softapplication.rb @@ -3,7 +3,7 @@ class ContestingSoftapplication < ActiveRecord::Base attr_accessible :contest_id, :description, :softapplication_id, :user_id belongs_to :contest - belongs_to :softapplication + belongs_to :softapplication, :dependent => :destroy belongs_to :user diff --git a/app/models/issue.rb b/app/models/issue.rb index 83e7f8479..1978f5405 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -79,6 +79,7 @@ class Issue < ActiveRecord::Base # fq after_create :act_as_activity,:be_user_score_new_issue after_update :be_user_score + before_destroy :down_user_score # after_create :be_user_score # end @@ -1524,5 +1525,19 @@ class Issue < ActiveRecord::Base update_post_issue(self.author,1) end + def down_user_score + #缺陷完成度更新 + if self.done_ratio_changed? + UserScore.project(:update_issue_ratio, User.current,self,{ issue_id: self.id }) + #update_issue_done_ratio(User.current,1) + end + #缺陷状态更改 + if self.status_id_changed? + #协同得分 + UserScore.joint(:change_issue_status, User.current,nil,self, {issue_id: self.id}) + #update_issues_status(self.author , 1) + end + end + end diff --git a/app/models/issue_overdue.rb b/app/models/issue_overdue.rb new file mode 100644 index 000000000..5caec94c9 --- /dev/null +++ b/app/models/issue_overdue.rb @@ -0,0 +1,33 @@ +class IssueOverdue < ActiveRecord::Base +#缺陷到期后发送邮件提示 +#只监听已经提交的未到期的缺陷,已过期的缺陷默认已经发过邮件通知,不再提醒。 + def self.mail_issue + threads = [] + issues = Issue.where("done_ratio <> 100 and closed_on is null and due_date is not null") + puts issues + issues.each do |issue| + thread = Thread.new do + while true + cur_issue = Issue.find issue.id + if cur_issue.done_ratio == 100 || cur_issue.closed_on != nil + break + end + if Time.now < Time.parse(cur_issue.due_date.to_s) + #休眠一个小时。。。 + puts cur_issue.id.to_s + sleep 5 + else + #发邮件 + #puts "11" + issue.id.to_s + #Mailer.issue_expire(issue).deliver + Mailer.issue_add(issue).deliver + break + end + end + end + threads << thread + end + puts threads + return threads + end +end \ No newline at end of file diff --git a/app/models/journal.rb b/app/models/journal.rb index 8d03f2325..c08d8d630 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -48,9 +48,9 @@ class Journal < ActiveRecord::Base # fq after_create :act_as_activity,:be_user_score # end - + #after_destroy :down_user_score #before_save :be_user_score - #before_destroy :down_user_score + before_destroy :down_user_score scope :visible, lambda {|*args| user = args.shift || User.current @@ -158,19 +158,20 @@ class Journal < ActiveRecord::Base # 更新用户分数 -by zjc def be_user_score - #新建了缺陷留言且留言不为空,不为空白 + #新建了缺陷留言且留言不为空,不为空白 if !self.notes.nil? && self.notes.gsub(' ','') != '' #协同得分加分 - UserScore.joint(:post_issue_message, User.current,self.issue.author,self, { message_id: self.id }) - update_messges_for_issue(User.current,1) + UserScore.joint(:post_issue_message, self.user,self.issue.author,self, { message_id: self.id }) end + #update_messges_for_issue(User.current,1) end # 减少用户分数 -by zjc def down_user_score #删除有效缺陷留言 if !self.notes.nil? && self.notes.gsub(' ','') != '' #协同得分减分 - UserScore.joint(:delete_issue_message, User.current,self.issue.author, { message_id: self.id }) + UserScore.joint(:delete_issue_message, self.user,self.issue.author,self, { message_id: self.id }) end + #update_messges_for_issue(User.current,1) end end diff --git a/app/models/journal_detail.rb b/app/models/journal_detail.rb index 4100a5b1c..c2b0aaa2a 100644 --- a/app/models/journal_detail.rb +++ b/app/models/journal_detail.rb @@ -20,6 +20,8 @@ class JournalDetail < ActiveRecord::Base belongs_to :journal before_save :normalize_values after_create :be_user_score + #after_destroy :down_user_score + before_destroy :down_user_score private def normalize_values @@ -42,11 +44,24 @@ class JournalDetail < ActiveRecord::Base def be_user_score #更新缺陷完成度 - if self.prop_key = 'done_ratio' - update_issue_done_ratio(User.current,1) + if self.prop_key == 'done_ratio' + #update_issue_done_ratio(User.current,1) #更新缺陷状态 - elsif self.prop_key = 'status_id' - update_issues_status(User.current , 1) + elsif self.prop_key == 'status_id' + #update_issues_status(User.current , 1) + end + end + + #更新用户分数 + def down_user_score + #update_issue_done_ratio(User.current,1) + #update_issues_status(User.current , 1) + + if self.prop_key == 'done_ratio' + + #更新缺陷状态 + elsif self.prop_key == 'status_id' + UserScore.joint(:delete_issue_status, self.journal.user,nil,self, {issue_id: self.id}) end end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 4debe668f..c79004794 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -68,6 +68,7 @@ class JournalsForMessage < ActiveRecord::Base return true end end + def self.remove_by_user? user if( self.user == user || @@ -87,6 +88,15 @@ class JournalsForMessage < ActiveRecord::Base def reference_user User.find(reply_id) end + + def delete_by_user?user + # 用户可删除自己的留言 + if self.user.id == user.id || user.admin? + return true + else + return false + end + end def self.reference_message(user_id) @user = User.find(user_id) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index ecc7a8d91..f6c5e1a9e 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -104,7 +104,7 @@ class Mailer < ActionMailer::Base message_id issue @author = issue.author @issue = issue - @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue) + @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id) recipients = issue.recipients cc = issue.watcher_recipients - recipients mail :to => recipients, @@ -167,12 +167,6 @@ class Mailer < ActionMailer::Base #缺陷到期邮件通知 def issue_expire issue - #@issues = issues - #s = l(:text_issue_expire,:issue => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}") - #puts s + "////" + issue.assigned_to.mail - #@issues_url = url_for(:controller => 'issues', :action => 'show',:id => issue.id) - #mail :to => issue.assigned_to.mail, - # :subject => s issue_id = issue.project_index redmine_headers 'Project' => issue.project.identifier, 'Issue-Id' => issue_id, @@ -181,12 +175,34 @@ class Mailer < ActionMailer::Base message_id issue @author = issue.author @issue = issue - @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue) + @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id) recipients = issue.recipients - cc = issue.watcher_recipients - recipients + s = l(:text_issue_expire,:issue => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}") mail :to => recipients, - :cc => cc, - :subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}" + :subject => s + ######################################################################################################### + #@issues = issues + #s = l(:text_issue_expire,:issue => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}") + #puts s + "////" + issue.assigned_to.mail + #@issues_url = url_for(:controller => 'issues', :action => 'show',:id => issue.id) + #mail :to => issue.assigned_to.mail, + # :subject => s + ######################################################################################################### + #issue_id = issue.project_index + #redmine_headers 'Project' => issue.project.identifier, + # 'Issue-Id' => issue_id, + # 'Issue-Author' => issue.author.login + #redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to + #message_id issue + #@author = issue.author + #@issue = issue + #@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue) + #recipients = issue.recipients + #cc = issue.watcher_recipients - recipients + #mail :to => recipients, + # :cc => cc, + # :subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}" + ###################################################################################################### end @@ -566,34 +582,7 @@ class Mailer < ActionMailer::Base end end - #缺陷到期后发送邮件提示 - def mail_issue - threads = [] - issues = Issue.where("done_ratio <> 100 && closed_on is null && due_date is not null") - issues.each do |issue| - thread = Thread.start do - while true - cur_issue = Issue.find issue.id - if cur_issue.done_ratio == 100 || cur_issue.closed_on != nil - break - end - if Time.now < Time.parse(cur_issue.due_date.to_s) - #休眠一个小时。。。 - sleep 3600 - else - #发邮件 - puts issue.id.to_s - Mailer.issue_expire(issue).deliver - #Mailer.issue_add(issue).deliver - break - end - end - end - threads << thread - end - puts threads.count.to_s - threads - end + private diff --git a/app/models/memo.rb b/app/models/memo.rb index 6370065ba..1d191e39d 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -42,9 +42,9 @@ class Memo < ActiveRecord::Base "parent_id", "replies_count" - after_create :add_author_as_watcher, :reset_counters!,:be_user_score + after_create :add_author_as_watcher, :reset_counters!#,:be_user_score -- 公共区发帖暂不计入得分 # after_update :update_memos_forum - after_destroy :reset_counters! + after_destroy :reset_counters!#,:down_user_score -- 公共区发帖暂不计入得分 # after_create :send_notification # after_save :plusParentAndForum # after_destroy :minusParentAndForum @@ -157,4 +157,10 @@ class Memo < ActiveRecord::Base end end + #被删除时更新用户分数 + def down_user_score + update_memo_number(User.current,1) + update_replay_for_memo(User.current,1) + end + end diff --git a/app/models/message.rb b/app/models/message.rb index 2c183dc59..a57797af1 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -59,12 +59,12 @@ class Message < ActiveRecord::Base after_create :add_author_as_watcher, :reset_counters! after_update :update_messages_board - after_destroy :reset_counters! + after_destroy :reset_counters!#,:down_user_score # fq after_create :act_as_activity,:be_user_score #before_save :be_user_score - #before_destroy :down_user_score + before_destroy :down_user_score # end scope :visible, lambda {|*args| @@ -149,23 +149,24 @@ class Message < ActiveRecord::Base #更新用户分数 -by zjc def be_user_score #新建message且无parent的为发帖 - if self.parent_id.nil? - UserScore.joint(:post_message, User.current,nil,self, { message_id: self.id }) - update_memo_number(User.current,1) + if self.parent_id.nil? && !self.board.project.nil? + UserScore.joint(:post_message, self.author,nil,self, { message_id: self.id }) + #update_memo_number(User.current,1) #新建message且有parent的为回帖 - elsif !self.parent_id.nil? - UserScore.joint(:reply_posting, User.current,self.parent.author,self, { message_id: self.id }) - update_replay_for_memo(User.current,1) + elsif !self.parent_id.nil? && !self.board.project.nil? + UserScore.joint(:reply_posting, self.author,self.parent.author,self, { message_id: self.id }) + #update_replay_for_memo(User.current,1) end end + #减少用户分数 def down_user_score - #删除发帖 - if self.parent_id.nil? - UserScore.joint(:delete_message, User.current,nil, { message_id: self.id }) - #删除留言 - else - UserScore.joint(:reply_deleting, User.current,self.parent.author, { message_id: self.id }) + if self.parent_id.nil? && !self.board.project.nil? + UserScore.joint(:delete_message, self.author,nil,self, { message_id: self.id }) + elsif !self.parent_id.nil? && !self.board.project.nil? + UserScore.joint(:reply_deleting, self.author,self.parent.author,self, { message_id: self.id }) end + #update_memo_number(User.current,1) + #update_replay_for_memo(User.current,1) end end diff --git a/app/models/project.rb b/app/models/project.rb index d6283e44f..1a2c0504d 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -758,6 +758,7 @@ class Project < ActiveRecord::Base 'tracker_ids', 'issue_custom_field_ids', 'project_type', + 'dts_test', 'attachmenttype' diff --git a/app/models/softapplication.rb b/app/models/softapplication.rb index 770d70d53..a572a22ba 100644 --- a/app/models/softapplication.rb +++ b/app/models/softapplication.rb @@ -11,6 +11,10 @@ class Softapplication < ActiveRecord::Base belongs_to :project has_many :contests, :through => :contesting_softapplications + validates_length_of :name, :maximum => 125 + validates_length_of :application_developers, :maximum => 125 + validates_length_of :android_min_version_available, :maximum => 125 + def add_jour(user, notes, reference_user_id = 0, options = {}) if options.count == 0 self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id) diff --git a/app/models/user_score.rb b/app/models/user_score.rb index 6371fc12d..219c7e8e5 100644 --- a/app/models/user_score.rb +++ b/app/models/user_score.rb @@ -69,10 +69,11 @@ class UserScore < ActiveRecord::Base end create_score_changed_details({:current_user_id => current_user.id ,:score_type => "collaboration",:score_action => "post_message",:user_id => current_user.id,:old_score => user_score.collaboration - 2,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a message. options => (#{options.to_s})" - #when :delete_message # current_user 删帖了 Delete Message - # user_score.collaboration = user_score.collaboration.to_i - 2 - # user_score.save - # Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a message. options => (#{options.to_s})" + when :delete_message # current_user 删帖了 Delete Message + user_score.collaboration = user_score.collaboration.to_i - 2 + user_score.save + create_score_changed_details({:current_user_id => current_user.id ,:score_type => "collaboration",:score_action => "post_message",:user_id => current_user.id,:old_score => user_score.collaboration + 2,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) + Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a message. options => (#{options.to_s})" when :post_issue_message # current_user 对 target_user 的缺陷留言了 Add Journal user_score.collaboration = user_score.collaboration.to_i + 1 user_score.save @@ -81,11 +82,12 @@ class UserScore < ActiveRecord::Base user_grade.save end create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "collaboration",:score_action => "post_issue_message",:user_id => current_user.id,:old_score => user_score.collaboration - 1,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) - Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a issue. options => (#{options.to_s})" - #when :delete_issue_message # current_user 删除了 对 target_user 的缺陷留言了 Delete Journal - # user_score.collaboration = user_score.collaboration.to_i - 1 - # user_score.save - # Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a issue. options => (#{options.to_s})" + Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a issue message. options => (#{options.to_s})" + when :delete_issue_message # current_user 删除了 对 target_user 的缺陷留言了 Delete Journal + user_score.collaboration = user_score.collaboration.to_i - 1 + user_score.save + create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "collaboration",:score_action => "delete_issue_message",:user_id => current_user.id,:old_score => user_score.collaboration + 1,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) + Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a issue message. options => (#{options.to_s})" when :change_issue_status # current_user 更改了缺陷的状态 Changed Issue user_score.collaboration = user_score.collaboration.to_i + 1 user_score.save @@ -95,6 +97,11 @@ class UserScore < ActiveRecord::Base end create_score_changed_details({:current_user_id => current_user.id , :score_type => "collaboration",:score_action => "change_issue_status",:user_id => current_user.id,:old_score => user_score.collaboration - 1,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) Rails.logger.info "[UserScore#joint] ===> User: #{current_user} change issue status. options => (#{options.to_s})" + when :delete_issue_status + user_score.collaboration = user_score.collaboration.to_i - 1 + user_score.save + create_score_changed_details({:current_user_id => current_user.id , :score_type => "collaboration",:score_action => "delete_issue_status",:user_id => current_user.id,:old_score => user_score.collaboration + 1,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) + Rails.logger.info "[UserScore#joint] ===> User: #{current_user} delete issue status. options => (#{options.to_s})" when :reply_message # current_user 对 target_user 留言的回复 Add Journals_for_messages user_score.collaboration = user_score.collaboration.to_i + 1 user_score.save @@ -117,10 +124,10 @@ class UserScore < ActiveRecord::Base end create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "collaboration",:score_action => "reply_posting",:user_id => current_user.id,:old_score => user_score.collaboration - 1,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply posting. options => (#{options.to_s})" - #when :reply_deleting # current_user 删除了 对 target_user 帖子的回复 Delete Message - # user_score.collaboration = user_score.collaboration.to_i - 1 - # user_score.save - # Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply deleting. options => (#{options.to_s})" + when :reply_deleting # current_user 删除了 对 target_user 帖子的回复 Delete Message + user_score.collaboration = user_score.collaboration.to_i - 1 + user_score.save + Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply deleting. options => (#{options.to_s})" else Rails.logger.error "[UserScore#joint] ===> #{operate} is not define." return false @@ -329,6 +336,11 @@ class UserScore < ActiveRecord::Base end create_score_changed_details({:current_user_id => current_user.id , :score_type => "active",:score_action => "update_issue_ratio",:user_id => current_user.id,:old_score => user_score.active - 2,:new_score => user_score.active,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] updated issue ratio. options => (#{options.to_s})" + when :delete_issue_ratio + user_score.active = user_score.active.to_i - 2 + user_score.save + create_score_changed_details({:current_user_id => current_user.id , :score_type => "active",:score_action => "delete_issue_ratio",:user_id => current_user.id,:old_score => user_score.active + 2,:new_score => user_score.active,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) + Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] delete issue ratio. options => (#{options.to_s})" when :post_issue # current_user 发布了缺陷 issue user_score.active = user_score.active.to_i + 4 user_score.save diff --git a/app/views/admin/first_page_made.html.erb b/app/views/admin/first_page_made.html.erb index b83e54db1..8cb5b3716 100644 --- a/app/views/admin/first_page_made.html.erb +++ b/app/views/admin/first_page_made.html.erb @@ -27,24 +27,35 @@ <%= text_field_tag 'image_height', params[:label_imgae_height], :value => @first_page.image_height,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>

- +

+ + +

+

+ + +

+

+ + +

<%= text_area 'first_page', 'description', :value => @first_page.description,:cols => 80, :rows => 15, :class => 'wiki-edit' %> <%= wikitoolbar_for 'first_page_description' %>

-

- - -

+ <%= submit_tag l(:button_save), :class => "small", :name => nil %> <% end %> diff --git a/app/views/admin/index.html.erb b/app/views/admin/index.html.erb index f8447590c..a1efc32fc 100644 --- a/app/views/admin/index.html.erb +++ b/app/views/admin/index.html.erb @@ -1,6 +1,6 @@

<%=l(:label_administration)%>

- + <%= render :partial => 'menu' %>
diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index 52b090bd8..cdd1fdd2f 100644 --- a/app/views/attachments/_links.html.erb +++ b/app/views/attachments/_links.html.erb @@ -1,6 +1,9 @@
<% for attachment in attachments %> -

<%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%> +

+ + <%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%> + <% if attachment.is_text? %> <%= link_to image_tag('magnifier.png'), :controller => 'attachments', :action => 'show', @@ -15,11 +18,20 @@ :method => :delete, :class => 'delete', :title => l(:button_delete) %> - <% else %> + <%# elsif attachment.container_type == 'Softapplication'%> + <%#= link_to image_tag('delete.png'), delete_softapplications_attachments_path(:id => attachment.id), + :data => {:confirm => l(:text_are_you_sure)}, + :method => :delete, + :class => 'delete', + :remote => true, + :title => l(:button_delete) %> + <% else %> <%= link_to image_tag('delete.png'), attachment_path(attachment), :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :class => 'delete', + :remote => true, + #:id => "attachments_" + attachment.id.to_s, :title => l(:button_delete) %> <% end %> <% end %> diff --git a/app/views/attachments/delete_softapplications.js.erb b/app/views/attachments/delete_softapplications.js.erb new file mode 100644 index 000000000..95085ba93 --- /dev/null +++ b/app/views/attachments/delete_softapplications.js.erb @@ -0,0 +1,2 @@ +<% options = {:author => true, :deletable => true} %> +$("#soft_attachments_links").html('<%= escape_javascript(render(:partial => 'links', :locals => {:attachments => @softapplication.attachments, :options => options} )) %>'); \ No newline at end of file diff --git a/app/views/auto_completes/issues.html.erb b/app/views/auto_completes/issues.html.erb index b097eaff4..1df31e41b 100644 --- a/app/views/auto_completes/issues.html.erb +++ b/app/views/auto_completes/issues.html.erb @@ -1,6 +1,6 @@ <%= raw @issues.map {|issue| { 'id' => issue.id, - 'label' => "#{issue.tracker} ##{issue.id}: #{truncate issue.subject.to_s, :length => 60}", + 'label' => "#{issue.tracker} ##{issue.project_index}: #{truncate issue.subject.to_s, :length => 60}", 'value' => issue.id } }.to_json diff --git a/app/views/contests/_new_softapplication.html.erb b/app/views/contests/_new_softapplication.html.erb new file mode 100644 index 000000000..c83bdf6e9 --- /dev/null +++ b/app/views/contests/_new_softapplication.html.erb @@ -0,0 +1,98 @@ +<%#= error_messages_for 'softapplication' %> +<%= form_for Softapplication.new, :url => softapplications_path do |f| %> +

+ <%= hidden_field_tag 'contest_id', @contest.id %> + + <%= l(:label_work_name) %> + * : + <%= f.text_field :name, :required => true, :size => 60, :style => "width:350px;" %> + (<%= l(:label_workname_lengthlimit) %>) + +
+
+
+ + + <%= l(:label_running_platform) %> + * : + + <%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:350px;" %> + + (<%= l(:label_workdescription_lengthlimit) %>) + +
+
+
+ + + <%= l(:label_work_type) %> + * : + + + <%#= select_tag 'app_type_name', work_type_opttion, {:name => 'app_type_name',:style => "width:358px;"} %> + + <%= f.select :app_type_name,work_type_opttion, {},{:style => "width:358px;",:onchange => "selectChange(this)"} %> + <%#= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %> + + + +
+
+
+ + + <%= l(:label_work_description) %> + * : + <%= f.text_field :description, :required => true, :size => 60, :style => "width:350px;" %> + + +
+
+
+ + + <%= l(:label_softapplication_developers) %> + * : + <%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:350px;" %> + (<%= l(:label_workdescription_lengthlimit) %>) + +
+
+
+ + + <%= l(:label_work_deposit_project) %>: + <%= select_tag 'project', options_for_select(select_option_helper(@option)), :name => 'project', :class => 'grayline2',:style => "width:358px;" %> + <%= link_to l(:label_create_new_projects),{:controller => 'projects',:action => 'new',course: 0, project_type: 0,host: Setting.project_domain}, :target => '_blank' %> + +
+
+
+ +
+ + <%= l(:label_upload_softworkpacket_photo) %> + + <%#= render_flash_messages %> +

+ <%= render :partial => 'attachments/form' %> +

+ +

+ 1、<%= l(:label_upload_softapplication_packets_mustpacketed) %>
+
+ 2、<%= l(:label_upload_softapplication_photo_condition) %> +

+ +
+

+
+ <%= submit_tag l(:button_create) %> + <%= submit_tag l(:button_cancel), :name => nil, :onclick => "cancel();", + :type => 'button', :class => "enterprise", :onmouseout => "this.style.backgroundPosition = 'left top'", + :onmouseover => "this.style.backgroundPosition = 'left -30px'" %> +
+<% end %> \ No newline at end of file diff --git a/app/views/contests/index.html.erb b/app/views/contests/index.html.erb index 8c999f941..6f8430ca0 100644 --- a/app/views/contests/index.html.erb +++ b/app/views/contests/index.html.erb @@ -6,17 +6,17 @@ <%= l(:label_user_location) %> : <% if User.current.logged? %> - <% unless User.current.user_extensions.identity == 1 %> - <%= link_to(l(:label_newtype_contest), {:controller => 'contests', :action => 'new_contest'}, :class => 'icon icon-add', :target => "_blank") %> - <% end %> - <% end %> + <% unless User.current.user_extensions.identity == 1 %> + <%= link_to(l(:label_newtype_contest), {:controller => 'contests', :action => 'new_contest'}, :class => 'icon icon-add', :target => "_blank") %> + <% end %> + <% end %> - - diff --git a/app/views/contests/show_attendingcontest.html.erb b/app/views/contests/show_attendingcontest.html.erb index b261780bd..799656f36 100644 --- a/app/views/contests/show_attendingcontest.html.erb +++ b/app/views/contests/show_attendingcontest.html.erb @@ -88,7 +88,7 @@
<%= l(:label_attending_contest) %>: - <%= link_to l(:label_new_attendingcontest_work), "javascript:void(0);", onclick: "$('#put-project-form').toggle();" %> + <%= link_to l(:label_new_attendingcontest_work), "javascript:void(0);", onclick: "$('#put-project-form').slideToggle();" %>
<% else %> @@ -99,102 +99,8 @@ <% end %> -