Merge branch 'develop' of 10.0.47.245:/home/trustie2 into develop

exceptionHandle
fanqiang 12 years ago
commit a31f817e55

@ -7,6 +7,7 @@ gem "coderay", "~> 1.0.6"
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
gem "builder", "3.0.0"
gem 'acts-as-taggable-on'
# Optional gem for LDAP authentication
group :ldap do
gem "net-ldap", "~> 0.3.1"

@ -98,6 +98,8 @@ GEM
rmagick (2.13.2)
ruby-openid (2.1.8)
rubyzip (0.9.9)
jquery-rails
rails
selenium-webdriver (2.33.0)
childprocess (>= 0.2.5)
multi_json (~> 1.0)

@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.

@ -0,0 +1,225 @@
/************************************************************************
*************************************************************************
@Name : jRating - jQuery Plugin
@Revison : 3.0
@Date : 28/01/2013
@Author: ALPIXEL - (www.myjqueryplugins.com - www.alpixel.fr)
@License : Open Source - MIT License : http://www.opensource.org/licenses/mit-license.php
**************************************************************************
*************************************************************************/
(function($) {
$.fn.jRating = function(op) {
var defaults = {
/** String vars **/
bigStarsPath : '<%= image_path "seems_rateable/stars.png" %>', // path of the icon stars.png
smallStarsPath : '<%= image_path "seems_rateable/small.png" %>', // path of the icon small.png
path : '<%= SeemsRateable::Engine.routes.url_helpers.ratings_path %>',
type : 'big', // can be set to 'small' or 'big'
/** Boolean vars **/
step:false, // if true, mouseover binded star by star,
isDisabled:false,
showRateInfo: false,
canRateAgain : false,
/** Integer vars **/
length:5, // number of star to display
decimalLength : 0, // number of decimals.. Max 3, but you can complete the function 'getNote'
rateMax : 20, // maximal rate - integer from 0 to 9999 (or more)
rateInfosX : -45, // relative position in X axis of the info box when mouseover
rateInfosY : 5, // relative position in Y axis of the info box when mouseover
nbRates : 1,
/** Functions **/
onSuccess : null,
onError : null
};
if(this.length>0)
return this.each(function() {
/*vars*/
var opts = $.extend(defaults, op),
newWidth = 0,
starWidth = 0,
starHeight = 0,
bgPath = '',
hasRated = false,
globalWidth = 0,
nbOfRates = opts.nbRates;
if($(this).hasClass('jDisabled') || opts.isDisabled)
var jDisabled = true;
else
var jDisabled = false;
getStarWidth();
$(this).height(starHeight);
var average = parseFloat($(this).attr('data-average')), // get the average of all rates
idBox = parseInt($(this).attr('data-id')), // get the id of the box
kls = $(this).attr('data-kls'),
dimension = $(this).attr('data-dimension'),
widthRatingContainer = starWidth*opts.length, // Width of the Container
widthColor = average/opts.rateMax*widthRatingContainer, // Width of the color Container
quotient =
$('<div>',
{
'class' : 'jRatingColor',
css:{
width:widthColor
}
}).appendTo($(this)),
average =
$('<div>',
{
'class' : 'jRatingAverage',
css:{
width:0,
top:- starHeight
}
}).appendTo($(this)),
jstar =
$('<div>',
{
'class' : 'jStar',
css:{
width:widthRatingContainer,
height:starHeight,
top:- (starHeight*2),
background: 'url('+bgPath+') repeat-x'
}
}).appendTo($(this));
$(this).css({width: widthRatingContainer,overflow:'hidden',zIndex:1,position:'relative'});
if(!jDisabled)
$(this).unbind().bind({
mouseenter : function(e){
var realOffsetLeft = findRealLeft(this);
var relativeX = e.pageX - realOffsetLeft;
if (opts.showRateInfo)
var tooltip =
$('<p>',{
'class' : 'jRatingInfos',
html : getNote(relativeX)+' <span class="maxRate">/ '+opts.rateMax+'</span>',
css : {
top: (e.pageY + opts.rateInfosY),
left: (e.pageX + opts.rateInfosX)
}
}).appendTo('body').show();
},
mouseover : function(e){
$(this).css('cursor','pointer');
},
mouseout : function(){
$(this).css('cursor','default');
if(hasRated) average.width(globalWidth);
else average.width(0);
},
mousemove : function(e){
var realOffsetLeft = findRealLeft(this);
var relativeX = e.pageX - realOffsetLeft;
if(opts.step) newWidth = Math.floor(relativeX/starWidth)*starWidth + starWidth;
else newWidth = relativeX;
average.width(newWidth);
if (opts.showRateInfo)
$("p.jRatingInfos")
.css({
left: (e.pageX + opts.rateInfosX)
})
.html(getNote(newWidth) +' <span class="maxRate">/ '+opts.rateMax+'</span>');
},
mouseleave : function(){
$("p.jRatingInfos").remove();
},
click : function(e){
var element = this;
/*set vars*/
hasRated = true;
globalWidth = newWidth;
nbOfRates--;
if(!opts.canRateAgain || parseInt(nbOfRates) <= 0) $(this).unbind().css('cursor','default').addClass('jDisabled');
if (opts.showRateInfo) $("p.jRatingInfos").fadeOut('fast',function(){$(this).remove();});
e.preventDefault();
var rate = getNote(newWidth);
average.width(newWidth);
$.post(defaults.path,
{
idBox : idBox,
rate : rate,
kls : kls,
dimension : dimension
/** action : 'rating' **/
},
function(data) {
if(!data.error)
{
/** Here you can display an alert box,
or use the jNotify Plugin :) http://www.myqjqueryplugins.com/jNotify
exemple : */
if(opts.onSuccess) opts.onSuccess( element, rate );
}
else
{
/** Here you can display an alert box,
or use the jNotify Plugin :) http://www.myqjqueryplugins.com/jNotify
exemple : */
if(opts.onError) opts.onError( element, rate );
}
},
'json'
);
}
});
function getNote(relativeX) {
var noteBrut = parseFloat((relativeX*100/widthRatingContainer)*opts.rateMax/100);
switch(opts.decimalLength) {
case 1 :
var note = Math.round(noteBrut*10)/10;
break;
case 2 :
var note = Math.round(noteBrut*100)/100;
break;
case 3 :
var note = Math.round(noteBrut*1000)/1000;
break;
default :
var note = Math.round(noteBrut*1)/1;
}
return note;
};
function getStarWidth(){
switch(opts.type) {
case 'small' :
starWidth = 12; // width of the picture small.png
starHeight = 10; // height of the picture small.png
bgPath = opts.smallStarsPath;
break;
default :
starWidth = 23; // width of the picture stars.png
starHeight = 20; // height of the picture stars.png
bgPath = opts.bigStarsPath;
}
};
function findRealLeft(obj) {
if( !obj ) return 0;
return obj.offsetLeft + findRealLeft( obj.offsetParent );
};
});
}
})(jQuery);

