Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
commit
a80da022cb
@ -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,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,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
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue