From 01ea6238a441c4000c3ac9a9dca106f14c37db9b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 30 Jul 2014 10:48:33 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AB=9E=E8=B5=9B?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E6=8F=8F=E8=BF=B0=E8=BF=87=E9=95=BF=E6=97=B6?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/initializers/task.rb | 6 ++++++ ...0730024419_update_contestnotifications_description.rb | 9 +++++++++ db/schema.rb | 4 ++-- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20140730024419_update_contestnotifications_description.rb diff --git a/config/initializers/task.rb b/config/initializers/task.rb index 5b4f35098..51c903355 100644 --- a/config/initializers/task.rb +++ b/config/initializers/task.rb @@ -2,3 +2,9 @@ Mailer.mail_issue.each do |t| t.join end +#Thread.new do +# if Time.now == Time. +# +# end +#end + diff --git a/db/migrate/20140730024419_update_contestnotifications_description.rb b/db/migrate/20140730024419_update_contestnotifications_description.rb new file mode 100644 index 000000000..a959e93bd --- /dev/null +++ b/db/migrate/20140730024419_update_contestnotifications_description.rb @@ -0,0 +1,9 @@ +class UpdateContestnotificationsDescription < ActiveRecord::Migration + def up + change_column :contestnotifications, :description, :text + end + + def down + change_column :contestnotifications, :description, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 3cbfefa76..e9f2d5308 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140728014933) do +ActiveRecord::Schema.define(:version => 20140730024419) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -272,7 +272,7 @@ ActiveRecord::Schema.define(:version => 20140728014933) do t.integer "contest_id" t.string "title" t.string "summary" - t.string "description" + t.text "description" t.integer "author_id" t.integer "notificationcomments_count" t.datetime "created_at", :null => false From 1f4943483e65db2db7330aea116a8074dfa003ff Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 30 Jul 2014 13:52:55 +0800 Subject: [PATCH 2/5] =?UTF-8?q?1.=E7=8E=B0=E5=9C=A8=E7=AB=9E=E8=B5=9B?= =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=90=8D=E7=A7=B0=E3=80=81=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E4=BA=BA=E5=91=98=E3=80=81=E5=BC=80=E5=8F=91=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E7=9A=84=E9=95=BF=E5=BA=A6=202.=E4=BF=AE=E5=A4=8D=E7=AB=9E?= =?UTF-8?q?=E8=B5=9B=E4=BD=9C=E5=93=81=E4=B8=80=E4=B8=8A=E4=BC=A0=E7=9A=84?= =?UTF-8?q?=E5=9B=BE=E7=89=87=EF=BC=8C=E7=BC=96=E8=BE=91=E6=97=B6=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E5=88=97=E8=A1=A8=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/softapplication.rb | 4 ++++ app/views/attachments/_links.html.erb | 5 ++++- app/views/contests/_new_softapplication.html.erb | 10 ++++++---- app/views/softapplications/_form.html.erb | 15 ++++++++++----- 4 files changed, 24 insertions(+), 10 deletions(-) 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/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index 99ecab35d..4d938707e 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', diff --git a/app/views/contests/_new_softapplication.html.erb b/app/views/contests/_new_softapplication.html.erb index 830bcd314..c83bdf6e9 100644 --- a/app/views/contests/_new_softapplication.html.erb +++ b/app/views/contests/_new_softapplication.html.erb @@ -6,7 +6,7 @@ <%= l(:label_work_name) %> * : <%= f.text_field :name, :required => true, :size => 60, :style => "width:350px;" %> - + (<%= l(:label_workname_lengthlimit) %>)

@@ -15,8 +15,10 @@ <%= l(:label_running_platform) %> * : - <%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:350px;" %> - + + <%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:350px;" %> + + (<%= l(:label_workdescription_lengthlimit) %>)

@@ -55,7 +57,7 @@ <%= l(:label_softapplication_developers) %> * : <%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:350px;" %> - + (<%= l(:label_workdescription_lengthlimit) %>)

diff --git a/app/views/softapplications/_form.html.erb b/app/views/softapplications/_form.html.erb index 27954a7d0..58f8093a6 100644 --- a/app/views/softapplications/_form.html.erb +++ b/app/views/softapplications/_form.html.erb @@ -32,7 +32,7 @@ <%= l(:label_work_name) %> * : <%= f.text_field :name, :required => true, :size => 60, :style => "width:400px;" %> - <%= l(:label_softapplication_name_condition)%> + (<%= l(:label_workname_lengthlimit) %>)


@@ -40,7 +40,7 @@ <%= l(:label_running_platform) %> * : <%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:400px;" %> - + (<%= l(:label_workdescription_lengthlimit) %>)

@@ -73,7 +73,7 @@ <%= l(:label_work_description) %> * : <%= f.text_field :description, :required => true, :size => 60, :style => "width:400px;" %> - <%= l(:label_softapplication_description_condition)%> +

@@ -82,7 +82,7 @@ <%= l(:label_softapplication_developers) %> * : <%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:400px;" %> - + (<%= l(:label_workdescription_lengthlimit) %>)

@@ -100,10 +100,15 @@

+

+ <% options = {:author => true, :deletable => true} %> + <%= render :partial => 'attachments/links', + :locals => {:attachments => @softapplication.attachments, :options => options} %> +

