添加申请版主功能,目前已经可以写入数据库
This commit is contained in:
parent
976ecc8c89
commit
89b668be82
|
@ -1,4 +1,7 @@
|
||||||
class ApplyProjectMastersController < ApplicationController
|
class ApplyProjectMastersController < ApplicationController
|
||||||
|
|
||||||
|
before_filter :require_login, :find_apply, :only => [:create, :delete]
|
||||||
|
|
||||||
# GET /apply_project_masters
|
# GET /apply_project_masters
|
||||||
# GET /apply_project_masters.json
|
# GET /apply_project_masters.json
|
||||||
def index
|
def index
|
||||||
|
@ -40,17 +43,20 @@ class ApplyProjectMastersController < ApplicationController
|
||||||
# POST /apply_project_masters
|
# POST /apply_project_masters
|
||||||
# POST /apply_project_masters.json
|
# POST /apply_project_masters.json
|
||||||
def create
|
def create
|
||||||
@apply_project_master = ApplyProjectMaster.new(params[:apply_project_master])
|
# @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)
|
||||||
|
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# PUT /apply_project_masters/1
|
# PUT /apply_project_masters/1
|
||||||
|
@ -80,4 +86,29 @@ class ApplyProjectMastersController < ApplicationController
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
class NoUsesController < ApplicationController
|
class NoUsesController < ApplicationController
|
||||||
|
|
||||||
|
before_filter :require_login, :find_no_use, :only => [:create, :delete]
|
||||||
|
|
||||||
# GET /no_uses
|
# GET /no_uses
|
||||||
# GET /no_uses.json
|
# GET /no_uses.json
|
||||||
def index
|
def index
|
||||||
|
@ -40,17 +43,20 @@ class NoUsesController < ApplicationController
|
||||||
# POST /no_uses
|
# POST /no_uses
|
||||||
# POST /no_uses.json
|
# POST /no_uses.json
|
||||||
def create
|
def create
|
||||||
@no_use = NoUse.new(params[:no_use])
|
set_no_use(@no_use, User.current, true)
|
||||||
|
|
||||||
respond_to do |format|
|
# respond_to do |format|
|
||||||
if @no_use.save
|
# if @no_use.save
|
||||||
format.html { redirect_to @no_use, notice: 'No use was successfully created.' }
|
# format.html { redirect_to @no_use, notice: 'No use was successfully created.' }
|
||||||
format.json { render json: @no_use, status: :created, location: @no_use }
|
# format.json { render json: @no_use, status: :created, location: @no_use }
|
||||||
else
|
# else
|
||||||
format.html { render action: "new" }
|
# format.html { render action: "new" }
|
||||||
format.json { render json: @no_use.errors, status: :unprocessable_entity }
|
# format.json { render json: @no_use.errors, status: :unprocessable_entity }
|
||||||
end
|
# end
|
||||||
|
# end
|
||||||
end
|
end
|
||||||
|
def delete
|
||||||
|
set_no_use(@no_use, User.current, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
# PUT /no_uses/1
|
# PUT /no_uses/1
|
||||||
|
@ -72,52 +78,34 @@ class NoUsesController < ApplicationController
|
||||||
# DELETE /no_uses/1
|
# DELETE /no_uses/1
|
||||||
# DELETE /no_uses/1.json
|
# DELETE /no_uses/1.json
|
||||||
def destroy
|
def destroy
|
||||||
@no_use = NoUse.find(params[:id])
|
# @no_use = NoUse.find(params[:id])
|
||||||
@no_use.destroy
|
# @no_use.destroy
|
||||||
|
|
||||||
respond_to do |format|
|
set_no_use(@no_use, User.current, false)
|
||||||
format.html { redirect_to no_uses_url }
|
|
||||||
format.json { head :no_content }
|
# respond_to do |format|
|
||||||
end
|
# format.html { redirect_to no_uses_url }
|
||||||
|
# format.json { head :no_content }
|
||||||
|
# end
|
||||||
end
|
end
|
||||||
private
|
private
|
||||||
|
|
||||||
def find_no_use
|
def find_no_use
|
||||||
klass = Object.const_get(params[:object_type].camelcase) rescue nil
|
klass = Object.const_get(params[:object_type].camelcase) rescue nil
|
||||||
if klass && klass.respond_to?('watched_by')
|
if klass && klass.respond_to?('no_use_for')
|
||||||
@no_use = klass.find_all_by_id(Array.wrap(params[:object_id]))
|
@no_use = klass.find_all_by_id(Array.wrap(params[:object_id]))
|
||||||
end
|
end
|
||||||
render_404 unless @no_use.present?
|
render_404 unless @no_use.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_watcher(watchables, user, watching)
|
#flag标注功能,为1时设置‘没有帮助’,为0时设置取消
|
||||||
watchables.each do |watchable|
|
def set_no_use(objects, user, flag)
|
||||||
watchable.set_watcher(user, watching)
|
objects.each do |object|
|
||||||
# @user = watchable # added by william
|
object.set_no_use(user, flag)
|
||||||
if watching
|
|
||||||
# 修改 user和project的状态
|
|
||||||
if watchable.instance_of?(User)
|
|
||||||
#写user_statuses表
|
|
||||||
UserStatus.find_by_user_id(watchable.id).update_watchers_count(1)
|
|
||||||
elsif watchable.instance_of?(Project)
|
|
||||||
#写project_statuese表
|
|
||||||
ProjectStatus.find_by_project_id(watchable.id).update_watchers_count(1)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
# 修改 user和project的状态
|
|
||||||
if watchable.instance_of?(User)
|
|
||||||
#写user_statuses表
|
|
||||||
UserStatus.find_by_user_id(watchable.id).update_watchers_count(-1)
|
|
||||||
elsif watchable.instance_of?(Project)
|
|
||||||
#写project_statuese表 :project_status
|
|
||||||
ProjectStatus.find_by_project_id(watchable.id).update_watchers_count(-1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
|
format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
|
||||||
format.js { render :partial => 'set_watcher', :locals => {:user => user, :watched => watchables} }
|
format.js { render :partial => 'set_no_use', :locals => {:user => user, :objects => objects} }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,6 +2,15 @@ class RelativeMemosController < ApplicationController
|
||||||
|
|
||||||
helper :sort
|
helper :sort
|
||||||
include SortHelper
|
include SortHelper
|
||||||
|
helper :apply_project_masters
|
||||||
|
include ApplyProjectMastersHelper
|
||||||
|
helper :no_uses
|
||||||
|
include NoUsesHelper
|
||||||
|
|
||||||
|
before_filter :find_memo, :except => [:new, :create]
|
||||||
|
|
||||||
|
layout 'base_opensource_p'
|
||||||
|
|
||||||
# GET /open_source_projects
|
# GET /open_source_projects
|
||||||
# GET /open_source_projects.json
|
# GET /open_source_projects.json
|
||||||
def index
|
def index
|
||||||
|
@ -22,42 +31,41 @@ class RelativeMemosController < ApplicationController
|
||||||
|
|
||||||
# GET /open_source_projects/1
|
# GET /open_source_projects/1
|
||||||
# GET /open_source_projects/1.json
|
# GET /open_source_projects/1.json
|
||||||
|
REPLIES_PER_PAGE = 20 unless const_defined?(:REPLIES_PER_PAGE)
|
||||||
def show
|
def show
|
||||||
# @open_source_project = OpenSourceProject.find(params[:id])
|
pre_count = REPLIES_PER_PAGE
|
||||||
#
|
|
||||||
# sort_init 'updated_at', 'desc'
|
@memo = @memo.root # 取出楼主,防止输入帖子id让回复作为主贴显示
|
||||||
# sort_update 'created_at' => "#{RelativeMemo.table_name}.created_at",
|
@memo.update_column(:viewed_count_local, (@memo.viewed_count_local.to_i + 1))
|
||||||
# 'replies' => "#{RelativeMemo.table_name}.replies_count",
|
|
||||||
# 'updated_at' => "COALESCE (last_replies_relative_memos.created_at, #{RelativeMemo.table_name}.created_at)"
|
page = params[:page]
|
||||||
#
|
if params[:r] && page.nil?
|
||||||
# @memo = RelativeMemo.new(:open_source_project => @open_source_project)
|
offset = @memo.children.where("#{Memo.table_name}.id < ?", params[:r].to_i).count
|
||||||
# @topic_count = @open_source_project.topics.count
|
page = 1 + offset / pre_count
|
||||||
# @topic_pages = Paginator.new @topic_count, per_page_option, params['page']
|
else
|
||||||
# @memos = @open_source_project.topics.
|
|
||||||
# reorder("#{RelativeMemo.table_name}.sticky DESC").
|
end
|
||||||
# includes(:last_reply).
|
@reply_count = @memo.children.count
|
||||||
# limit(@topic_pages.per_page).
|
@reply_pages = Paginator.new @reply_count, pre_count, page
|
||||||
# offset(@topic_pages.offset).
|
@replies = @memo.children.
|
||||||
# order(sort_clause).
|
includes(:author, :attachments).
|
||||||
# all
|
reorder("#{RelativeMemo.table_name}.created_at ASC").
|
||||||
|
limit(@reply_pages.per_page).
|
||||||
|
offset(@reply_pages.offset).
|
||||||
|
all
|
||||||
|
|
||||||
|
@mome_new = Memo.new
|
||||||
|
|
||||||
|
|
||||||
|
# @memo = Memo.find_by_id(params[:id])
|
||||||
|
# @forum = Forum.find(params[:forum_id])
|
||||||
|
# @replies = @memo.replies
|
||||||
|
# @mome_new = Memo.new
|
||||||
|
|
||||||
# @offset, @limit = api_offset_and_limit({:limit => 10})
|
respond_to do |format|
|
||||||
# @forum = Forum.find(params[:id])
|
format.html # show.html.erb
|
||||||
# @memos_all = @forum.topics
|
format.json { render json: @memo }
|
||||||
# @topic_count = @memos_all.count
|
end
|
||||||
# @topic_pages = Paginator.new @topic_count, @limit, params['page']
|
|
||||||
|
|
||||||
# @offset ||= @topic_pages.offset
|
|
||||||
# @memos = @memos_all.offset(@offset).limit(@limit).all
|
|
||||||
|
|
||||||
# respond_to do |format|
|
|
||||||
# format.html {
|
|
||||||
# render :layout => "base_opensource_p"
|
|
||||||
# }
|
|
||||||
# format.json { render json: @open_source_project }
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,4 +128,21 @@ class RelativeMemosController < ApplicationController
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
end
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,15 +9,23 @@ module ApplyProjectMastersHelper
|
||||||
# css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) :
|
# 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)
|
# ([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 ? ("123") : ("123")) : ("231")
|
text = applied ? (allowed ? ("123") : ("123")) : ("231")
|
||||||
|
|
||||||
url = apply_project_master_path(
|
url = apply_project_masters_path(
|
||||||
:object_type => objects.first.class.to_s.underscore,
|
:object_type => objects.first.class.to_s.underscore,
|
||||||
:object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort)
|
:object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort)
|
||||||
)
|
)
|
||||||
method = applied ? 'delete' : 'post'
|
method = applied ? 'delete' : 'post'
|
||||||
|
|
||||||
link_to text, url, :remote => true, :method => method
|
link_to text, url, :remote => true, :method => method, :class => css
|
||||||
#, :class => css
|
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -5,18 +5,24 @@ module NoUsesHelper
|
||||||
|
|
||||||
clicked = objects.any? {|object| object.no_use_for?(user)}
|
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)))
|
# @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) :
|
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)
|
# ([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s)
|
||||||
|
|
||||||
text = clicked ? ("123") : ("231")
|
text = clicked ? l(:no_use) : l(:cancel_no_use)
|
||||||
|
|
||||||
url = apply_project_master_path(
|
url = no_uses_path(
|
||||||
:object_type => objects.first.class.to_s.underscore,
|
:object_type => objects.first.class.to_s.underscore,
|
||||||
:object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort)
|
:object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort)
|
||||||
)
|
)
|
||||||
method = clicked ? 'delete' : 'post'
|
method = clicked ? 'delete' : 'post'
|
||||||
|
|
||||||
link_to text, url, :remote => true, :method => method
|
link_to text, url, :remote => true, :method => method, :class => css
|
||||||
#, :class => css
|
#, :class => css
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
class ApplyProjectMaster < ActiveRecord::Base
|
class ApplyProjectMaster < ActiveRecord::Base
|
||||||
# attr_accessible :title, :body
|
# attr_accessible :title, :body
|
||||||
|
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
|
end
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
class NoUse < ActiveRecord::Base
|
class NoUse < ActiveRecord::Base
|
||||||
# attr_accessible :title, :body
|
# 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
|
end
|
||||||
|
|
|
@ -2,11 +2,21 @@ class OpenSourceProject < ActiveRecord::Base
|
||||||
attr_accessible :String
|
attr_accessible :String
|
||||||
|
|
||||||
include Redmine::SafeAttributes
|
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 :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, :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 :tags, :through => :project_tags, :class_name => 'Tag'
|
||||||
has_many :project_tags, :class_name => 'ProjectTags'
|
has_many :project_tags, :class_name => 'ProjectTags'
|
||||||
|
|
||||||
|
|
||||||
acts_as_taggable
|
acts_as_taggable
|
||||||
|
|
||||||
|
scope :applied_by, lambda { |user_id|
|
||||||
|
{ :include => :apply_project_master,
|
||||||
|
:conditions => ["#{ApplyProjectMaster.table_name}.user_id = ?", user_id] }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def short_description(length = 255)
|
def short_description(length = 255)
|
||||||
description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||||
end
|
end
|
||||||
|
@ -19,6 +29,19 @@ class OpenSourceProject < ActiveRecord::Base
|
||||||
false
|
false
|
||||||
end
|
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 reset_counters!
|
def reset_counters!
|
||||||
self.class.reset_counters!(id)
|
self.class.reset_counters!(id)
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,9 @@ class RelativeMemo < ActiveRecord::Base
|
||||||
|
|
||||||
has_many :tags, :through => :project_tags, :class_name => 'Tag'
|
has_many :tags, :through => :project_tags, :class_name => 'Tag'
|
||||||
has_many :project_tags, :class_name => 'ProjectTags'
|
has_many :project_tags, :class_name => 'ProjectTags'
|
||||||
|
|
||||||
|
has_many :no_uses, :as => :no_use, :dependent => :delete_all
|
||||||
|
|
||||||
acts_as_taggable
|
acts_as_taggable
|
||||||
|
|
||||||
validates_presence_of :osp_id, :subject
|
validates_presence_of :osp_id, :subject
|
||||||
|
@ -77,9 +80,27 @@ class RelativeMemo < ActiveRecord::Base
|
||||||
}
|
}
|
||||||
|
|
||||||
def no_use_for?(user)
|
def no_use_for?(user)
|
||||||
|
self.no_uses.each do |no_use|
|
||||||
|
if no_use.user_id == user.id
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
false
|
false
|
||||||
end
|
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!
|
def reset_counters!
|
||||||
if parent && parent.id
|
if parent && parent.id
|
||||||
RelativeMemo.update_all({:last_reply_id => parent.children.maximum(:id)}, {:id => parent.id})
|
RelativeMemo.update_all({:last_reply_id => parent.children.maximum(:id)}, {:id => parent.id})
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
<% selector = ".#{apply_css(objects)}" %>
|
||||||
|
$("<%= selector %>").each(function(){$(this).replaceWith("<%= escape_javascript apply_super_user(objects, user) %>")});
|
|
@ -0,0 +1,2 @@
|
||||||
|
<% selector = ".#{no_use_css(objects)}" %>
|
||||||
|
$("<%= selector %>").each(function(){$(this).replaceWith("<%= escape_javascript no_use_link(objects, user) %>")});
|
|
@ -149,7 +149,7 @@ li {
|
||||||
<span class="topbar-submit"></span>
|
<span class="topbar-submit"></span>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li>共 <span class="h">1.61万</span> 件宝贝</li>
|
<li>共 <span class="h">1.61万</span> 个开源项目</li>
|
||||||
<li class="related-count"><a href="/search?q=iphone&app=vproduct&vlist=1&from_combo=true">8款相关产品</a></li>
|
<li class="related-count"><a href="/search?q=iphone&app=vproduct&vlist=1&from_combo=true">8款相关产品</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -171,6 +171,19 @@ li {
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="nav-category-group type-block" data-group="type-block">
|
||||||
|
<div class="nav-flexbox ">
|
||||||
|
</div>
|
||||||
|
<div class="nav-flexbox ">
|
||||||
|
</div>
|
||||||
|
<div class="nav-flexbox last">
|
||||||
|
<div class="nav-category">
|
||||||
|
<h4 title="上市时间">
|
||||||
|
<div class="nav-category-wrap ">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,142 @@
|
||||||
|
<div class="lz">
|
||||||
|
<div class="lz-left">
|
||||||
|
<div class=""><%= link_to image_tag(url_to_avatar(@memo.author), :class => "avatar"), user_path(@memo.author) if @memo.author %></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"> <%= authoring @memo.created_at, @memo.author.name if @memo.author %></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">
|
||||||
|
<%= link_to image_tag(url_to_avatar(reply.author), :class => "avatar"), user_path(reply.author) if reply.author %>
|
||||||
|
</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"><%= authoring reply.created_at, reply.author.name if reply.author %></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 => '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 %>
|
|
@ -1806,3 +1806,5 @@ zh:
|
||||||
label_contest_reason: 参赛宣言:
|
label_contest_reason: 参赛宣言:
|
||||||
label_notification: 通知
|
label_notification: 通知
|
||||||
label_sumbit_empty: 搜索内容不能为空
|
label_sumbit_empty: 搜索内容不能为空
|
||||||
|
no_use: 没有帮助
|
||||||
|
cancel_no_use: 撤销没有帮助
|
||||||
|
|
|
@ -17,9 +17,12 @@
|
||||||
|
|
||||||
RedmineApp::Application.routes.draw do
|
RedmineApp::Application.routes.draw do
|
||||||
resources :no_uses
|
resources :no_uses
|
||||||
|
delete 'no_uses', :to => 'no_uses#delete'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resources :apply_project_masters
|
resources :apply_project_masters
|
||||||
|
delete 'apply_project_masters', :to => 'apply_project_masters#delete'
|
||||||
|
|
||||||
|
|
||||||
resources :open_source_projects do
|
resources :open_source_projects do
|
||||||
|
|
|
@ -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
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20140403113341) do
|
ActiveRecord::Schema.define(:version => 20140404031622) do
|
||||||
|
|
||||||
create_table "activities", :force => true do |t|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
@ -201,6 +201,7 @@ ActiveRecord::Schema.define(:version => 20140403113341) do
|
||||||
t.string "setup_time"
|
t.string "setup_time"
|
||||||
t.string "endup_time"
|
t.string "endup_time"
|
||||||
t.string "class_period"
|
t.string "class_period"
|
||||||
|
t.integer "school_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "custom_fields", :force => true do |t|
|
create_table "custom_fields", :force => true do |t|
|
||||||
|
@ -781,6 +782,8 @@ ActiveRecord::Schema.define(:version => 20140403113341) do
|
||||||
t.boolean "is_quote", :default => false
|
t.boolean "is_quote", :default => false
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
|
t.integer "viewed_count_crawl", :default => 0
|
||||||
|
t.integer "viewed_count_local", :default => 0
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "repositories", :force => true do |t|
|
create_table "repositories", :force => true do |t|
|
||||||
|
|
Loading…
Reference in New Issue