Conflicts: app/controllers/tags_controller.rb app/views/tags/_tag.html.erb app/views/tags/_tag_search_results.html.erb app/views/tags/index.html.erb config/locales/zh.yml config/routes.rb db/schema.rbexceptionHandle
commit
2c8580a4e8
@ -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
|
@ -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(:no_use) : l(:cancel_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
|
@ -0,0 +1,15 @@
|
||||
class NoUse < ActiveRecord::Base
|
||||
# attr_accessible :title, :body
|
||||
belongs_to :no_use, :polymorphic => true
|
||||
belongs_to :user
|
||||
|
||||
validates_presence_of :user
|
||||
validates_uniqueness_of :user_id, :scope => [:no_use_type, :no_use_id]
|
||||
validate :validate_user
|
||||
|
||||
protected
|
||||
|
||||
def validate_user
|
||||
errors.add :user_id, :invalid unless user.nil? || user.active?
|
||||
end
|
||||
end
|
@ -0,0 +1,134 @@
|
||||
class OpenSourceProject < ActiveRecord::Base
|
||||
attr_accessible :name
|
||||
|
||||
include Redmine::SafeAttributes
|
||||
has_many :applies, :class_name => "ApplyProjectMaster", :as => :apply, :dependent => :delete_all
|
||||
has_many :topics, :class_name => 'RelativeMemo', :foreign_key => 'osp_id', :conditions => "#{RelativeMemo.table_name}.parent_id IS NULL", :order => "#{RelativeMemo.table_name}.created_at DESC", :dependent => :destroy
|
||||
has_many :relative_memos, :class_name => 'RelativeMemo', :foreign_key => 'osp_id', :dependent => :destroy
|
||||
has_many :tags, :through => :project_tags, :class_name => 'Tag'
|
||||
has_many :project_tags, :class_name => 'ProjectTags'
|
||||
has_many :masters, :class_name => 'ApplyProjectMaster', :as => :apply, :dependent => :delete_all, :conditions => "#{ApplyProjectMaster.table_name}.status = 2"
|
||||
has_many :admin, :through => :masters, :class_name => 'User'
|
||||
has_many :apply_tips, :class_name => 'ApplyProjectMaster', :as => :apply, :dependent => :delete_all, :conditions => "#{ApplyProjectMaster.table_name}.status = 1"
|
||||
has_many :applicants, :class_name => 'User', :through => :apply_tips, :source => :user
|
||||
|
||||
validates_uniqueness_of :name
|
||||
|
||||
acts_as_taggable
|
||||
|
||||
scope :applied_by, lambda { |user_id|
|
||||
{ :include => :apply_project_master,
|
||||
:conditions => ["#{ApplyProjectMaster.table_name}.user_id = ?", user_id]
|
||||
}
|
||||
}
|
||||
scope :like, lambda {|arg|
|
||||
if arg.blank?
|
||||
where(nil)
|
||||
else
|
||||
pattern = "%#{arg.to_s.strip.downcase}%"
|
||||
where("LOWER(name) LIKE :p OR LOWER(description) LIKE :p ", :p => pattern)
|
||||
end
|
||||
}
|
||||
def filter(app_dir, language, created_at)
|
||||
filter_app_dir(app_dir).filter_language(language).filter_time(created_at)
|
||||
end
|
||||
|
||||
def self.filter(app_dir, language, created_at)
|
||||
self.filter_app_dir(app_dir).filter_language(language).filter_time(created_at)
|
||||
end
|
||||
|
||||
scope :filter_app_dir, lambda {|args|
|
||||
nil
|
||||
}
|
||||
|
||||
scope :filter_language, lambda {|*arg|
|
||||
if arg[0].nil?
|
||||
where(nil)
|
||||
else
|
||||
tagged_with(arg).order('updated_at desc')
|
||||
end
|
||||
}
|
||||
|
||||
scope :filter_time, lambda {|args|
|
||||
where("YEAR(#{OpenSourceProject.table_name}.created_at) = ?", args) unless args.nil?
|
||||
}
|
||||
|
||||
# def filter_app_dir(app_dir)
|
||||
# nil
|
||||
# end
|
||||
#
|
||||
# def self.filter_app_dir(app_dir)
|
||||
# nil
|
||||
# end
|
||||
#
|
||||
# def filter_language(language)
|
||||
# nil
|
||||
# end
|
||||
#
|
||||
# def self.filter_language(language)
|
||||
# nil
|
||||
# end
|
||||
#
|
||||
# def filter_time(created_at)
|
||||
# nil
|
||||
# end
|
||||
#
|
||||
# def self.filter_time(created_at)
|
||||
# nil
|
||||
# end
|
||||
|
||||
def short_description(length = 255)
|
||||
description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||
end
|
||||
|
||||
def applied_by?(user)
|
||||
self.applies.each do |apply|
|
||||
if apply.user_id == user.id
|
||||
return true
|
||||
end
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
def allowed?(user)
|
||||
self.applies.each do |apply|
|
||||
if apply.user_id == user.id and apply.status == 2
|
||||
return true
|
||||
end
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
def set_apply(user, flag=true)
|
||||
flag ? set_filter(user) : remove_filter(user)
|
||||
end
|
||||
|
||||
def set_filter(user)
|
||||
self.applies << ApplyProjectMaster.new(:user => user, :status => 1)
|
||||
end
|
||||
|
||||
def remove_filter(user)
|
||||
return nil unless user && user.is_a?(User)
|
||||
ApplyProjectMaster.delete_all "apply_type = '#{self.class}' AND apply_id = #{self.id} AND user_id = #{user.id}"
|
||||
end
|
||||
|
||||
def admin?(user)
|
||||
if user.admin? or ApplyProjectMaster.find(:all, :conditions => ["user_id = ? and apply_type = 'OpenSourceProject' and apply_id = ? and status = ?", user.id, self.id, 2]).present?
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def reset_counters!
|
||||
self.class.reset_counters!(id)
|
||||
end
|
||||
|
||||
def self.reset_counters!(id)
|
||||
osp_id = id.to_i
|
||||
update_all("topic_count = (SELECT COUNT(*) FROM #{RelativeMemo.table_name} WHERE osp_id=#{osp_id} AND parent_id IS NULL)," +
|
||||
" memo_count = (SELECT COUNT(*) FROM #{RelativeMemo.table_name} WHERE osp_id=#{osp_id} AND parent_id IS NOT NULL)," +
|
||||
" last_memo_id = (SELECT MAX(id) FROM #{RelativeMemo.table_name} WHERE osp_id=#{osp_id})",
|
||||
["id = ?", osp_id])
|
||||
end
|
||||
end
|
@ -0,0 +1,185 @@
|
||||
class RelativeMemo < ActiveRecord::Base
|
||||
# attr_accessible :title, :body
|
||||
include Redmine::SafeAttributes
|
||||
belongs_to :open_source_project, :class_name => "OpenSourceProject", :foreign_key => 'osp_id'
|
||||
belongs_to :author, :class_name => "User", :foreign_key => 'author_id'
|
||||
|
||||
has_many :tags, :through => :project_tags, :class_name => 'Tag'
|
||||
has_many :project_tags, :class_name => 'ProjectTags'
|
||||
|
||||
has_many :no_uses, :as => :no_use, :dependent => :delete_all
|
||||
|
||||
acts_as_taggable
|
||||
acts_as_attachable
|
||||
|
||||
validates_presence_of :osp_id, :subject
|
||||
#validates :content, presence: true
|
||||
# validates_length_of :subject, maximum: 50
|
||||
#validates_length_of :content, maximum: 3072
|
||||
validate :cannot_reply_to_locked_topic, :on => :create
|
||||
validates_uniqueness_of :osp_id, :scope => [:subject, :context]
|
||||
|
||||
acts_as_tree :counter_cache => :replies_count, :order => "#{RelativeMemo.table_name}.created_at ASC"
|
||||
acts_as_attachable
|
||||
belongs_to :last_reply, :class_name => 'RelativeMemo', :foreign_key => 'last_reply_id'
|
||||
# acts_as_searchable :column => ['subject', 'content'],
|
||||
# #:include => { :forum => :p}
|
||||
# #:project_key => "#{Forum.table_name}.project_id"
|
||||
# :date_column => "#{table_name}.created_at"
|
||||
|
||||
# acts_as_event :title => Proc.new {|o| "#{o.forum.name}: #{o.subject}"},
|
||||
# :datetime => :updated_at,
|
||||
# # :datetime => :created_at,
|
||||
# :description => :content,
|
||||
# :author => :author,
|
||||
# :type => Proc.new {|o| o.parent_id.nil? ? 'Memo' : 'Reply'},
|
||||
# :url => Proc.new {|o| {:controller => 'memos', :action => 'show', :forum_id => o.forum_id}.merge(o.parent_id.nil? ? {:id => o.id} : {:id => o.parent_id, :r => o.id, :anchor => "reply-#{o.id}"})}
|
||||
# acts_as_activity_provider :author_key => :author_id,
|
||||
# :func => 'memos',
|
||||
# :timestamp => 'created_at'
|
||||
|
||||
# :find_options => {:type => 'memos'}
|
||||
# acts_as_watchable
|
||||
|
||||
safe_attributes "author_id",
|
||||
"subject",
|
||||
"content",
|
||||
"osp_id",
|
||||
"last_memo_id",
|
||||
"lock",
|
||||
"sticky",
|
||||
"parent_id",
|
||||
"replies_count",
|
||||
"is_quote"
|
||||
|
||||
after_create :add_author_as_watcher, :reset_counters!
|
||||
# after_update :update_memos_forum
|
||||
after_destroy :reset_counters!
|
||||
# after_create :send_notification
|
||||
# after_save :plusParentAndForum
|
||||
# after_destroy :minusParentAndForum
|
||||
|
||||
# scope :visible, lambda { |*args|
|
||||
# includes(:forum => ).where()
|
||||
# }
|
||||
|
||||
def cannot_reply_to_locked_topic
|
||||
errors.add :base, l(:label_memo_locked) if root.locked? && self != root
|
||||
end
|
||||
|
||||
# def update_memos_forum
|
||||
# if forum_id_changed?
|
||||
# Message.update_all({:board_id => board_id}, ["id = ? OR parent_id = ?", root.id, root.id ])
|
||||
# Forum.reset_counters!(forum_id_was)
|
||||
# Forum.reset_counters!(forum_id)
|
||||
# end
|
||||
# end
|
||||
|
||||
|
||||
scope :no_use_for, lambda { |user_id|
|
||||
{ :include => :no_uses,
|
||||
:conditions => ["#{NoUse.table_name}.user_id = ?", user_id] }
|
||||
}
|
||||
|
||||
def no_use_for?(user)
|
||||
self.no_uses.each do |no_use|
|
||||
if no_use.user_id == user.id
|
||||
return true
|
||||
end
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
def set_no_use(user, flag=true)
|
||||
flag ? set_filter(user) : remove_filter(user)
|
||||
end
|
||||
|
||||
def set_filter(user)
|
||||
self.no_uses << NoUse.new(:user => user)
|
||||
end
|
||||
|
||||
def remove_filter(user)
|
||||
return nil unless user && user.is_a?(User)
|
||||
NoUse.delete_all "no_use_type = '#{self.class}' AND no_use_id = #{self.id} AND user_id = #{user.id}"
|
||||
end
|
||||
|
||||
def reset_counters!
|
||||
if parent && parent.id
|
||||
RelativeMemo.update_all({:last_reply_id => parent.children.maximum(:id)}, {:id => parent.id})
|
||||
parent.update_attribute(:updated_at, Time.now)
|
||||
end
|
||||
# forum.reset_counters!
|
||||
end
|
||||
|
||||
def sticky?
|
||||
sticky == 1
|
||||
end
|
||||
|
||||
def replies
|
||||
RelativeMemo.where("parent_id = ?", id)
|
||||
end
|
||||
|
||||
def locked?
|
||||
self.lock
|
||||
end
|
||||
|
||||
def editable_by? user
|
||||
# user && user.logged? || (self.author == usr && usr.allowed_to?(:edit_own_messages, project))
|
||||
user.admin?
|
||||
end
|
||||
|
||||
# def destroyable_by? user
|
||||
# (user && user.logged? && (Forum.find(self.forum_id).creator_id == user.id) ) || user.admin?
|
||||
# #self.author == user || user.admin?
|
||||
# end
|
||||
|
||||
def deleted_attach_able_by? user
|
||||
(user && user.logged? && (self.author == user) ) || user.admin?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def add_author_as_watcher
|
||||
Watcher.create(:watchable => self.root, :user => author)
|
||||
end
|
||||
|
||||
def send_notification
|
||||
if Setting.notified_events.include?('message_posted')
|
||||
Mailer.message_posted(self).deliver
|
||||
end
|
||||
end
|
||||
|
||||
# def plusParentAndForum
|
||||
# @forum = Forum.find(self.forum_id)
|
||||
# @forum.memo_count = @forum.memo_count.to_int + 1
|
||||
# @forum.last_memo_id = self.id
|
||||
# if self.parent_id
|
||||
# @parent_memo = Memo.find_by_id(self.parent_id)
|
||||
# @parent_memo.last_reply_id = self
|
||||
# @parent_memo.replies_count = @parent_memo.replies_count.to_int + 1
|
||||
# @parent_memo.save
|
||||
# else
|
||||
# @forum.topic_count = @forum.topic_count.to_int + 1
|
||||
# end
|
||||
# @forum.save
|
||||
# end
|
||||
|
||||
# def minusParentAndForum
|
||||
# @forum = Forum.find(self.forum_id)
|
||||
# @forum.memo_count = @forum.memo_count.to_int - 1
|
||||
# @forum.memo_count = 0 if @forum.memo_count.to_int < 0
|
||||
# # @forum.last_memo_id = Memo.reorder('created_at ASC').find_all_by_forum_id(self.forum_id).last.id
|
||||
# if self.parent_id
|
||||
# @parent_memo = Memo.find_by_id(self.parent_id)
|
||||
# # @parent_memo.last_reply_id = Memo.reorder('created_at ASC').find_all_by_parent_id(self.parent_id).last.id
|
||||
# @parent_memo.replies_count = @parent_memo.replies_count.to_int - 1
|
||||
# @parent_memo.replies_count = 0 if @parent_memo.replies_count.to_int < 0
|
||||
# @parent_memo.save
|
||||
# else
|
||||
# @forum.topic_count = @forum.topic_count.to_int - 1
|
||||
# @forum.topic_count = 0 if @forum.topic_count.to_int < 0
|
||||
# end
|
||||
# @forum.save
|
||||
# end
|
||||
end
|
||||
|
@ -0,0 +1,17 @@
|
||||
<%= form_for(@apply_project_master) do |f| %>
|
||||
<% if @apply_project_master.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@apply_project_master.errors.count, "error") %> prohibited this apply_project_master from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% @apply_project_master.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
@ -0,0 +1,2 @@
|
||||
<% selector = ".#{apply_css(objects)}" %>
|
||||
$("<%= selector %>").each(function(){$(this).replaceWith("<%= escape_javascript apply_super_user(objects, user) %>")});
|
@ -0,0 +1,6 @@
|
||||
<h1>Editing apply_project_master</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @apply_project_master %> |
|
||||
<%= link_to 'Back', apply_project_masters_path %>
|
@ -0,0 +1,21 @@
|
||||
<h1>Listing apply_project_masters</h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% @apply_project_masters.each do |apply_project_master| %>
|
||||
<tr>
|
||||
<td><%= link_to 'Show', apply_project_master %></td>
|
||||
<td><%= link_to 'Edit', edit_apply_project_master_path(apply_project_master) %></td>
|
||||
<td><%= link_to 'Destroy', apply_project_master, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
<%= link_to 'New Apply project master', new_apply_project_master_path %>
|
@ -0,0 +1,5 @@
|
||||
<h1>New apply_project_master</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', apply_project_masters_path %>
|
@ -0,0 +1,5 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
|
||||
<%= link_to 'Edit', edit_apply_project_master_path(@apply_project_master) %> |
|
||||
<%= link_to 'Back', apply_project_masters_path %>
|
@ -0,0 +1,17 @@
|
||||
<%= form_for(@no_use) do |f| %>
|
||||
<% if @no_use.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@no_use.errors.count, "error") %> prohibited this no_use from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% @no_use.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
@ -0,0 +1,2 @@
|
||||
<% selector = ".#{no_use_css(objects)}" %>
|
||||
$("<%= selector %>").each(function(){$(this).replaceWith("<%= escape_javascript no_use_link(objects, user) %>")});
|
@ -0,0 +1,6 @@
|
||||
<h1>Editing no_use</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @no_use %> |
|
||||
<%= link_to 'Back', no_uses_path %>
|
@ -0,0 +1,21 @@
|
||||
<h1>Listing no_uses</h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% @no_uses.each do |no_use| %>
|
||||
<tr>
|
||||
<td><%= link_to 'Show', no_use %></td>
|
||||
<td><%= link_to 'Edit', edit_no_use_path(no_use) %></td>
|
||||
<td><%= link_to 'Destroy', no_use, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
<%= link_to 'New No use', new_no_use_path %>
|
@ -0,0 +1,5 @@
|
||||
<h1>New no_use</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', no_uses_path %>
|
@ -0,0 +1,5 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
|
||||
<%= link_to 'Edit', edit_no_use_path(@no_use) %> |
|
||||
<%= link_to 'Back', no_uses_path %>
|
@ -0,0 +1,21 @@
|
||||
<%= form_for(@open_source_project) do |f| %>
|
||||
<% if @open_source_project.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@open_source_project.errors.count, "error") %> prohibited this open_source_project from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% @open_source_project.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :String %><br />
|
||||
<%= f.text_field :String %>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
@ -0,0 +1,68 @@
|
||||
<style>
|
||||
.information .stats a{
|
||||
width: 80px;
|
||||
text-align: right;
|
||||
display: inline-block;
|
||||
font-weight: bold;
|
||||
font-style: 1.2em;
|
||||
}
|
||||
.information .stats span{
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
||||
<div class="project-block">
|
||||
<div class="img-tag">
|
||||
<%= image_tag('../images/avatars/Project/0', :class => 'avatar2') %>
|
||||
</div>
|
||||
<div class="wiki-description">
|
||||
<p>
|
||||
<%= textilizable(project.short_description, :project => project) %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="information">
|
||||
<p class="stats">
|
||||
<%= link_to project.users_count %>
|
||||
<%= content_tag('span', l(:label_x_follow_people,:count =>0)) %>
|
||||
</p>
|
||||
<p class="stats">
|
||||
<%=link_to 1%>
|
||||
<%= content_tag('span', l(:label_x_current_contributors, :count => 0)) %>
|
||||
</p>
|
||||
<p class="stats">
|
||||
<%=link_to project.commit_count %>
|
||||
<%= content_tag('span', l(:label_since_last_commits)) %>
|
||||
</p>
|
||||
<p class="stats">
|
||||
<%=link_to project.code_line %>
|
||||
<%= content_tag('span', "行代码") %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="add-info">
|
||||
<div class="main-language">
|
||||
|
||||
<%= content_tag('span', "#{l(:default_role_manager)}: ") %>
|
||||
|
||||
</div>
|
||||
<div class="licences">
|
||||
<%= content_tag('span', "#{l(:label_create_time)}: ") %><%= content_tag('span', format_time(project.created_at)) %>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="url">
|
||||
<div class="main-language">
|
||||
<%= content_tag('span', "项目来源:")%><%= link_to project.url, project.url %>
|
||||
</div>
|
||||
<div class="licences">
|
||||
<%= content_tag('span', "数据更新时间:") %><%= content_tag('span', project.date_collected) %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tags">
|
||||
<div id="tags">
|
||||
<%= image_tag( "/images/sidebar/tags.png") %>
|
||||
<%= render :partial => 'tags/tag_name', :locals => {:obj => project,:object_flag => "7",:non_list_all => true }%>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,67 @@
|
||||
<!-- added by fq -->
|
||||
<!--display the board-->
|
||||
<div class="borad-topic-count">
|
||||
共有 <%= link_to memos.count %> 个贴子
|
||||
</div>
|
||||
<div style="padding-top: 10px">
|
||||
<% if memos.any? %>
|
||||
<% memos.each do |topic| %>
|
||||
<table class="content-text-list">
|
||||
<tr>
|
||||
<td colspan="2" valign="top" width="50" ><%= link_to image_tag(url_to_avatar(topic.author), :class => "avatar"), user_path(topic.author) if topic.author%>
|
||||
<%= image_tag('../images/avatars/User/0', :class => "avatar") unless topic.author%> </td>
|
||||
<td>
|
||||
<table width="630px" border="0">
|
||||
<tr>
|
||||
<td valign="top" width="500px" class="<%= topic.sticky ? 'sticky' : '' %> <%= topic.locked? ? 'locked' : '' %>"><%= link_to h(topic.subject), open_source_project_relative_memo_path(topic.open_source_project, topic) %></td>
|
||||
<td align="right" rowspan="3">
|
||||
<table class="borad-count">
|
||||
<tr>
|
||||
<td align="center" class="borad-count-digit"><%= link_to (topic.replies_count), open_source_project_relative_memo_path(topic.open_source_project, topic) %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">回答</td>
|
||||
</tr>
|
||||
</table></td>
|
||||
<td align="right" rowspan="3">
|
||||
<table class="borad-count">
|
||||
<tr>
|
||||
<td align="center" class="borad-count-digit"><%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), open_source_project_relative_memo_path(topic.open_source_project, topic) %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">浏览</td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" ><span class="font_description"> </span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" colspan="2" ><span class="font_lighter"><%#= authoring topic.created_at, topic.author %>
|
||||
<br />
|
||||
</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" colspan="2" ><span class="font_lighter">帖子来源:<%= link_to topic.url, topic.url%> </span></td>
|
||||
<td align="left"><%= no_use_link(topic, User.current) %> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" colspan="2"> <%= image_tag( "/images/sidebar/tags.png") %>
|
||||
<%= render :partial => 'tags/tag_name', :locals => {:obj => topic,:object_flag => "9",:non_list_all => true }%> </td>
|
||||
</tr>
|
||||
|
||||
</table></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<% end %>
|
||||
<div class="pagination">
|
||||
<%= pagination_links_full @topic_pages, @topic_count %>
|
||||
</div>
|
||||
<% else %>
|
||||
<p class="nodata">
|
||||
<%= l(:label_no_data) %>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
@ -0,0 +1,6 @@
|
||||
<h1>Editing open_source_project</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @open_source_project %> |
|
||||
<%= link_to 'Back', open_source_projects_path %>
|
@ -0,0 +1,5 @@
|
||||
<h1>New open_source_project</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', open_source_projects_path %>
|
@ -0,0 +1,54 @@
|
||||
<!-- added by fq -->
|
||||
<div id="add-memo" class='lz' style="display: none; padding: 20px;">
|
||||
<h3><%=l(:label_memo_new)%></h3>
|
||||
<% if User.current.logged? %>
|
||||
<%= labelled_form_for(@memo, :url => open_source_project_relative_memos_path(@open_source_project), :html => {:multipart => true} ) do |f| %>
|
||||
<% if @memo.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@memo.errors.count, "error") %> prohibited this memo from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% @memo.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="actions" style="max-width:680px">
|
||||
<p><%= f.text_field :subject, :required => true%></p>
|
||||
<p style="max-width:680px"><%= f.text_area :content, :required => true, :id => 'editor02' %></p>
|
||||
<script type="text/javascript">var ckeditor=CKEDITOR.replace('editor02');</script>
|
||||
<br/>
|
||||
<p>
|
||||
<%#= l(:label_attachment_plural) %><br />
|
||||
<%#= render :partial => 'attachments/form', :locals => {:container => @memo} %>
|
||||
</p>
|
||||
<%= f.submit :value => l(:label_memo_create) %>
|
||||
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-memo").hide(); return false;' %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<!--modified by huang-->
|
||||
<% #= link_to '发布帖子', new_forum_memo_path(@forum), :class => 'icon icon-add' %>
|
||||
<span>
|
||||
<%= link_to l(:label_memo_new_from_forum), new_open_source_project_relative_memo_path(@open_source_project), :class => 'icon icon-add',
|
||||
:onclick => 'showAndScrollTo("add-memo", "memo_subject"); return false;' if User.current.logged? %>
|
||||
</span>
|
||||
|
||||
<div class="contextual-borad">
|
||||
<%#= link_to(
|
||||
image_tag('edit.png')+l(:label_forum_edit),
|
||||
{:action => 'edit', :id => @forum},
|
||||
:method => 'get',
|
||||
:title => l(:button_edit)
|
||||
) if @forum.editable_by?(User.current) %>
|
||||
<%#= link_to(
|
||||
image_tag('delete.png')+'删除讨论区',
|
||||
{:action => 'destroy', :id => @forum},
|
||||
:method => :delete,
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:title => l(:button_delete)
|
||||
) if @forum.destroyable_by?(User.current) %>
|
||||
</div>
|
||||
<%= render :partial => 'open_source_projects/show_topics', :locals => {:memos => @memos} %>
|
@ -0,0 +1,14 @@
|
||||
<%= form_for(@mome_new, url: open_source_project_relative_memos_path, :html => {:multipart => true}) do |f| %>
|
||||
<%= f.hidden_field :subject, :required => true, value: @memo.subject %>
|
||||
<%= f.hidden_field :osp_id, :required => true, value: @memo.osp_id %>
|
||||
<%= f.hidden_field :parent_id, :required => true, value: @memo.id %>
|
||||
<%= label_tag(l(:label_reply_plural)) %>:
|
||||
<!-- <p> < %= f.text_area :content, :required => true, :size => "75%", :resize => "none", id: 'editor01' %> </p> -->
|
||||
<%= f.text_area :content, :cols => 80, :rows => 15, :class => 'wiki-edit', :id => 'editor01', :value => @content %></p>
|
||||
|
||||
<script type="text/javascript">var ckeditor=CKEDITOR.replace('editor01');</script>
|
||||
<p><%#= l(:label_attachment_plural) %><br />
|
||||
<%#= render :partial => 'attachments/form' %>
|
||||
</p>
|
||||
<%= f.submit value: l(:label_reply_plural), class: "replies" %>
|
||||
<% end %>
|
@ -0,0 +1,164 @@
|
||||
<div class="lz">
|
||||
<div class="lz-left">
|
||||
<div class="">
|
||||
<% if @memo.author%>
|
||||
<%= link_to image_tag(url_to_avatar(@memo.author), :class => "avatar"), user_path(@memo.author) %>
|
||||
<% else %>
|
||||
<%= image_tag('../images/avatars/User/0', :class => "avatar") %>
|
||||
<% end %></div>
|
||||
<p class=""><%=link_to @memo.author.name, user_path(@memo.author) if @memo.author%></p>
|
||||
</div>
|
||||
<div class="memo-section">
|
||||
<div class="contextual-borad">
|
||||
<!-- <%#= link_to(
|
||||
image_tag('comment.png'),
|
||||
{:action => 'quote', :id => @memo},
|
||||
:remote => true,
|
||||
:method => 'get',
|
||||
:title => l(:button_quote)
|
||||
)if !@memo.locked? && User.current.logged? %> -->
|
||||
<%#= link_to(
|
||||
l(:button_quote),
|
||||
{:action => 'quote', :id => @memo},
|
||||
:remote => true,
|
||||
:method => 'get',
|
||||
:title => l(:button_quote)
|
||||
)if !@memo.locked? && User.current.logged? %>
|
||||
|
||||
<%#= link_to(
|
||||
image_tag('edit.png'),
|
||||
{:action => 'edit', :id => @memo},
|
||||
:method => 'get',
|
||||
:title => l(:button_edit)
|
||||
) if @memo.editable_by?(User.current) %>
|
||||
<!-- <%#= link_to(
|
||||
image_tag('delete.png'),
|
||||
{:action => 'destroy', :id => @memo},
|
||||
:method => :delete,
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:title => l(:button_delete)
|
||||
) if @memo.destroyable_by?(User.current) %> -->
|
||||
<%#= link_to(
|
||||
l(:button_delete),
|
||||
{:action => 'destroy', :id => @memo},
|
||||
:method => :delete,
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:title => l(:button_delete)
|
||||
) if @memo.destroyable_by?(User.current) %>
|
||||
</div>
|
||||
|
||||
<div class="memo-title <%= @memo.sticky ? 'sticky' : '' %> <%= @memo.locked? ? 'locked' : '' %>"><%= label_tag l(:field_subject) %>: <%=h @memo.subject %></div>
|
||||
<div class="memo-content">
|
||||
<!-- < %= textilizable(@memo, :content) %> -->
|
||||
<%= raw @memo.content %>
|
||||
<p>
|
||||
<% if @memo.attachments.any?%>
|
||||
<% options = {:author => true, :deletable => @memo.deleted_attach_able_by?(User.current) } %>
|
||||
<%= render :partial => 'attachments/links', :locals => {:attachments => @memo.attachments, :options => options} %>
|
||||
<% end %>
|
||||
</p>
|
||||
</div>
|
||||
<div class="memo-timestamp">
|
||||
<% if @memo.author %>
|
||||
<%= authoring @memo.created_at, @memo.author.name %>
|
||||
<% else %>
|
||||
<%= added_time @memo.created_at %>
|
||||
<% end %></div>
|
||||
<div class="tags">
|
||||
<div id="tags">
|
||||
<%= image_tag( "/images/sidebar/tags.png") %>
|
||||
<%= render :partial => 'tags/tag_name', :locals => {:obj => @memo,:object_flag => "8",:non_list_all => true }%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
</div>
|
||||
<div class="replies">
|
||||
<h3 class="comments"><%= l(:label_reply_plural) %> (<%= @replies.nil? ? 0 : @replies.size %>)</h3>
|
||||
<% pages_count = @reply_pages.offset %>
|
||||
<% @replies.each do |reply| %>
|
||||
<div class="reply" id="<%= "reply-#{reply.id}" %>">
|
||||
<p class="font_lighter"><%= pages_count += 1 %>楼 :</p>
|
||||
<div class="contextual-borad">
|
||||
<!-- <%#= link_to(
|
||||
image_tag('comment.png'),
|
||||
{:action => 'quote', :id => reply},
|
||||
:remote => true,
|
||||
:method => 'get',
|
||||
:title => l(:button_quote)
|
||||
)if !@memo.locked? && User.current.logged? %> -->
|
||||
<%#= link_to(
|
||||
l(:button_quote),
|
||||
{:action => 'quote', :id => reply},
|
||||
:remote => true,
|
||||
:method => 'get',
|
||||
:title => l(:button_quote)
|
||||
)if !@memo.locked? && User.current.logged? %>
|
||||
|
||||
<%#= link_to(
|
||||
image_tag('edit.png'),
|
||||
{:action => 'edit', :id => reply},
|
||||
:title => l(:button_edit)
|
||||
) if reply.editable_by?(User.current) %>
|
||||
<!-- <%#= link_to(
|
||||
image_tag('delete.png'),
|
||||
{:action => 'destroy', :id => reply},
|
||||
:method => :delete,
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:title => l(:button_delete)
|
||||
) if reply.destroyable_by?(User.current) %> -->
|
||||
<%#= link_to(
|
||||
l(:button_delete),
|
||||
{:action => 'destroy', :id => reply},
|
||||
:method => :delete,
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:title => l(:button_delete)
|
||||
) if reply.destroyable_by?(User.current) %>
|
||||
|
||||
</div>
|
||||
|
||||
<table class="borad-text-list">
|
||||
<tr>
|
||||
<td rowspan="3" valign="top" width="60px">
|
||||
<% if reply.author%>
|
||||
<%= link_to image_tag(url_to_avatar(reply.author), :class => "avatar"), user_path(reply.author) %>
|
||||
<% else %>
|
||||
<%= image_tag('../images/avatars/User/0', :class => "avatar") %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="comments">
|
||||
<div class="reply_content" ><%=h reply.content.html_safe %></div>
|
||||
<!-- <div class="wiki">< %=h reply.content.html_safe %></div> -->
|
||||
<p>
|
||||
<% if reply.attachments.any?%>
|
||||
<% options = {:author => true, :deletable => reply.deleted_attach_able_by?(User.current) } %>
|
||||
<%= render :partial => 'attachments/links', :locals => {:attachments => reply.attachments, :options => options} %>
|
||||
<% end %>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="font_lighter" style="float:right">
|
||||
<% if reply.author %>
|
||||
<%= authoring reply.created_at, reply.author.name %>
|
||||
<% else %>
|
||||
<%= added_time reply.created_at %>
|
||||
<% end %></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="pagination"><%= pagination_links_full @reply_pages, @reply_count, :per_page_links => false %></div>
|
||||
</div>
|
||||
|
||||
<% if User.current.login? %>
|
||||
<div class="reply-box" style="">
|
||||
<%= render :partial => 'relative_memos/reply_box' %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div style="font-size: 14px;margin:20px;">
|
||||
<%= l(:label_user_login_tips) %>
|
||||
<%= link_to l(:label_user_login_new), signin_path %>
|
||||
<hr/>
|
||||
</div>
|
||||
<% end %>
|
@ -0,0 +1,15 @@
|
||||
<div id="projects">
|
||||
<% if projects_results.size > 0 %>
|
||||
<hr />
|
||||
<% projects_results.each do |prj| %>
|
||||
<div>
|
||||
<p class="font_description2">
|
||||
<strong><%= l(:label_tags_project_name) %><%= link_to "#{prj.name}",:controller => "open_source_projects",:action => "show",:id => prj.id %></strong>
|
||||
<br />
|
||||
<strong><%= l(:label_tags_project_description) %></strong><%= prj.short_description %>
|
||||
</p>
|
||||
</div>
|
||||
<div class="line_under"></div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
@ -0,0 +1,15 @@
|
||||
class CreateOpenSourceProjects < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :open_source_projects do |t|
|
||||
t.column "name", :string, :default => nil, :null => true
|
||||
t.column "description", :string, :default => '', :null => true
|
||||
t.column "commit_count", :integer, :default => 0
|
||||
t.column "code_line", :integer, :default => 0
|
||||
t.column "users_count",:integer, :default => 0
|
||||
t.column "last_commit_time", :date, :null => true
|
||||
t.column "url", :string, :default => nil, :null => true
|
||||
t.column "date_collected", :date, :null => true
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,18 @@
|
||||
class CreateRelativeMemos < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :relative_memos do |t|
|
||||
t.integer :osp_id, :null => false
|
||||
t.integer :parent_id, null: true
|
||||
t.string :subject, null: false
|
||||
t.text :content, null: false
|
||||
t.integer :author_id
|
||||
t.integer :replies_count, default: 0
|
||||
t.integer :last_reply_id
|
||||
t.boolean :lock, default: false
|
||||
t.boolean :sticky, default: false
|
||||
t.boolean :is_quote, default: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,12 @@
|
||||
class CreateApplyProjectMasters < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :apply_project_masters do |t|
|
||||
t.integer :user_id
|
||||
t.string :apply_type
|
||||
t.integer :apply_id
|
||||
t.integer :status
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,11 @@
|
||||
class CreateNoUses < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :no_uses do |t|
|
||||
t.integer :user_id, :null => false
|
||||
t.string :no_use_type
|
||||
t.integer :no_use_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,6 @@
|
||||
class AddViewCountToRelativeMemos < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :relative_memos, :viewed_count_crawl, :int, default: 0
|
||||
add_column :relative_memos, :viewed_count_local, :int, default: 0
|
||||
end
|
||||
end
|
@ -0,0 +1,9 @@
|
||||
class ChangeDescriptionTypeToOpenSourceProject < ActiveRecord::Migration
|
||||
def up
|
||||
change_column :open_source_projects, :description, :text
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddUrlToRelativeMemos < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :relative_memos, :url, :string
|
||||
end
|
||||
end
|
@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||
|
||||
one:
|
||||
act_id:
|
||||
act_type: MyString
|
||||
user_id:
|
||||
|
||||
two:
|
||||
act_id:
|
||||
act_type: MyString
|
||||
user_id:
|
@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||
|
||||
one:
|
||||
journal_id: 1
|
||||
user_id: 1
|
||||
reply_id: 1
|
||||
|
||||
two:
|
||||
journal_id: 1
|
||||
user_id: 1
|
||||
reply_id: 1
|
@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
@ -0,0 +1,7 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||
|
||||
one:
|
||||
String:
|
||||
|
||||
two:
|
||||
String:
|
@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
@ -0,0 +1,49 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ApplyProjectMastersControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@apply_project_master = apply_project_masters(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:apply_project_masters)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create apply_project_master" do
|
||||
assert_difference('ApplyProjectMaster.count') do
|
||||
post :create, apply_project_master: { }
|
||||
end
|
||||
|
||||
assert_redirected_to apply_project_master_path(assigns(:apply_project_master))
|
||||
end
|
||||
|
||||
test "should show apply_project_master" do
|
||||
get :show, id: @apply_project_master
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, id: @apply_project_master
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update apply_project_master" do
|
||||
put :update, id: @apply_project_master, apply_project_master: { }
|
||||
assert_redirected_to apply_project_master_path(assigns(:apply_project_master))
|
||||
end
|
||||
|
||||
test "should destroy apply_project_master" do
|
||||
assert_difference('ApplyProjectMaster.count', -1) do
|
||||
delete :destroy, id: @apply_project_master
|
||||
end
|
||||
|
||||
assert_redirected_to apply_project_masters_path
|
||||
end
|
||||
end
|
@ -0,0 +1,49 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ForumsControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@forum = forums(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:forums)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create forum" do
|
||||
assert_difference('Forum.count') do
|
||||
post :create, forum: { }
|
||||
end
|
||||
|
||||
assert_redirected_to forum_path(assigns(:forum))
|
||||
end
|
||||
|
||||
test "should show forum" do
|
||||
get :show, id: @forum
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, id: @forum
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update forum" do
|
||||
put :update, id: @forum, forum: { }
|
||||
assert_redirected_to forum_path(assigns(:forum))
|
||||
end
|
||||
|
||||
test "should destroy forum" do
|
||||
assert_difference('Forum.count', -1) do
|
||||
delete :destroy, id: @forum
|
||||
end
|
||||
|
||||
assert_redirected_to forums_path
|
||||
end
|
||||
end
|
@ -0,0 +1,49 @@
|
||||
require 'test_helper'
|
||||
|
||||
class NoUsesControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@no_use = no_uses(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:no_uses)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create no_use" do
|
||||
assert_difference('NoUse.count') do
|
||||
post :create, no_use: { }
|
||||
end
|
||||
|
||||
assert_redirected_to no_use_path(assigns(:no_use))
|
||||
end
|
||||
|
||||
test "should show no_use" do
|
||||
get :show, id: @no_use
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, id: @no_use
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update no_use" do
|
||||
put :update, id: @no_use, no_use: { }
|
||||
assert_redirected_to no_use_path(assigns(:no_use))
|
||||
end
|
||||
|
||||
test "should destroy no_use" do
|
||||
assert_difference('NoUse.count', -1) do
|
||||
delete :destroy, id: @no_use
|
||||
end
|
||||
|
||||
assert_redirected_to no_uses_path
|
||||
end
|
||||
end
|
@ -0,0 +1,49 @@
|
||||
require 'test_helper'
|
||||
|
||||
class OpenSourceProjectsControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@open_source_project = open_source_projects(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:open_source_projects)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create open_source_project" do
|
||||
assert_difference('OpenSourceProject.count') do
|
||||
post :create, open_source_project: { String: @open_source_project.String }
|
||||
end
|
||||
|
||||
assert_redirected_to open_source_project_path(assigns(:open_source_project))
|
||||
end
|
||||
|
||||
test "should show open_source_project" do
|
||||
get :show, id: @open_source_project
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, id: @open_source_project
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update open_source_project" do
|
||||
put :update, id: @open_source_project, open_source_project: { String: @open_source_project.String }
|
||||
assert_redirected_to open_source_project_path(assigns(:open_source_project))
|
||||
end
|
||||
|
||||
test "should destroy open_source_project" do
|
||||
assert_difference('OpenSourceProject.count', -1) do
|
||||
delete :destroy, id: @open_source_project
|
||||
end
|
||||
|
||||
assert_redirected_to open_source_projects_path
|
||||
end
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ActivityTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ApplyProjectMasterTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ForumTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
@ -0,0 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ApplyProjectMastersHelperTest < ActionView::TestCase
|
||||
end
|
@ -0,0 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ForumsHelperTest < ActionView::TestCase
|
||||
end
|
@ -0,0 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class NoUsesHelperTest < ActionView::TestCase
|
||||
end
|
@ -0,0 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class OpenSourceProjectsHelperTest < ActionView::TestCase
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class JournalReplyTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class NoUseTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class OpenSourceProjectTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class RelativeMemoTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
Reference in new issue