diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 15e612fc5..536d0a291 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -3,7 +3,7 @@ class BidsController < ApplicationController #Added by young menu_item l(:label_homework), :only => [:edit, :udpate] menu_item :respond - menu_item :project, :only => [:show_project,:show_results] + 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 #Ended by young @@ -713,24 +713,42 @@ class BidsController < ApplicationController render :action => 'edit' end end + + def new_submit_homework + #render html to prepare create submit homework + find_bid + render :layout => 'base_homework' + end def add_homework if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0) # homework = HomeworkAttach.create(:bid_id => @bid.id, :user_id => User.current.id) # homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) @homework = HomeworkAttach.new + @homework.safe_attributes = params[:homeworkattach] @homework.bid_id = @bid.id @homework.user_id = User.current.id @homework.save_attachments(params[:attachments]) - @homework.save + render_attachment_warning_if_needed(@homework) + if @homework.save + @homework_flag = l(:label_bidding_homework_succeed) + else + @homework_flag = l(:label_bidding_homework_failed) + end if @homework.attachments.empty? @homework.delete flash[:error] = l(:no_attachmens_allowed) + @homework_flag = l(:no_attachmens_allowed) # else end end @homework_list = @bid.homeworks - @homework = HomeworkAttach.new + respond_to do |format| + format.html{ + redirect_to project_for_bid_path, notice: @homework_flag.to_s + } + format.js + end end diff --git a/app/models/homework_attach.rb b/app/models/homework_attach.rb index aea68abb5..5ce08a0a8 100644 --- a/app/models/homework_attach.rb +++ b/app/models/homework_attach.rb @@ -1,9 +1,10 @@ class HomeworkAttach < ActiveRecord::Base - attr_accessible :bid_id, :user_id - + include Redmine::SafeAttributes belongs_to :user belongs_to :bid + safe_attributes "bid_id", + "user_id" acts_as_attachable end diff --git a/app/views/attachments/upload.js.erb b/app/views/attachments/upload.js.erb index 04e30b569..ade73ab23 100644 --- a/app/views/attachments/upload.js.erb +++ b/app/views/attachments/upload.js.erb @@ -1,9 +1,14 @@ -var fileSpan = $('#attachments_<%= j params[:attachment_id] %>'); -$('', { type: 'hidden', name: 'attachments[<%= j params[:attachment_id] %>][token]' } ).val('<%= j @attachment.token %>').appendTo(fileSpan); -fileSpan.find('a.remove-upload') - .attr({ - "data-remote": true, - "data-method": 'delete', - href: '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>' - }) - .off('click'); +var fileSpan = $('#attachments_<%= j params[:attachment_id] %>'); +<% if @attachment.new_record? %> + fileSpan.hide(); + alert("<%= escape_javascript @attachment.errors.full_messages.join(', ') %>"); +<% else %> +$('', { type: 'hidden', name: 'attachments[<%= j params[:attachment_id] %>][token]' } ).val('<%= j @attachment.token %>').appendTo(fileSpan); +fileSpan.find('a.remove-upload') + .attr({ + "data-remote": true, + "data-method": 'delete', + href: '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>' + }) + .off('click'); +<% end %> diff --git a/app/views/bids/_homework.html.erb b/app/views/bids/_homework.html.erb index 79d10bff0..5094d0c0a 100644 --- a/app/views/bids/_homework.html.erb +++ b/app/views/bids/_homework.html.erb @@ -1,21 +1,33 @@ +<%= render_flash_messages %> <% if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0) %>
- <%= toggle_link l(:label_commit_homework), 'put-bid-form' %> + <%= link_to l(:label_commit_homework), new_submit_homework_path, :onclick => "$('#put-bid-form').slideToggle(); this.blur(); return false;" %>
<% end %> diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 83f4cb45a..0fd2bf202 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -1,5 +1,4 @@ -<%= render_flash_messages %> <%= form_tag(:controller => 'bids', :action => "show_project", :method => :get) do %>
diff --git a/app/views/bids/add_homework.js.erb b/app/views/bids/add_homework.js.erb index 90085a502..42b22392e 100644 --- a/app/views/bids/add_homework.js.erb +++ b/app/views/bids/add_homework.js.erb @@ -1,5 +1,7 @@ $('#bidding_project_list').html('<%= escape_javascript(render(:partial => 'homework_list', :locals => {:homework => @homework_list})) %>'); -$('#put-bid-form-partial').html(' <%= escape_javascript( render( :partial => 'attachments/form', :locals => {:container => @homework}) )%>') +$('#put-bid-form-partial').html(' <%= escape_javascript( render( :partial => 'attachments/form') )%>') +$('#flash_notice').remove() $("#project_id").val("请选择项目"); $("#bid_message").val( "<%= l(:label_bid_reason) %>" ); -$("#put-bid-form").hide(); \ No newline at end of file +$("#put-bid-form").hide(); +alert('<%= @homework_flag %>'); \ No newline at end of file diff --git a/app/views/bids/new_submit_homework.html.erb b/app/views/bids/new_submit_homework.html.erb new file mode 100644 index 000000000..dd06af643 --- /dev/null +++ b/app/views/bids/new_submit_homework.html.erb @@ -0,0 +1,15 @@ +

