exceptionHandle
z9hang 11 years ago
commit a80da022cb

1
.gitignore vendored

@ -1,3 +1,4 @@
*.swp
/.project
/.idea
/.bundle

@ -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,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,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,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/

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

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

@ -0,0 +1,114 @@
class ApplyProjectMastersController < ApplicationController
before_filter :require_login, :find_apply, :only => [:create, :delete]
# GET /apply_project_masters
# GET /apply_project_masters.json
def index
@apply_project_masters = ApplyProjectMaster.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @apply_project_masters }
end
end
# GET /apply_project_masters/1
# GET /apply_project_masters/1.json
def show
@apply_project_master = ApplyProjectMaster.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @apply_project_master }
end
end
# GET /apply_project_masters/new
# GET /apply_project_masters/new.json
def new
@apply_project_master = ApplyProjectMaster.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @apply_project_master }
end
end
# GET /apply_project_masters/1/edit
def edit
@apply_project_master = ApplyProjectMaster.find(params[:id])
end
# POST /apply_project_masters
# POST /apply_project_masters.json
def create
# @apply_project_master = ApplyProjectMaster.new(params[:apply_project_master])
#
# respond_to do |format|
# if @apply_project_master.save
# format.html { redirect_to @apply_project_master, notice: 'Apply project master was successfully created.' }
# format.json { render json: @apply_project_master, status: :created, location: @apply_project_master }
# else
# format.html { render action: "new" }
# format.json { render json: @apply_project_master.errors, status: :unprocessable_entity }
# end
# end
set_apply(@apply, User.current, true)
end
# PUT /apply_project_masters/1
# PUT /apply_project_masters/1.json
def update
@apply_project_master = ApplyProjectMaster.find(params[:id])
respond_to do |format|
if @apply_project_master.update_attributes(params[:apply_project_master])
format.html { redirect_to @apply_project_master, notice: 'Apply project master was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @apply_project_master.errors, status: :unprocessable_entity }
end
end
end
# DELETE /apply_project_masters/1
# DELETE /apply_project_masters/1.json
def destroy
@apply_project_master = ApplyProjectMaster.find(params[:id])
@apply_project_master.destroy
respond_to do |format|
format.html { redirect_to apply_project_masters_url }
format.json { head :no_content }
end
end
def delete
set_apply(@apply, User.current, false)
end
private
def find_apply
klass = Object.const_get(params[:object_type].camelcase) rescue nil
if klass && klass.respond_to?('applied_by')
@apply = klass.find_all_by_id(Array.wrap(params[:object_id]))
end
render_404 unless @apply.present?
end
#flag标注功能为1时设置申请版主为0时设置取消
def set_apply(objects, user, flag)
objects.each do |object|
object.set_apply(user, flag)
end
respond_to do |format|
format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
format.js { render :partial => 'set_apply', :locals => {:user => user, :objects => objects} }
end
end
end

@ -30,6 +30,7 @@ class AutoCompletesController < ApplicationController
@issues.compact!
end
render :layout => false
end
private

@ -53,7 +53,7 @@ class FilesController < ApplicationController
def create
container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id]))
attachments = Attachment.attach_files(container, params[:attachments])
attachments = Attachment.attach_filesex(container, params[:attachments],params[:attachment_type])
render_attachment_warning_if_needed(container)
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
@ -61,4 +61,8 @@ class FilesController < ApplicationController
end
redirect_to project_files_path(@project)
end
def show_by_attachtype
end
end

@ -148,7 +148,8 @@ class MemosController < ApplicationController
def find_memo
return unless find_forum
@memo = @forum.memos.find(params[:id])
#@memo = @forum.memos.find(params[:id])
@memo = Memo.find(params[:id])
rescue ActiveRecord::RecordNotFound
render_404
nil