@ -0,0 +1,25 @@
$(document).ready(function(){
$(".rateable").jRating({
//default options displayed below ->
rateMax: 5, //Maximal rate
length : 5, //Number of stars
//decimalLength : 0, //Number of decimals in the rate
//type : 'big', //Big or small
//step : true, //If set to true, filling of the stars is done star by star (step by step).
//isDisabled: false, //Set true to display static rating
//showRateInfo:false, //Rate info panel, set true to display
//rateInfosX : 45, //In pixel - Absolute left position of the information box during mousemove.
//rateInfosY : 5, //In pixel - Absolute top position of the information box during mousemove.
path : '<%= SeemsRateable::Engine.routes.url_helpers.ratings_path %>',
onSuccess : function(element, rate){
//something like ->
//alert('success');
$('<span class="text-success"><small style="display:inline-block;">Thanks for rating!</small></span>').insertAfter(element)
},
onError : function(element, rate) {
$('<span class="text-error"><small style="display:inline-block;">You have already rated!</small></span>').insertAfter(element)
}
});
});

@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/

@ -95,6 +95,9 @@ class ApplicationController < ActionController::Base
# Returns the current user or nil if no user is logged in
# and starts a session if needed
def current_user
find_current_user
end
def find_current_user
user = nil
unless api_request?

