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/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/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..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) %> + <%# 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/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..17cb20598 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,17 @@

+

+ <% 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)%>

diff --git a/config/initializers/task.rb b/config/initializers/task.rb index 5b4f35098..1c687d15e 100644 --- a/config/initializers/task.rb +++ b/config/initializers/task.rb @@ -1,4 +1,12 @@ -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. +# +# end +#end 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 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