This commit is contained in:
huang 2015-06-13 09:38:12 +08:00
commit f5f267839e
8 changed files with 160 additions and 249 deletions

View File

@ -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(/&nbsp;/," ")
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(/&nbsp;/," ")
count_row += 1
end
count_row += 1

View File

@ -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

View File

@ -1,25 +0,0 @@
<!-- fq --> <!-- modified by bai -->
<%= error_messages_for 'bid' %>
<!--[form:project]-->
<p><%= l(:label_fork_form_new_description) %></p>
<!-- modified by bai -->
<p style="margin-left:-68px;padding-right: 20px;"><strong><%= l(:label_choose_course) %><span class="required"> *&nbsp;</span></strong><%= select_tag 'course', course_options_for_select(@courses) %></p>
<p><%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;", :maxlength => Bid::NAME_LENGTH_LIMIT, :value => @bid.name %></p>
<!-- end -->
<p style="margin-left:-10px;padding-right: 20px;">
<%= 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 %></p>
<!-- <p><%#= select_tag 'bid_reward_type', "<option value = '0'>#{l(:label_choose_reward)}</option><option value = '1'>#{l(:label_money)}</option><option value = '3'>#{l(:label_bids_credit)}</option><option value = '2'>#{l(:label_reward_1)}</option>".html_safe,
:onChange => "show('bid_reward_type', 'bid_budget', '"+l(:label_bids_reward_what)+"','"+l(:label_bids_new_money)+"','"+l(:label_bids_new_credit)+"','"+l(:label_bids_new_content)+"')" %>
<%#= f.text_field :budget, :required => true, :size => 60, :style => "width:350px;", :placeholder => l(:label_bids_reward_what) %>
</p> -->
<p><%= f.text_field :deadline, :value => nil,:required => true, :size => 60, :style => "width:150px;" , :readonly => true %><%= calendar_for('bid_deadline')%>
<!--
<p><%#= f.select :homework_type, homework_type_option %>
</p>
-->
<p><%= f.select :is_evaluation, is_evaluation_option %>
<fieldset><legend><%= l(:label_attachment_plural) %></legend>
<p><%= render :partial => 'attachments/form', :locals => {:container => @homework} %></p>
</fieldset>

View File

@ -1,36 +0,0 @@
<!-- huang -->
<script type="text/javascript" language="javascript">
function show(id, id_t, label_reward, label_money, label_credit, label_content) {
var text = $('#' + id);
var text_t = $('#' + id_t);
if (text.val() == 0) {
text_t.attr("placeholder", label_reward);
}
if (text.val() == 1) {
text_t.attr("placeholder", label_money);
}
if (text.val() == 3) {
text_t.attr("placeholder", label_credit);
}
if (text.val() == 2) {
text_t.attr("placeholder", label_content);
}
return content;
}
</script>
<%= error_messages_for 'bid' %>
<!--[form:project]-->
<p style="width:500px;"><%= l(:label_bids_form_contest_new_description) %></p>
<p><%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;", :maxlength => Bid::NAME_LENGTH_LIMIT, :placeholder => "#{l(:label_contest_name)}" %></p>
<p style="margin-left:-10px;padding-right: 20px;"><%= 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)}" %></p>
<p style="margin-left:-10px;"><%= f.text_field :password, :size => 60, :style => "width:488px;margin-left: 10px;" %></p>
<p>
<%= f.text_field :budget, :required => true, :size => 60, :style => "width:350px;", :placeholder => l(:label_bids_reward_what) %>
<!-- 设置奖项设置的打开 关闭开关-->
</p>
<!-- <em class="info" style="margin-left:95px;"><%= l(:text_contest_reward) %></em> -->
<p><%= f.text_field :deadline, :required => true, :size => 60, :style => "width:150px;", :readonly => true, :placeholder => "#{l(:label_deadline)}" %><%= calendar_for('bid_deadline')%></p>

View File

@ -1,30 +0,0 @@
<div class="inf_user_image">
<% for user in @bid.watcher_users %>
<ul class="list_watch"><li>
<table width="660px" border="0" align="center">
<tr>
<td colspan="2" valign="top" width="50" ><%= image_tag(url_to_avatar(user), :class => "avatar") %></td>
<td><table width="580px" border="0">
<tr>
<td colspan="2" valign="top"><strong><%= content_tag "div", link_to_user(user), :class => "project_avatar_name" %>
</td>
</tr>
<tr>
<td colspan="2" width="580px" ><p class="font_description">
<% unless user.memberships.empty? %>
<%= l(:label_x_contribute_to, :count => user.memberships.count) %>
<% for member in user.memberships %>
<%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : '' %>
<% end %>
<% end %>
</p></td>
</tr>
<tr>
<td width="200" align="right" class="font_lighter"><%= l(:label_user_joinin) %><%= format_date(user.created_on) %>
</td>
</tr>
</table></td>
</tr>
</table></li></ul>
<% end %>
</div>

View File

@ -107,7 +107,9 @@
<!--邀请加入-->
<div class="subNavBox">
<% if User.current.member_of?(@project) %>
<div class="subNav currentDd currentDt subNav_jiantou" id="expand_tools_expand_invit" nhtype="toggle4cookie" data-id="expand_invit" data-target="#navContent_invit" data-val="expand"><%= l(:label_invite)%></div>
<div class="subNav currentDd currentDt subNav_jiantou" id="expand_tools_expand_invit" nhtype="toggle4cookie" data-id="expand_invit" data-target="#navContent_invit">
<%= l(:label_invite)%>
</div>
<ul class="navContent " style="display:block" id="navContent_invit">
<li><%= link_to l(:label_invite_new_user), :controller=>"projects", :action=>"invite_members_by_mail", :id => @project %></li>
<% if User.current.allowed_to?(:manage_members, @project) %>

View File

@ -35,7 +35,7 @@
<%= c1.downloads %>
</div>
<div class="table_cell1 downicon1 filename download_icon" >
<%= 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)) }%>
</div>
</div>
<% end -%>

View File

@ -5621,7 +5621,7 @@ _plugin('core', function(K) {
if (data.error === 0) {
var url = K.formatUrl(data.url, 'absolute');
//self.exec('insertimage', url, 'image','','','1','left');
self.insertHtml('<img src="'+url+'"/>');
self.insertHtml('<img src="'+url+'"/>');
var asset_id = data.asset_id;
if ( asset_id != "" && parent.document.getElementById('asset_id') != null ) {
parent.document.getElementById('asset_id').value += asset_id.toString();