@ -0,0 +1,68 @@
class PraiseTreadController < ApplicationController
def praise_plus
@obj = nil
if request.get?
@obj = params[:obj] # 传的是对象最后变成id了
#首先创建或更新praise_tread 表
@pt = PraiseTread.find_by_user_id_and_praise_tread_object_id(User.current.id,@obj)
@pt = @pt.nil? ? PraiseTread.new : @pt
@pt.user_id = User.current.id
@pt.praise_tread_object_id = @obj.to_i
@pt.praise_tread_object_type = User.find_by_id(@obj).class.name.underscore
@pt.praise_or_tread = 1
@pt.save
#再创建或更新praise_tread_cache表
@ptc = PraiseTreadCache.find_by_object_id(@obj)
@ptc = @ptc.nil? ? PraiseTreadCache.new : @ptc
@ptc.object_id = @obj.to_i
@ptc.object_type = User.find_by_id(@obj).class.name.underscore
@ptc.plus(1)
@ptc.save
end
@obj = User.find_by_id(@obj)
respond_to do |format|
format.html
format.js
end
end
def praise_minus
@obj = nil
if request.get?
@obj = params[:obj] # 传的是对象最后变成id了
#首先更新praise_tread 表 删除关注记录
@pt = PraiseTread.find_by_user_id_and_praise_tread_object_id_and_praise_tread_object_type(User.current.id,@obj,"user")
@pt.delete
#再更新praise_tread_cache表 使相应的记录减1 当为0时删除
@ptc = PraiseTreadCache.find_by_object_id(@obj)
@ptc.minus(1)
if @ptc.praise_num == 0
@ptc.delete
end
end
@obj = User.find_by_id(@obj)
respond_to do |format|
format.html
format.js
end
end
def tread_plus
end
def tread_minus
respond_to do |format|
format.html
format.js
end
end
end

@ -2,9 +2,7 @@
class TagsController < ApplicationController
before_filter :require_admin,:only => :show
#Added by nie
#before_filter :require_login,:only => :add_tag
#end
include ProjectsHelper
include IssuesHelper
include UsersHelper
@ -78,5 +76,10 @@ class TagsController < ApplicationController
def show
end
def show_all
@tags = ActsAsTaggableOn::Tag.find(:all)
@tags = @tags.to_a
end
end

@ -17,9 +17,13 @@
class UsersController < ApplicationController
layout 'base_users'
before_filter :require_admin, :except => [:show, :index,:tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info]
before_filter :find_user, :only => [:show, :edit, :update, :destroy, :edit_membership, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info]
before_filter :require_admin, :except => [:show, :index,:tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, :user_watchlist, :user_fanslist]
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info]
accept_api_auth :index, :show, :create, :update, :destroy
#william
before_filter :require_login,:only=>[:tag_save]
helper :sort
include SortHelper
@ -27,7 +31,7 @@ class UsersController < ApplicationController
include CustomFieldsHelper
include AvatarHelper
# added by liuping 关注
# added by liuping 关注
helper :watchers
helper :activities
@ -379,7 +383,16 @@ class UsersController < ApplicationController
respond_to do |format|
format.html
format.js
end
end
end
###add by huang
def user_watchlist
end
###add by huang
def user_fanslist
end
private

@ -26,12 +26,9 @@ module ApplicationHelper
include GravatarHelper::PublicMethods
include Redmine::Pagination::Helper
include AvatarHelper
### added by william
include ActsAsTaggableOn::TagsHelper
# include WatchersHelper
## added by william
include PraiseTreadHelper
extend Forwardable
def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter
@ -1309,4 +1306,14 @@ module ApplicationHelper
html.html_safe
end
#end
# add by huang
def show_watcher_list(user)
html = ''
for user in User.watched_by(user.id)
html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => "#{user.name}")
end
html.html_safe
end
# end
end

@ -377,7 +377,7 @@ module IssuesHelper
# this method is used to get all projects that tagged one tag
# added by william
def get_issues_by_tag(tag_name)
Issue.tagged_with(tag_name)
Issue.tagged_with(tag_name).by_join_date
end
end

@ -0,0 +1,23 @@
module PraiseTreadHelper
#added by william
def is_praise_or_tread(object,user_id)
@obj_type = object.class.name.underscore
@obj_id = object.id
@is_praise = PraiseTread.find_by_sql("select * from praise_treads where user_id=#{user_id} and " +
"praise_tread_object_type='#{@obj_type}' and praise_tread_object_id=#{@obj_id} ")
return @is_praise
end
#end
def get_praise_num(object)
@obj_type = object.class.name.underscore
@obj_id = object.id
@record = PraiseTreadCache.find_by_object_id_and_object_type(@obj_id,@obj_type)
if @record
return @record.praise_num
else
return 0
end
end
end

@ -85,7 +85,7 @@ module ProjectsHelper
# this method is used to get all projects that tagged one tag
# added by william
def get_projects_by_tag(tag_name)
Project.tagged_with(tag_name)
Project.tagged_with(tag_name).by_join_date
end
end

@ -58,7 +58,7 @@ module UsersHelper
# this method is used to get all projects that tagged one tag
# added by william
def get_users_by_tag(tag_name)
User.tagged_with(tag_name)
User.tagged_with(tag_name).by_join_date
end
end

@ -60,7 +60,8 @@ class Issue < ActiveRecord::Base
###########################added by william
acts_as_taggable
scope :by_join_date, order("created_at DESC")
##end
DONE_RATIO_OPTIONS = %w(issue_field issue_status)
attr_reader :current_journal

