From 418f75fd1f78048ff23e8b2ca22e967bb0269490 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 12 Jun 2015 16:43:52 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/bids/show_bid_user.html.erb | 62 ++++++++++++++------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/app/views/bids/show_bid_user.html.erb b/app/views/bids/show_bid_user.html.erb index f4d7b2642..a0acdfa1a 100644 --- a/app/views/bids/show_bid_user.html.erb +++ b/app/views/bids/show_bid_user.html.erb @@ -1,30 +1,32 @@ -
- <% for user in @bid.watcher_users %> - -<% end %> -
\ No newline at end of file + + + + + + + + + + <%#= content_tag "div", link_to_user(user), :class => "project_avatar_name" %> + + + + + + + + + + + + + + + <%#= l(:label_user_joinin) %><%#= format_date(user.created_on) %> + + + + + + + \ No newline at end of file From 21a9a67bfc308d7d202d57edf28d1160e51c106f Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 12 Jun 2015 16:45:23 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E7=A7=BB=E9=99=A4bid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/bid.rb | 306 +++++++++++++------------- app/views/bids/show_bid_user.html.erb | 32 --- 2 files changed, 153 insertions(+), 185 deletions(-) delete mode 100644 app/views/bids/show_bid_user.html.erb diff --git a/app/models/bid.rb b/app/models/bid.rb index ccd6198bb..f5cb5a3b7 100644 --- a/app/models/bid.rb +++ b/app/models/bid.rb @@ -10,158 +10,158 @@ homework_type == 1 文件提交 homework_type == 2 Project提交 =end class Bid < ActiveRecord::Base - Enterprise = 1 - Contest = 2 - Homework = 3 - HomeworkFile = 1 - HomeworkProject = 2 - attr_accessible :author_id, :budget, :deadline, :name, :description, :homework_type, :password - include Redmine::SafeAttributes - include ApplicationHelper - has_many_kindeditor_assets :assets, :dependent => :destroy - belongs_to :author, :class_name => 'User', :foreign_key => :author_id - belongs_to :course - has_many :biding_projects, :dependent => :destroy - has_many :projects, :through => :biding_projects - has_many :courses_member, :class_name => 'User', :through => :courses - has_many :journals_for_messages, :as => :jour, :dependent => :destroy - has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy - has_many :homework_for_courses, :dependent => :destroy - has_many :courses, :through => :homework_for_courses, :source => :course - has_many :homeworks, :class_name => 'HomeworkAttach', :dependent => :destroy - has_many :homework_evaluations, :through => :homeworks - has_many :join_in_contests, :dependent => :destroy - has_many :praise_tread, as: :praise_tread_object, dependent: :destroy - # has_many :fork_homework, :class_name => 'Bid', :conditions => "#{Bid.table_name}.parent_id = #{id}" - acts_as_attachable - - NAME_LENGTH_LIMIT = 60 - DESCRIPTION_LENGTH_LIMIT = 3000 - validates :name, length: {maximum: NAME_LENGTH_LIMIT}, presence: true - validates :description, length: {maximum: DESCRIPTION_LENGTH_LIMIT} - validates :author_id, presence: true - validates :deadline, presence: true, format: {:with => /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/} - validates :name, length: {maximum: NAME_LENGTH_LIMIT} - validates :budget, format: { with: ->(p) { if p.reward_type == 1 then /^(\d+)$|^(\d+).([0-9]{2})|^(\d+).([0-9]{1})$/ - elsif p.reward_type == 3 then /^(\d+)$|^(\d+).([0-9]{1})$/ end } } - - validate :validate_user - validate :validate_reward_type - after_create :act_as_activity - after_destroy :delete_kindeditor_assets - scope :visible, lambda {|*args| - nil - } - - scope :like, lambda {|arg| - if arg.blank? - where(nil) - else - pattern = "%#{arg.to_s.strip.downcase}%" - where("LOWER(id) LIKE :p OR LOWER(name) LIKE :p OR LOWER(description) LIKE :p", :p => pattern) - end - } - - scope :course_visible, lambda {|*args| - includes(:courses).where(Course.allowed_to_condition(args.shift || User.current, :view_homeworks, *args)) - } - - acts_as_watchable - acts_as_taggable - - acts_as_event :title => Proc.new {|o| "#{l(:label_course_homework)} ##{o.id}: #{o.name}" }, - :description => :description, - :author => :author, - :url => Proc.new {|o| {:controller => 'bids', :action => 'show', :id => o.id}} - - acts_as_activity_provider :type => 'homeworks', - :author_key => :author_id - - acts_as_activity_provider :find_options => {:include => [:projects, :author]}, - :author_key => :author_id - - safe_attributes 'name', - 'description', - 'budget', - 'deadline', - 'homework_type', - 'reward_type', - 'password' - - + # Enterprise = 1 + # Contest = 2 + # Homework = 3 + # HomeworkFile = 1 + # HomeworkProject = 2 + # attr_accessible :author_id, :budget, :deadline, :name, :description, :homework_type, :password + # include Redmine::SafeAttributes + # include ApplicationHelper + # has_many_kindeditor_assets :assets, :dependent => :destroy + # belongs_to :author, :class_name => 'User', :foreign_key => :author_id + # belongs_to :course + # has_many :biding_projects, :dependent => :destroy + # has_many :projects, :through => :biding_projects + # has_many :courses_member, :class_name => 'User', :through => :courses + # has_many :journals_for_messages, :as => :jour, :dependent => :destroy + # has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy + # has_many :homework_for_courses, :dependent => :destroy + # has_many :courses, :through => :homework_for_courses, :source => :course + # has_many :homeworks, :class_name => 'HomeworkAttach', :dependent => :destroy + # has_many :homework_evaluations, :through => :homeworks + # has_many :join_in_contests, :dependent => :destroy + # has_many :praise_tread, as: :praise_tread_object, dependent: :destroy + # # has_many :fork_homework, :class_name => 'Bid', :conditions => "#{Bid.table_name}.parent_id = #{id}" + # acts_as_attachable + # + # NAME_LENGTH_LIMIT = 60 + # DESCRIPTION_LENGTH_LIMIT = 3000 + # validates :name, length: {maximum: NAME_LENGTH_LIMIT}, presence: true + # validates :description, length: {maximum: DESCRIPTION_LENGTH_LIMIT} + # validates :author_id, presence: true + # validates :deadline, presence: true, format: {:with => /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/} + # validates :name, length: {maximum: NAME_LENGTH_LIMIT} + # validates :budget, format: { with: ->(p) { if p.reward_type == 1 then /^(\d+)$|^(\d+).([0-9]{2})|^(\d+).([0-9]{1})$/ + # elsif p.reward_type == 3 then /^(\d+)$|^(\d+).([0-9]{1})$/ end } } + # + # validate :validate_user + # validate :validate_reward_type + # after_create :act_as_activity + # after_destroy :delete_kindeditor_assets + # scope :visible, lambda {|*args| + # nil + # } + # + # scope :like, lambda {|arg| + # if arg.blank? + # where(nil) + # else + # pattern = "%#{arg.to_s.strip.downcase}%" + # where("LOWER(id) LIKE :p OR LOWER(name) LIKE :p OR LOWER(description) LIKE :p", :p => pattern) + # end + # } + # + # scope :course_visible, lambda {|*args| + # includes(:courses).where(Course.allowed_to_condition(args.shift || User.current, :view_homeworks, *args)) + # } + # + # acts_as_watchable + # acts_as_taggable + # + # acts_as_event :title => Proc.new {|o| "#{l(:label_course_homework)} ##{o.id}: #{o.name}" }, + # :description => :description, + # :author => :author, + # :url => Proc.new {|o| {:controller => 'bids', :action => 'show', :id => o.id}} + # + # acts_as_activity_provider :type => 'homeworks', + # :author_key => :author_id + # + # acts_as_activity_provider :find_options => {:include => [:projects, :author]}, + # :author_key => :author_id + # # safe_attributes 'name', - # 'description', - # 'deadline' - def add_jour(user, notes, reference_user_id = 0, options = {}) - if options.count == 0 - jfm = JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id) - self.journals_for_messages << jfm - jfm - else - jfm = self.journals_for_messages.build(options) - jfm.save - jfm - end - end - - def self.creat_bids(budget, deadline, name, description=nil, reward_type) - self.create(:author_id => User.current.id, :budget => budget, - :deadline => deadline, :name => name, :description => description, :commit => 0, :reward_type => reward_type) - # self.acts << Activity.new(:user_id => self.author_id) - end - - def update_bids(budget, deadline, name, description=nil) - if(User.current.id == self.author_id) - self.name = name - self.budget = budget - self.deadline = deadline - self.description = description - self.save - end - end - - def delete_bids - unless self.nil? - if User.current.id == self.author_id - self.destroy - end - end - end - - def set_commit(commit) - self.update_attribute(:commit, commit) - end - - private - - def validate_user - errors.add :author_id, :invalid if author.nil? || !author.active? - end - - def validate_reward_type - errors.add :reward_type, :invalid if self.reward_type == 0 - end - - def act_as_activity - self.acts << Activity.new(:user_id => self.author_id) - end - - # used to validate weather the user is the creater of the bid - # added by william - def validate_bid_manager(user_id) - unless user_id.nil? - if self.author_id == user_id - return true - else - return false - end - end - end - - # Time 2015-04-01 14:19:06 - # Author lizanle - # Description 删除对应课程通知的图片资源 - def delete_kindeditor_assets - delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::BID - end + # 'description', + # 'budget', + # 'deadline', + # 'homework_type', + # 'reward_type', + # 'password' + # + # + # # safe_attributes 'name', + # # 'description', + # # 'deadline' + # def add_jour(user, notes, reference_user_id = 0, options = {}) + # if options.count == 0 + # jfm = JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id) + # self.journals_for_messages << jfm + # jfm + # else + # jfm = self.journals_for_messages.build(options) + # jfm.save + # jfm + # end + # end + # + # def self.creat_bids(budget, deadline, name, description=nil, reward_type) + # self.create(:author_id => User.current.id, :budget => budget, + # :deadline => deadline, :name => name, :description => description, :commit => 0, :reward_type => reward_type) + # # self.acts << Activity.new(:user_id => self.author_id) + # end + # + # def update_bids(budget, deadline, name, description=nil) + # if(User.current.id == self.author_id) + # self.name = name + # self.budget = budget + # self.deadline = deadline + # self.description = description + # self.save + # end + # end + # + # def delete_bids + # unless self.nil? + # if User.current.id == self.author_id + # self.destroy + # end + # end + # end + # + # def set_commit(commit) + # self.update_attribute(:commit, commit) + # end + # + # private + # + # def validate_user + # errors.add :author_id, :invalid if author.nil? || !author.active? + # end + # + # def validate_reward_type + # errors.add :reward_type, :invalid if self.reward_type == 0 + # end + # + # def act_as_activity + # self.acts << Activity.new(:user_id => self.author_id) + # end + # + # # used to validate weather the user is the creater of the bid + # # added by william + # def validate_bid_manager(user_id) + # unless user_id.nil? + # if self.author_id == user_id + # return true + # else + # return false + # end + # end + # end + # + # # Time 2015-04-01 14:19:06 + # # Author lizanle + # # Description 删除对应课程通知的图片资源 + # def delete_kindeditor_assets + # delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::BID + # end end diff --git a/app/views/bids/show_bid_user.html.erb b/app/views/bids/show_bid_user.html.erb deleted file mode 100644 index a0acdfa1a..000000000 --- a/app/views/bids/show_bid_user.html.erb +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - <%#= content_tag "div", link_to_user(user), :class => "project_avatar_name" %> - - - - - - - - - - - - - - - <%#= l(:label_user_joinin) %><%#= format_date(user.created_on) %> - - - - - - - \ No newline at end of file From 1810a3eb411410b6657ea9012f209eff215dd576 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 12 Jun 2015 16:46:07 +0800 Subject: [PATCH 3/6] 111 --- app/views/bids/_fork_form.html.erb | 25 ------------------- app/views/bids/_form_contest.html.erb | 36 --------------------------- 2 files changed, 61 deletions(-) delete mode 100644 app/views/bids/_fork_form.html.erb delete mode 100644 app/views/bids/_form_contest.html.erb diff --git a/app/views/bids/_fork_form.html.erb b/app/views/bids/_fork_form.html.erb deleted file mode 100644 index 7a7010794..000000000 --- a/app/views/bids/_fork_form.html.erb +++ /dev/null @@ -1,25 +0,0 @@ - -<%= error_messages_for 'bid' %> - -