@ -0,0 +1,111 @@
class NoUsesController < ApplicationController
before_filter :require_login, :find_no_use, :only => [:create, :delete]
# GET /no_uses
# GET /no_uses.json
def index
@no_uses = NoUse.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @no_uses }
end
end
# GET /no_uses/1
# GET /no_uses/1.json
def show
@no_use = NoUse.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @no_use }
end
end
# GET /no_uses/new
# GET /no_uses/new.json
def new
@no_use = NoUse.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @no_use }
end
end
# GET /no_uses/1/edit
def edit
@no_use = NoUse.find(params[:id])
end
# POST /no_uses
# POST /no_uses.json
def create
set_no_use(@no_use, User.current, true)
# respond_to do |format|
# if @no_use.save
# format.html { redirect_to @no_use, notice: 'No use was successfully created.' }
# format.json { render json: @no_use, status: :created, location: @no_use }
# else
# format.html { render action: "new" }
# format.json { render json: @no_use.errors, status: :unprocessable_entity }
# end
# end
end
def delete
set_no_use(@no_use, User.current, false)
end
# PUT /no_uses/1
# PUT /no_uses/1.json
def update
@no_use = NoUse.find(params[:id])
respond_to do |format|
if @no_use.update_attributes(params[:no_use])
format.html { redirect_to @no_use, notice: 'No use was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @no_use.errors, status: :unprocessable_entity }
end
end
end
# DELETE /no_uses/1
# DELETE /no_uses/1.json
def destroy
# @no_use = NoUse.find(params[:id])
# @no_use.destroy
set_no_use(@no_use, User.current, false)
# respond_to do |format|
# format.html { redirect_to no_uses_url }
# format.json { head :no_content }
# end
end
private
def find_no_use
klass = Object.const_get(params[:object_type].camelcase) rescue nil
if klass && klass.respond_to?('no_use_for')
@no_use = klass.find_all_by_id(Array.wrap(params[:object_id]))
end
render_404 unless @no_use.present?
end
#flag标注功能为1时设置没有帮助为0时设置取消
def set_no_use(objects, user, flag)
objects.each do |object|
object.set_no_use(user, flag)
end
respond_to do |format|
format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
format.js { render :partial => 'set_no_use', :locals => {:user => user, :objects => objects} }
end
end
end

@ -0,0 +1,190 @@
class OpenSourceProjectsController < ApplicationController
before_filter :find_osp, :only => [:master_apply, :accept_master_apply, :refuse_master_apply]
before_filter :require_master, :only => [:master_apply, :accept_master_apply, :refuse_master_apply]
helper :sort
include SortHelper
helper :apply_project_masters
include ApplyProjectMastersHelper
helper :no_uses
include NoUsesHelper
# GET /open_source_projects
# GET /open_source_projects.json
def index
@app_dir = params[:app_dir]
@language = params[:language]
@created_at = params[:created_at]
per_page_option = 10
@open_source_projects = OpenSourceProject.filter(@app_dir, @language, @created_at)
@open_source_projects = @open_source_projects.like(params[:name]) if params[:name].present?
@os_project_count = @open_source_projects.count
@os_project_pages = Paginator.new @os_project_count, per_page_option, params['page']
@open_source_projects = @open_source_projects.offset(@os_project_pages.offset).limit(@os_project_pages.per_page)
# @open_source_projects = OpenSourceProject.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @open_source_projects }
end
end
def master_apply
@apply = @open_source_project.apply_tips
@applicants = @open_source_project.applicants
respond_to do |format|
format.html {
render :layout => "base_opensource_p"
}
format.json { render json: @open_source_project }
end
end
# GET /open_source_projects/1
# GET /open_source_projects/1.json
def show
@open_source_project = OpenSourceProject.find(params[:id])
sort_init 'updated_at', 'desc'
sort_update 'created_at' => "#{RelativeMemo.table_name}.created_at",
'replies' => "#{RelativeMemo.table_name}.replies_count",
'updated_at' => "COALESCE (last_replies_relative_memos.created_at, #{RelativeMemo.table_name}.created_at)"
@memo = RelativeMemo.new(:open_source_project => @open_source_project)
@topic_count = @open_source_project.topics.count
@topic_pages = Paginator.new @topic_count, per_page_option, params['page']
@memos = @open_source_project.topics.
reorder("#{RelativeMemo.table_name}.sticky DESC").
includes(:last_reply).
limit(@topic_pages.per_page).
offset(@topic_pages.offset).
order(sort_clause).
all
respond_to do |format|
format.html {
render :layout => "base_opensource_p"
}
format.json { render json: @open_source_project }
end
end
def search
end
# GET /open_source_projects/new
# GET /open_source_projects/new.json
def new
@open_source_project = OpenSourceProject.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @open_source_project }
end
end
# GET /open_source_projects/1/edit
def edit
@open_source_project = OpenSourceProject.find(params[:id])
end
# POST /open_source_projects
# POST /open_source_projects.json
def create
@open_source_project = OpenSourceProject.new(params[:open_source_project])
respond_to do |format|
if @open_source_project.save
format.html { redirect_to @open_source_project, notice: 'Open source project was successfully created.' }
format.json { render json: @open_source_project, status: :created, location: @open_source_project }
else
format.html { render action: "new" }
format.json { render json: @open_source_project.errors, status: :unprocessable_entity }
end
end
end
# PUT /open_source_projects/1
# PUT /open_source_projects/1.json
def update
@open_source_project = OpenSourceProject.find(params[:id])
respond_to do |format|
if @open_source_project.update_attributes(params[:open_source_project])
format.html { redirect_to @open_source_project, notice: 'Open source project was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @open_source_project.errors, status: :unprocessable_entity }
end
end
end
# DELETE /open_source_projects/1
# DELETE /open_source_projects/1.json
def destroy
@open_source_project = OpenSourceProject.find(params[:id])
@open_source_project.destroy
respond_to do |format|
format.html { redirect_to open_source_projects_url }
format.json { head :no_content }
end
end
def remove_condition
@app_dir = params[:app_dir]
@language = params[:language]
@created_at = params[:created_at]
redirect_to open_source_projects_path(:app_dir => @app_dir, :language => @language, :created_at => @created_at, :name => params[:name])
end
def search
# per_page_option = 10
#
# @open_source_projects = OpenSourceProject.filter(@app_dir, @language, @created_at)
# @open_source_projects = @open_source_projects.like(params[:name]) if params[:name].present?
#
# @os_project_count = @open_source_projects.count
# @os_project_pages = Paginator.new @os_project_count, per_page_option, params['page']
#
# @open_source_projects = @open_source_projects.offset(@os_project_pages.offset).limit(@os_project_pages.per_page)
redirect_to open_source_projects_path(:name => params[:name])
end
def refuse_master_apply
@apply = ApplyProjectMaster.where("user_id = ? and apply_id = ? and apply_type = 'OpenSourceProject'", params[:user_id], @open_source_project.id)
@apply.first.destory
redirect_to master_apply_open_source_project_path
end
def accept_master_apply
@apply = ApplyProjectMaster.where("user_id = ? and apply_id = ? and apply_type = 'OpenSourceProject'", params[:user_id], @open_source_project.id)
if @apply.count == 1
@apply.first.update_attributes(:status => 2)
end
redirect_to master_apply_open_source_project_path
end
private
def require_master
render_403 unless @open_source_project.admin?(User.current)
end
def find_osp
@open_source_project = OpenSourceProject.find(params[:id])
render_404 unless @open_source_project.present?
end
end

File diff suppressed because it is too large Load Diff

@ -0,0 +1,161 @@
class RelativeMemosController < ApplicationController
helper :sort
include SortHelper
helper :apply_project_masters
include ApplyProjectMastersHelper
helper :no_uses
include NoUsesHelper
before_filter :find_memo, :except => [:new, :create]
before_filter :find_osp, :only => [:create]
before_filter :require_login, :only => [:new, :create]
layout 'base_opensource_p'
# GET /open_source_projects
# GET /open_source_projects.json
def index
# per_page_option = 10
#
# @open_source_projects = OpenSourceProject.all
#
# @os_project_count = @open_source_projects.count
# @os_project_pages = Paginator.new @os_project_count, per_page_option, params['page']
#
# @open_source_projects = OpenSourceProject.all
#
# respond_to do |format|
# format.html # index.html.erb
# format.json { render json: @open_source_projects }
# end
end
# GET /open_source_projects/1
# GET /open_source_projects/1.json
REPLIES_PER_PAGE = 10 unless const_defined?(:REPLIES_PER_PAGE)
def show
pre_count = REPLIES_PER_PAGE
@memo = @memo.root # 取出楼主防止输入帖子id让回复作为主贴显示
@memo.update_column(:viewed_count_local, (@memo.viewed_count_local.to_i + 1))
page = params[:page]
if params[:r] && page.nil?
offset = @memo.children.where("#{Memo.table_name}.id < ?", params[:r].to_i).count
page = 1 + offset / pre_count
else
end
@reply_count = @memo.children.count
@reply_pages = Paginator.new @reply_count, pre_count, page
@replies = @memo.children.
includes(:author, :attachments).
reorder("#{RelativeMemo.table_name}.created_at ASC").
limit(@reply_pages.per_page).
offset(@reply_pages.offset).
all
@mome_new = RelativeMemo.new
# @memo = Memo.find_by_id(params[:id])
# @forum = Forum.find(params[:forum_id])
# @replies = @memo.replies
# @mome_new = Memo.new
respond_to do |format|
format.html # show.html.erb
format.json { render json: @memo }
end
end
# GET /open_source_projects/new
# GET /open_source_projects/new.json
def new
@open_source_project = OpenSourceProject.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @open_source_project }
end
end
# GET /open_source_projects/1/edit
def edit
@open_source_project = OpenSourceProject.find(params[:id])
end
# POST /open_source_projects
# POST /open_source_projects.json
def create
@memo = RelativeMemo.new(params[:relative_memo])
# @memo.url = "http://forge.trustie.net/open_source_projects"
@memo.osp_id = params[:open_source_project_id]
@memo.author_id = User.current.id
@memo.save_attachments(params[:attachments] || (params[:relative_memo] && params[:relative_memo][:uploads]))
respond_to do |format|
if @memo.save
format.html { redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}" }
format.json { render json: @memo, status: :created, location: @memo }
else
flash[:error] = "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}"
# back_error_page = @memo.parent_id.nil? ? forum_path(@forum) : forum_memo_path(@forum, @memo.parent_id)
format.html { redirect_to back_memo_url}#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" }
format.json { render json: @memo.errors, status: :unprocessable_entity }
end
end
end
# PUT /open_source_projects/1
# PUT /open_source_projects/1.json
def update
@open_source_project = OpenSourceProject.find(params[:id])
respond_to do |format|
if @open_source_project.update_attributes(params[:open_source_project])
format.html { redirect_to @open_source_project, notice: 'Open source project was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @open_source_project.errors, status: :unprocessable_entity }
end
end
end
# DELETE /open_source_projects/1
# DELETE /open_source_projects/1.json
def destroy
@open_source_project = OpenSourceProject.find(params[:id])
@open_source_project.destroy
respond_to do |format|
format.html { redirect_to open_source_projects_url }
format.json { head :no_content }
end
end
private
def find_memo
return unless find_osp
@memo = @open_source_project.relative_memos.find(params[:id])
rescue ActiveRecord::RecordNotFound
render_404
nil
end
def find_osp
@open_source_project = OpenSourceProject.find(params[:open_source_project_id])
rescue ActiveRecord::RecordNotFound
render_404
nil
end
def back_memo_url
open_source_project_relative_memo_path(@open_source_project, (@memo.parent_id.nil? ? @memo : @memo.parent_id))
end
end

@ -32,6 +32,19 @@ class SchoolController < ApplicationController
def index
end
def get_province
@provinces = School.find_by_sql("select distinct province from schools")
options = ""
@provinces.each do |p|
options << "<option value = '#{p.province}' >#{p.province}</option>"
end
render :text => options
end
def get_options
@school = School.where("province = ?", params[:province])

@ -56,8 +56,10 @@ class SoftapplicationsController < ApplicationController
@stars_status_map = Hash.new(0.0)
stars_status.each do |star_status|
percent = percent_of(star_status.scount, stars_reates_count).to_f
percent_m = format("%.2f", percent)
@stars_status_map["star#{star_status.stars.to_i}".to_sym] =
percent_of(star_status.scount, stars_reates_count).to_s + "%"
percent_m.to_s + "%"
end
@jours = @softapplication.journals_for_messages.order('created_on DESC')
@image_results = []

@ -16,6 +16,7 @@ class TagsController < ApplicationController
helper :projects
include TagsHelper
helper :tags
include OpenSourceProjectsHelper
before_filter :require_admin,:only => [:delete,:show_all]
@ -58,7 +59,7 @@ class TagsController < ApplicationController
end
@users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num,@contests_tags_num,
@forum_tags_num, @attachments_tags_num = get_tags_size
@forum_tags_num, @attachments_tags_num, @open_source_projects_num = get_tags_size
# 获取搜索结果
@obj,@obj_pages,@results_count,@users_results,
@ -67,7 +68,8 @@ class TagsController < ApplicationController
@bids_results,
@forums_results,
@attachments_results,
@contests_tags = refresh_results(@obj_id,@obj_flag,@selected_tags)
@contests_tags,
@open_source_projects_results = refresh_results(@obj_id,@obj_flag,@selected_tags)
# 这里是做tag推荐用的 用来生产推荐的tags
unless @obj.nil?
@ -182,6 +184,7 @@ class TagsController < ApplicationController
@contests_results = nil
@forums_results = nil
attachments_results = nil
@open_source_projects_results = nil
@obj_pages = nil
@obj = nil
@result = nil
@ -213,10 +216,13 @@ class TagsController < ApplicationController
when '7'
@obj = Contest.find_by_id(obj_id)
@obj_pages,@contests_results,@results_count = for_pagination(get_contests_by_tag(selected_tags))
when '8'
@obj = OpenSourceProject.find_by_id(obj_id)
@obj_pages, @open_source_projects_results, @results_count = for_pagination(get_open_source_projects_by_tag(selected_tags))
else
@obj = nil
end
return [@obj,
return [@obj,
@obj_pages,
@results_count,
@users_results,
@ -225,7 +231,8 @@ class TagsController < ApplicationController
@bids_results,
@forums_results,
attachments_results,
@contests_results]
@contests_results,
@open_source_projects_results]
end
def for_pagination(results)
@ -245,8 +252,9 @@ class TagsController < ApplicationController
@bids_tags_num = Bid.tag_counts.size
forum_tags_num = Forum.tag_counts.size
attachment_tags_num = Attachment.tag_counts.size
@open_source_projects_num = OpenSourceProject.tag_counts.size
@contests_tags_num = Contest.tag_counts.size
return @users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num, forum_tags_num, attachment_tags_num, @contests_tags_num
return @users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num, forum_tags_num, attachment_tags_num, @contests_tags_num, @open_source_projects_num
end
# 通过数字 来转换出对象的类型
@ -269,6 +277,8 @@ class TagsController < ApplicationController
return 'Attachment'
when '7'
return 'Contest'
when '8'
return 'OpenSourceProject'
else
render_error :message => e.message
return

@ -658,6 +658,8 @@ class UsersController < ApplicationController
@obj = Attachment.find_by_id(@obj_id)
when '7' then
@obj = Contest.find_by_id(@obj_id)
when '8'
@obj = OpenSourceProject.find_by_id(@obj_id)
else
@obj = nil
end

@ -442,6 +442,10 @@ module ApplicationHelper
def authoring(created, author, options={})
l(options[:label] || :label_added_time_by, :author => link_to_user(author), :age => time_tag(created)).html_safe
end
def added_time(created)
l(:label_added_time, :age => time_tag(created)).html_safe
end
#huang
def betweentime(enddate)

@ -0,0 +1,31 @@
module ApplyProjectMastersHelper
def apply_super_user(objects, user, options=[])
return '' unless user && user.logged?
objects = Array.wrap(objects)
applied = objects.any? {|object| object.applied_by?(user)}
allowed = objects.any? {|object| object.allowed?(user)}
# @watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or (objects.first.instance_of?(Bid)))
# css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) :
# ([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s)
css = apply_css(objects) << options[0].to_s
text = applied ? (allowed ? l(:you_are_master) : l(:cancel_apply)) : l(:apply_master)
url = apply_project_masters_path(
:object_type => objects.first.class.to_s.underscore,
:object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort)
)
method = applied ? 'delete' : 'post'
link_to text, url, :remote => true, :method => method, :class => css
end
def apply_css(objects)
objects = Array.wrap(objects)
id = (objects.size == 1 ? objects.first.id : 'bulk')
"#{objects.first.class.to_s.underscore}-#{id}-watcher"
end
end