<%= l :label_bidding_homework %>

+
+ <%= form_for HomeworkAttach.new, :method => :post, :url => {:controller => 'bids', :action => 'add_homework'}, :update => "bidding_project_list", :complete => '$("#put-bid-form").hide();', :html => {:multipart => true} do |f| %> +
+ + <%= l(:label_attachment_plural) %> + +

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

+
+ <%= submit_tag l(:button_create) %> + <%= link_to (t :button_back), project_for_bid_homework_path %> + <% end %> +
\ No newline at end of file diff --git a/app/views/common/_project.html.erb b/app/views/common/_project.html.erb index 516ed0f5e..9109c3fd6 100644 --- a/app/views/common/_project.html.erb +++ b/app/views/common/_project.html.erb @@ -1,58 +1,58 @@ -
-
- <%= content_tag('div', tag('img', {:src => '../images/logo-only_med.png', :class => 'img_ta'}, false, false), :class => 'img-tag') %> -
-
-

- Claimed by <%= content_tag('a', project.name) %> | Analyzed about 11 hours ago -

-

- <%= textilizable(project.short_description, :project => project) %> -

-
-
-

- <%= content_tag('a', "9.23M") %><%= content_tag('span', "lines of codes") %> -

-

- <%= content_tag('a', "963") %><%= content_tag('span', "current contributors") %> -

-

- <%= content_tag('a', "1 day") %><%= content_tag('span', "since last commits") %> -

-

- <%= content_tag('a', "12,169") %><%= content_tag('span', "users on trustie2") %> -

-
-
- <%= content_tag('a', tag('img', {:src => '../images/pai.png', :class => 'img-ta'}, false, false), :class => 'img-tag3') %> - <%= content_tag('div', "Vert High Activity", :class => 'img-tag4') %> - <%= content_tag('div', tag('img', {:src => '../images/stars_ro.png', :class => 'img-ta'}, false, false), :class => 'img-tag2') %> - <%= content_tag('div', "#{WatchersOfProjects.watcher_count(project)}Reviews", :class => 'img-tag1') %> -
-
-
-
- <%= content_tag('a', 'Mostly written in C++') %> -
-
- <%= content_tag('a', 'Licenses:') %><%= content_tag('span', 'GPL-2.0+, LGPL, MPL-1.1') %> -
-
-
- <%= tag('img', {:src => "../images/user.png"}, false, false) %> - <% tags = ProjectTags.find_tag(project.id) - tags.each do |t_tag| - content = t_tag.tag.content - description = t_tag.description -%> - <%= content_tag('a', content, :class => 'tag', :title => description) %> - <% end -%> - <%= content_tag('a', 'css', :class => 'tag') %> - <%= content_tag('a', 'web_browser', :class => 'tag') %> - <%= content_tag('a', 'development', :class => 'tag') %> - <%= content_tag('a', 'client', :class => 'tag') %> - <%= content_tag('a', 'web', :class => 'tag') %> - <%= content_tag('a', 'xhtml', :class => 'tag') %> - <%= content_tag('a', 'tabbed', :class => 'tag') %> - <%= content_tag('a', 'and more') %> -
+
+
+ <%= content_tag('div', tag('img', {:src => '../images/logo-only_med.png', :class => 'img_ta'}, false, false), :class => 'img-tag') %> +
+
+