@ -0,0 +1,4 @@
class PraiseTread < ActiveRecord::Base
attr_accessible :user_id,:praise_tread_object_id,:praise_tread_object_type,:praise_or_tread
end

@ -0,0 +1,11 @@
class PraiseTreadCache < ActiveRecord::Base
attr_accessible :object_id,:object_type,:praise_num,:tread_num
def plus(num)
self.update_attribute(:praise_num, self.praise_num.to_i + num)
end
def minus(num)
self.update_attribute(:praise_num, self.praise_num.to_i - num)
end
end

@ -78,7 +78,7 @@ class Project < ActiveRecord::Base
:author => nil
############################added by william
acts_as_taggable
scope :by_join_date, order("created_at DESC")
###################added by liuping 关注
acts_as_watchable

@ -102,8 +102,8 @@ class User < Principal
acts_as_customizable
############################added by william
acts_as_taggable
acts_as_taggable
scope :by_join_date, order("created_at DESC")
############################# added by liuping 关注
acts_as_watchable

@ -4,7 +4,7 @@
<!-- 1代表是user类型 2代表是project类型 3代表是issue类型 -->
<!-- 3 代表的是issue 当是issue是 处理方式与前2个对象不同 -->
<% if object_flag == '3' %>
<%= toggle_link (image_tag "/images/sidebar/add.png"), 'put-tag-form-issue', {:focus => 'name'} %>
<%= toggle_link (image_tag "/images/sidebar/add.png"), 'put-tag-form-issue', {:focus => 'name-issue'} %>
<div id="tags_show_issue">
<%= render :partial => "layouts/tag_name",:locals => {:obj => obj,:non_list_all => false ,:object_flag => object_flag} %>
</div>

@ -30,7 +30,7 @@
<div class="inf_user_image">
<table>
<tr>
<td><%= link_to image_tag(avatar_image(@project), :class => 'avatar') %></td>
<td><%= link_to image_tag(url_to_avatar(@project), :class => 'avatar') %></td>
<td align="center">
<div class="info_font">
<%= textilizable @project.name %>
@ -42,6 +42,7 @@
</div></td>
</tr>
</table>
<!--tags-->
<div class="tags">
<!-- added by william -for tag -->

@ -10,6 +10,7 @@
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
<!-- page specific tags -->
@ -44,10 +45,15 @@
</table></td>
</tr>
</table>
<div id="praise_tread">
<%= render :partial => "/praise_tread/praise_tread",:locals => {:obj => @user,:show_flag => false,:user_id => User.current.id}%>
</div>
<div>
<%= l(:label_user_watcher) %> (<strong class="font_small_watch"><%= User.watched_by(@user.id).count %></strong>) &nbsp;
<%= l(:label_user_fans) %> (<strong class="font_small_watch"><%= @user.watcher_users.count %></strong>)
</div>
</div>
</div>
<div class="user_underline"></div>
<!--info-->
@ -70,7 +76,7 @@
<div class="user_fans">
<div class="font_title_left">
<strong><%= l(:label_user_watcher) %>(<%= link_to User.watched_by(@user.id).count %>)</strong>
<strong><%= l(:label_user_watcher) %>(<%= link_to User.watched_by(@user.id).count, :controller=>"users",:action=>"user_watchlist" %>)</strong>
</div>
<div class="left_wf">
@ -87,7 +93,7 @@
<!--fans-->
<div class="user_fans">
<div class="font_title_left">
<strong><%= l(:label_user_fans) %>(<%= link_to @user.watcher_users.count %>)</strong>
<strong><%= l(:label_user_fans) %>(<%= link_to @user.watcher_users.count,:controller=>"users",:action=>"user_fanslist" %>)</strong>
</div>
<div class="left_wf">
<table>

@ -0,0 +1,17 @@
<div id="praise">
<% if is_praise_or_tread(obj,user_id).size > 0 %>
<%= image_tag("/images/praise.png") %>
<%= link_to "取消贊",:controller=>"praise_tread",:action=>"praise_minus",:remote=>true,:obj => obj %>
(<%= get_praise_num(obj)%>)
<% else %>
<%= image_tag("/images/tread.png") %>
<%= link_to "贊",:controller=>"praise_tread",:action=>"praise_plus",:remote=>true,:obj => obj %>
(<%= get_praise_num(obj)%>)
<% end %>
</div>
<% if show_flag %>
<div id="tread">
<%= link_to image_tag("/images/tread.png"),:controller=>"praise_tread",
:action=>"tread_minus",:remote=>true,:obj => obj %>踩
</div>
<% end %>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save