@ -0,0 +1,28 @@
module NoUsesHelper
def no_use_link(objects, user, options=[])
return '' unless user && user.logged?
objects = Array.wrap(objects)
clicked = objects.any? {|object| object.no_use_for?(user)}
# @watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or (objects.first.instance_of?(Bid)))
css = no_use_css(objects) << options[0].to_s
# ([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s)
text = clicked ? l(:cancel_no_use) : l(:no_use)
url = no_uses_path(
:object_type => objects.first.class.to_s.underscore,
:object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort)
)
method = clicked ? 'delete' : 'post'
link_to text, url, :remote => true, :method => method, :class => css
#, :class => css
end
def no_use_css(objects)
objects = Array.wrap(objects)
id = (objects.size == 1 ? objects.first.id : 'bulk')
"#{objects.first.class.to_s.underscore}-#{id}-watcher"
end
end

@ -0,0 +1,37 @@
module OpenSourceProjectsHelper
def show_condition(app_dir, language, created_at, name)
s=''.html_safe
unless app_dir.nil?
s_temp = content_tag('a', app_dir)
temp = link_to 'x', {:controller => "open_source_projects", :action => "remove_condition", :language => language, :created_at => created_at, :name => name}
temp = content_tag('span', temp, :class => 'del')
s_temp << temp
s_temp = content_tag('span', s_temp, :class => 'tag_show')
s << content_tag('div', s_temp, :id => 'tag')
end
unless language.nil?
s_temp = content_tag('a', language)
temp = link_to 'x', {:controller => "open_source_projects", :action => "remove_condition", :app_dir => app_dir, :created_at => created_at, :name => name}
temp = content_tag('span', temp, :class => 'del')
s_temp << temp
s_temp = content_tag('span', s_temp, :class => 'tag_show')
s << content_tag('div', s_temp, :id => 'tag')
end
unless created_at.nil?
s_temp = content_tag('a', created_at)
temp = link_to 'x', {:controller => "open_source_projects", :action => "remove_condition", :app_dir => app_dir, :language => language, :name => name}
temp = content_tag('span', temp, :class => 'del')
s_temp << temp
s_temp = content_tag('span', s_temp, :class => 'tag_show')
s << content_tag('div', s_temp, :id => 'tag')
end
s = content_tag('div', s, :id => 'tags_show')
s = content_tag('div', s, :id => 'tags')
s = content_tag('div', s, :class => 'user_tags')
end
def get_open_source_projects_by_tag(tag_name)
OpenSourceProject.tagged_with(tag_name).order('created_at desc')
end
end

@ -297,6 +297,14 @@ module UserScoreHelper
return (commit_count + issue_details_count)
end
def calculate_attachments(user)
attachments = Attachment.where("container_type IS NOT NULL AND container_type <> 'Issue' AND author_id = ?", user.id).count
return attachments
end
def calculate_user_score(user)
collaboration = calculate_collaboration_count(user)

@ -0,0 +1,16 @@
class ApplyProjectMaster < ActiveRecord::Base
# attr_accessible :title, :body
# status 1是申请者2是版主
belongs_to :apply, :polymorphic => true
belongs_to :user
validates_presence_of :user
validates_uniqueness_of :user_id, :scope => [:apply_type, :apply_id]
validate :validate_user
protected
def validate_user
errors.add :user_id, :invalid unless user.nil? || user.active?
end
end

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

Loading…
Cancel
Save