+ Claimed by <%= content_tag('a', project.name) %> | Analyzed about 11 hours ago +

+

+ <%= textilizable(project.short_description, :project => project) %> +

+
+
+

+ <%= content_tag('a', "9.23M") %><%= content_tag('span', "lines of codes") %> +

+

+ <%= content_tag('a', "963") %><%= content_tag('span', "current contributors") %> +

+

+ <%= content_tag('a', "1 day") %><%= content_tag('span', "since last commits") %> +

+

+ <%= content_tag('a', "12,169") %><%= content_tag('span', "users on trustie2") %> +

+
+
+ <%= content_tag('a', tag('img', {:class => 'img-ta'}, false, false), :class => 'img-tag3') %> + <%= content_tag('div', "Vert High Activity", :class => 'img-tag4') %> + <%= content_tag('div', tag('img', {:src => '../images/stars_ro.png', :class => 'img-ta'}, false, false), :class => 'img-tag2') %> + <%= content_tag('div', "#{WatchersOfProjects.watcher_count(project)}Reviews", :class => 'img-tag1') %> +
+
+
+
+ <%= content_tag('a', 'Mostly written in C++') %> +
+
+ <%= content_tag('a', 'Licenses:') %><%= content_tag('span', 'GPL-2.0+, LGPL, MPL-1.1') %> +
+
+
+ <%= tag('img', {:src => "../images/user.png"}, false, false) %> + <% tags = ProjectTags.find_tag(project.id) + tags.each do |t_tag| + content = t_tag.tag.content + description = t_tag.description -%> + <%= content_tag('a', content, :class => 'tag', :title => description) %> + <% end -%> + <%= content_tag('a', 'css', :class => 'tag') %> + <%= content_tag('a', 'web_browser', :class => 'tag') %> + <%= content_tag('a', 'development', :class => 'tag') %> + <%= content_tag('a', 'client', :class => 'tag') %> + <%= content_tag('a', 'web', :class => 'tag') %> + <%= content_tag('a', 'xhtml', :class => 'tag') %> + <%= content_tag('a', 'tabbed', :class => 'tag') %> + <%= content_tag('a', 'and more') %> +
diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb index 5934733cd..a72eb4b41 100644 --- a/app/views/issues/index.html.erb +++ b/app/views/issues/index.html.erb @@ -4,7 +4,7 @@ :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) }, :class => 'icon icon-add' %> <%= link_to l(:label_query), '#', :class => 'icon icon-help', - :onclick => '$("#custom_query").toggle(); ' if User.current.logged? %> + :onclick => '$("#custom_query").slideToggle(); ' if User.current.logged? %> diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index 82cceaaec..827874d55 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -8,7 +8,7 @@ <%= csrf_meta_tag %> <%= favicon %> - <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', :media => 'all' %> + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %> <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> <%= javascript_heads %> <%= heads_for_theme %> diff --git a/app/views/memos/_reply_box.html.erb b/app/views/memos/_reply_box.html.erb index 32c03d2ad..a8991b572 100644 --- a/app/views/memos/_reply_box.html.erb +++ b/app/views/memos/_reply_box.html.erb @@ -1,4 +1,4 @@ -<%= form_for(@mome_new, url: forum_memos_path) do |f| %> +<%= form_for(@mome_new, url: forum_memos_path, :html => {:multipart => true}) do |f| %> <%= f.hidden_field :subject, :required => true, value: @memo.subject %> <%= f.hidden_field :forum_id, :required => true, value: @memo.forum_id %> <%= f.hidden_field :parent_id, :required => true, value: @memo.id %> @@ -8,7 +8,7 @@

<%= l(:label_attachment_plural) %>
- <%= render :partial => 'attachments/form', :locals => {:container => @mome_new} %> + <%= render :partial => 'attachments/form' %>