<%= l(:label_fork_form_new_description) %>

- - -

<%= l(:label_choose_course) %><%= select_tag 'course', course_options_for_select(@courses) %>

-

<%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;", :maxlength => Bid::NAME_LENGTH_LIMIT, :value => @bid.name %>

- - -

-<%= f.text_area :description, :rows => 8, :value => @bid.description, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;", :maxlength => Bid::DESCRIPTION_LENGTH_LIMIT %>

- -

<%= f.text_field :deadline, :value => nil,:required => true, :size => 60, :style => "width:150px;" , :readonly => true %><%= calendar_for('bid_deadline')%> - -

<%= f.select :is_evaluation, is_evaluation_option %> -

<%= l(:label_attachment_plural) %> -

<%= render :partial => 'attachments/form', :locals => {:container => @homework} %>

-
\ No newline at end of file diff --git a/app/views/bids/_form_contest.html.erb b/app/views/bids/_form_contest.html.erb deleted file mode 100644 index ccd16f15e..000000000 --- a/app/views/bids/_form_contest.html.erb +++ /dev/null @@ -1,36 +0,0 @@ - - -<%= error_messages_for 'bid' %> - -

<%= l(:label_bids_form_contest_new_description) %>

-

<%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;", :maxlength => Bid::NAME_LENGTH_LIMIT, :placeholder => "#{l(:label_contest_name)}" %>