<%=l(:label_upload_softworkpacket_photo)%> <%= render_flash_messages %>

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

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

<%=l(:label_updated_caution)%>

From 31e8ad98aed4051dfaadab4de161a5b4e271c42f Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 30 Jul 2014 15:48:13 +0800 Subject: [PATCH 3/5] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=E7=AB=9E=E8=B5=9B?= =?UTF-8?q?=E4=BD=9C=E5=93=81=E6=AF=8F=E6=AC=A1=E4=BF=AE=E6=94=B9=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E9=83=BD=E4=BC=9A=E5=90=A7=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E6=B8=85=E7=A9=BA=E7=9A=84BUG=202.=E4=BF=AE=E6=94=B9=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E7=AB=9E=E8=B5=9B=E4=BD=9C=E5=93=81=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 11 +++++++++++ app/controllers/softapplications_controller.rb | 4 ++-- app/views/attachments/_links.html.erb | 9 +++++++++ app/views/attachments/delete_softapplications.js.erb | 2 ++ app/views/softapplications/_form.html.erb | 6 ++++-- config/routes.rb | 1 + 6 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 app/views/attachments/delete_softapplications.js.erb diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 0aec29e6a..44d68de26 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -217,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] diff --git a/app/controllers/softapplications_controller.rb b/app/controllers/softapplications_controller.rb index c216a3e93..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]) diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index 4d938707e..cdd1fdd2f 100644 --- a/app/views/attachments/_links.html.erb +++ b/app/views/attachments/_links.html.erb @@ -18,11 +18,20 @@ :method => :delete, :class => 'delete', :title => l(:button_delete) %> + <%# 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/softapplications/_form.html.erb b/app/views/softapplications/_form.html.erb index 58f8093a6..17cb20598 100644 --- a/app/views/softapplications/_form.html.erb +++ b/app/views/softapplications/_form.html.erb @@ -102,8 +102,10 @@

<% options = {:author => true, :deletable => true} %> - <%= render :partial => 'attachments/links', - :locals => {:attachments => @softapplication.attachments, :options => options} %> + + <%= render :partial => 'attachments/links', + :locals => {:attachments => @softapplication.attachments, :options => options} %> +

<%=l(:label_upload_softworkpacket_photo)%> <%= render_flash_messages %> diff --git a/config/routes.rb b/config/routes.rb index 8d55fe300..af70b76da 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -520,6 +520,7 @@ RedmineApp::Application.routes.draw do match "updateType" , via: [:get, :post] match "updateFileDense" , via: [:get, :post] match "renderTag" , via: [:get, :post] + match 'delete_softapplications', via: [:get, :post] end end From 41d983e904ef11997ca9980ebfc8b722e7ee09f5 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 31 Jul 2014 09:45:46 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=8F=96=E6=B6=88=E8=BF=87=E6=9C=9F?= =?UTF-8?q?=E7=BC=BA=E9=99=B7=E9=82=AE=E4=BB=B6=E7=9A=84=E5=8F=91=E9=80=81?= =?UTF-8?q?(=E5=BE=88=E6=9C=89=E9=97=AE=E9=A2=98)=EF=BC=81=EF=BC=81?= =?UTF-8?q?=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/issue_overdue.rb | 33 +++++++++++++++++++++++++++++++++ app/models/mailer.rb | 33 +++------------------------------ config/initializers/task.rb | 8 +++++--- 3 files changed, 41 insertions(+), 33 deletions(-) create mode 100644 app/models/issue_overdue.rb diff --git a/app/models/issue_overdue.rb b/app/models/issue_overdue.rb new file mode 100644 index 000000000..342790f55 --- /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/mailer.rb b/app/models/mailer.rb index 156b6a8c5..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, @@ -175,7 +175,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 s = l(:text_issue_expire,:issue => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}") mail :to => recipients, @@ -582,34 +582,7 @@ class Mailer < ActionMailer::Base end end - #缺陷到期后发送邮件提示 - #只监听已经提交的未到期的缺陷,已过期的缺陷默认已经发过邮件通知,不再提醒。 - def mail_issue - threads = [] - issues = Issue.where("done_ratio <> 100 and closed_on is null and due_date is not null and due_date > '#{Time.now.to_date}'") - 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 - threads - end + private diff --git a/config/initializers/task.rb b/config/initializers/task.rb index 51c903355..62d1d78e5 100644 --- a/config/initializers/task.rb +++ b/config/initializers/task.rb @@ -1,6 +1,8 @@ -Mailer.mail_issue.each do |t| - t.join -end +@threads = IssueOverdue.mail_issue +#ii = 1 +#@threads.each do |t| +# t.join +#end #Thread.new do # if Time.now == Time. From f0cee20f116bbbaabca898f2b9b214ee062543de Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 31 Jul 2014 09:52:52 +0800 Subject: [PATCH 5/5] tt --- config/initializers/task.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/task.rb b/config/initializers/task.rb index 62d1d78e5..1c687d15e 100644 --- a/config/initializers/task.rb +++ b/config/initializers/task.rb @@ -1,4 +1,4 @@ -@threads = IssueOverdue.mail_issue +#@threads = IssueOverdue.mail_issue #ii = 1 #@threads.each do |t| # t.join