<%= f.submit value: l(:label_reply_plural), class: "replies" %> <% end %> \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 3d83fbd2a..6947fc04d 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1331,6 +1331,7 @@ zh: label_bidding_succeed: 应标成功 label_bidding_contest_succeed: 竞赛提交成功 #added by bai label_bidding_homework_succeed: 作业提交成功 #added by bai + label_bidding_homework_failed: 作业提交失败 #added by bai label_bidding_fail: 应标失败,该项目已经应标 label_bidding_homework_fail: 作业提交失败,该作业已经被提交! diff --git a/config/routes.rb b/config/routes.rb index 8d1156bff..d4d9b4f92 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -466,7 +466,8 @@ RedmineApp::Application.routes.draw do match 'calls/:id/show_project', :controller => 'bids', :action => 'show_project', :as => 'project_for_bid' match 'calls/:id/show_project_homework', :controller => 'bids', :action => 'show_project_homework', :as => 'project_for_bid_homework' # by huang match 'calls/:id/add', :controller => 'bids', :action => 'add' - match 'calls/:id/add_homework', :controller => 'bids', :action => 'add_homework' + match 'calls/:id/add_homework', :controller => 'bids', :action => 'add_homework', via: :post + match 'calls/:id/new_submit_homework', to: 'bids#new_submit_homework', via: :get, as: 'new_submit_homework' match 'words/add_project_respond', :controller => 'words', :action => 'add_project_respond' match 'words/:id/leave_project_message', :controller => 'words', :action => 'leave_project_message' @@ -499,7 +500,7 @@ RedmineApp::Application.routes.draw do match 'new_join_in_contest', :to => 'bids#new_join', :as => 'try_join_in_contest' match 'projects/:id/respond', :to => 'projects#project_respond', :via => :post match 'calls/:id/manage',:to => 'bids#manage',:via => [:get,:post] - match 'project/course', :to => 'projects#course', :as => 'course' #nyan + match 'project/course', :to => 'projects#course', :as => 'course' #added by william # match 'calls/:id/set_results',:controller => 'bids', :action => 'set_results',:via => [:get,:post],:as => 'set_results' diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js index 86bf06336..7b8394fe8 100644 --- a/public/javascripts/attachments.js +++ b/public/javascripts/attachments.js @@ -141,7 +141,7 @@ function uploadAndAttachFiles(files, inputEl) { var sizeExceeded = false; $.each(files, function() { - if (this.size && maxFileSize && this.size > parseInt(maxFileSize)) {sizeExceeded=true;} + if (this.size && maxFileSize != null && this.size > parseInt(maxFileSize)) {sizeExceeded=true;} }); if (sizeExceeded) { window.alert(maxFileSizeExceeded); diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 9ae70566f..9f0f648ba 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -211,7 +211,7 @@ div.forums-line{ } div.forums-info{ - background-image: url(../images/sidebar/forums.png); + /*background-image: url(../images/sidebar/forums.png); */ border-bottom: solid 1px #15bccf; height: 100px; width: 214px; diff --git a/public/themes/redpenny-master/stylesheets/application.css b/public/themes/redpenny-master/stylesheets/application.css index c8870221c..cf1a76d72 100644 --- a/public/themes/redpenny-master/stylesheets/application.css +++ b/public/themes/redpenny-master/stylesheets/application.css @@ -36,7 +36,7 @@ @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2) { #header > h1 { - background-image:ol url(../images/logo-2x.png); + /*background-image:ol url(../images/logo-2x.png);*/ background-size: 43px 30px; } } @@ -1251,7 +1251,7 @@ a.root { a.img-tag3{ float: left; - background-image: url("../images/pai.png"); + /*background-image: url("../images/pai.png");*/ background-position: 0px 0px; background-repeat: no-repeat; position: absolute; @@ -1891,7 +1891,7 @@ div.tableline{ * * @2013-09-27 /*added by bai*/ -input[type="submit"] { +input[type="submit"], .button_submit { padding-bottom: 5px; width: auto; height: 25px;