- -

<%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;", :maxlength => Bid::DESCRIPTION_LENGTH_LIMIT, :placeholder => "#{l(:label_contest_description)}" %>

- -

<%= f.text_field :password, :size => 60, :style => "width:488px;margin-left: 10px;" %>

- -

- <%= f.text_field :budget, :required => true, :size => 60, :style => "width:350px;", :placeholder => l(:label_bids_reward_what) %> - - -

- -

<%= f.text_field :deadline, :required => true, :size => 60, :style => "width:150px;", :readonly => true, :placeholder => "#{l(:label_deadline)}" %><%= calendar_for('bid_deadline')%>

From 2a2b93c97df190329af0e710ab0f3dea2d59d304 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 12 Jun 2015 16:58:43 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E9=97=AE=E5=8D=B7?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=A4=9A=E8=A1=8C=E4=B8=BB=E8=A7=82=E7=9A=84?= =?UTF-8?q?=E7=AD=94=E6=A1=88=E6=9C=89html=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/poll_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 73650a782..a222314ab 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -464,7 +464,7 @@ class PollController < ApplicationController sheet1[count_row + 1,0] = l(:label_poll_subtotal) sheet1[count_row + 2,0] = l(:label_poll_proportion) poll_question.poll_answers.each_with_index do |poll_answer,i| - sheet1[count_row, i + 1] = poll_answer.answer_text + sheet1[count_row, i + 1] = poll_answer.answer_text.gsub(/<\/?.*?>/,"").gsub(/ /," ") sheet1[count_row + 1, i + 1] = poll_answer.poll_votes.count sheet1[count_row + 2, i + 1] = statistics_result_percentage(poll_answer.poll_votes.count, total_answer(poll_question.id)).to_s + "%" end @@ -477,7 +477,7 @@ class PollController < ApplicationController sheet1[count_row,1] = poll_question.question_title count_row += 1 poll_question.poll_votes.each do |poll_vote| - sheet1[count_row,0] = poll_vote.vote_text + sheet1[count_row,0] = poll_vote.vote_text.gsub(/<\/?.*?>/,"").gsub(/ /," ") count_row += 1 end count_row += 1 From cd7bb85f2f777807576a1e6d4035080625aad22e Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 12 Jun 2015 17:25:39 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=A4=9A=E4=BA=86=E4=B8=80=E4=B8=AAc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/stores/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/stores/index.html.erb b/app/views/stores/index.html.erb index 84116a561..6fab364b5 100644 --- a/app/views/stores/index.html.erb +++ b/app/views/stores/index.html.erb @@ -35,7 +35,7 @@ <%= c1.downloads %>
- <%= link_to_attachment c1, {:download => true, :text => image_tag("/images/button/download.png", width: "22px", alt: l(:button_download)) }%>c + <%= link_to_attachment c1, {:download => true, :text => image_tag("/images/button/download.png", width: "22px", alt: l(:button_download)) }%>
<% end -%> From a600d936305340e0a19368445163be8bccfe828b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sat, 13 Jun 2015 09:23:04 +0800 Subject: [PATCH 6/6] 111 --- app/views/layouts/base_projects.html.erb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index faf73918d..734a0e2e8 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -107,7 +107,9 @@