|
|
|
@ -1,12 +1,29 @@
|
|
|
|
|
class ForumsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# GET /forums
|
|
|
|
|
# GET /forums.json
|
|
|
|
|
def index
|
|
|
|
|
@forums = Forum.all
|
|
|
|
|
# @forums = Forum.all
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html # index.html.erb
|
|
|
|
|
format.json { render json: @forums }
|
|
|
|
|
format.html {
|
|
|
|
|
scope = Forum
|
|
|
|
|
unless params[:closed]
|
|
|
|
|
scope = scope.active
|
|
|
|
|
end
|
|
|
|
|
@forums = scope.visible.order('lft').all
|
|
|
|
|
}
|
|
|
|
|
format.api {
|
|
|
|
|
@offset, @limit = api_offset_and_limit
|
|
|
|
|
@project_count = Forum.visible.count
|
|
|
|
|
@projects = Forum.visible.offset(@offset).limit(@limit).order('lft').all
|
|
|
|
|
}
|
|
|
|
|
format.atom {
|
|
|
|
|
projects = Forum.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
|
|
|
|
render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -15,9 +32,30 @@ class ForumsController < ApplicationController
|
|
|
|
|
def show
|
|
|
|
|
@forum = Forum.find(params[:id])
|
|
|
|
|
|
|
|
|
|
# # try to redirect to the requested menu item
|
|
|
|
|
# if params[:jump] && redirect_to_project_menu_item(@project, params[:jump])
|
|
|
|
|
# return
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
@users_by_role = @forum.users_by_role
|
|
|
|
|
# @subprojects = @project.children.visible.all
|
|
|
|
|
# @news = @project.news.limit(5).includes(:author, :project).reorder("#{News.table_name}.created_on DESC").all
|
|
|
|
|
# @trackers = @project.rolled_up_trackers
|
|
|
|
|
|
|
|
|
|
# cond = @project.project_condition(Setting.display_subprojects_issues?)
|
|
|
|
|
|
|
|
|
|
# @open_issues_by_tracker = Issue.visible.open.where(cond).count(:group => :tracker)
|
|
|
|
|
# @total_issues_by_tracker = Issue.visible.where(cond).count(:group => :tracker)
|
|
|
|
|
|
|
|
|
|
# if User.current.allowed_to?(:view_time_entries, @project)
|
|
|
|
|
# @total_hours = TimeEntry.visible.sum(:hours, :include => :project, :conditions => cond).to_f
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
@key = User.current.rss_key
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html # show.html.erb
|
|
|
|
|
format.json { render json: @forum }
|
|
|
|
|
format.html
|
|
|
|
|
format.api
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -26,6 +64,11 @@ class ForumsController < ApplicationController
|
|
|
|
|
def new
|
|
|
|
|
@forum = Forum.new
|
|
|
|
|
|
|
|
|
|
# @issue_custom_fields = IssueCustomField.sorted.all
|
|
|
|
|
# @trackers = Tracker.sorted.all
|
|
|
|
|
# @project = Project.new
|
|
|
|
|
@forum.safe_attributes = params[:forum]
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html # new.html.erb
|
|
|
|
|
format.json { render json: @forum }
|
|
|
|
@ -40,15 +83,37 @@ class ForumsController < ApplicationController
|
|
|
|
|
# POST /forums
|
|
|
|
|
# POST /forums.json
|
|
|
|
|
def create
|
|
|
|
|
@forum = Forum.new(params[:forum])
|
|
|
|
|
# @forum = Forum.new(params[:forum])
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
if @forum.save
|
|
|
|
|
format.html { redirect_to @forum, notice: 'Forum was successfully created.' }
|
|
|
|
|
format.json { render json: @forum, status: :created, location: @forum }
|
|
|
|
|
else
|
|
|
|
|
format.html { render action: "new" }
|
|
|
|
|
format.json { render json: @forum.errors, status: :unprocessable_entity }
|
|
|
|
|
# @issue_custom_fields = IssueCustomField.sorted.all
|
|
|
|
|
# @trackers = Tracker.sorted.all
|
|
|
|
|
@forum = Forum.new
|
|
|
|
|
@project.safe_attributes = params[:project]
|
|
|
|
|
|
|
|
|
|
if @forum.save
|
|
|
|
|
# @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
|
|
|
|
|
# Add current user as a project member if he is not admin
|
|
|
|
|
unless User.current.admin?
|
|
|
|
|
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
|
|
|
|
|
m = Member.new(:user => User.current, :roles => [r])
|
|
|
|
|
@forum.members << m
|
|
|
|
|
end
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html {
|
|
|
|
|
flash[:notice] = l(:notice_successful_create)
|
|
|
|
|
# if params[:continue]
|
|
|
|
|
# attrs = {:parent_id => @forum.parent_id}.reject {|k,v| v.nil?}
|
|
|
|
|
# redirect_to new_project_path(attrs)
|
|
|
|
|
# else
|
|
|
|
|
redirect_to settings_project_path(@forum)
|
|
|
|
|
# end
|
|
|
|
|
}
|
|
|
|
|
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'forums', :action => 'show', :id => @forum.id) }
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html { render :action => 'new' }
|
|
|
|
|
format.api { render_validation_errors(@forum) }
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -58,13 +123,23 @@ class ForumsController < ApplicationController
|
|
|
|
|
def update
|
|
|
|
|
@forum = Forum.find(params[:id])
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
if @forum.update_attributes(params[:forum])
|
|
|
|
|
format.html { redirect_to @forum, notice: 'Forum was successfully updated.' }
|
|
|
|
|
format.json { head :no_content }
|
|
|
|
|
else
|
|
|
|
|
format.html { render action: "edit" }
|
|
|
|
|
format.json { render json: @forum.errors, status: :unprocessable_entity }
|
|
|
|
|
@forum.safe_attributes = params[:project]
|
|
|
|
|
if @forum.save
|
|
|
|
|
# @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html {
|
|
|
|
|
flash[:notice] = l(:notice_successful_update)
|
|
|
|
|
redirect_to settings_project_path(@forum)
|
|
|
|
|
}
|
|
|
|
|
format.api { render_api_ok }
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html {
|
|
|
|
|
settings
|
|
|
|
|
render :action => 'settings'
|
|
|
|
|
}
|
|
|
|
|
format.api { render_validation_errors(@forum) }
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -73,11 +148,17 @@ class ForumsController < ApplicationController
|
|
|
|
|
# DELETE /forums/1.json
|
|
|
|
|
def destroy
|
|
|
|
|
@forum = Forum.find(params[:id])
|
|
|
|
|
@forum.destroy
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html { redirect_to forums_url }
|
|
|
|
|
format.json { head :no_content }
|
|
|
|
|
# @forum.destroy
|
|
|
|
|
|
|
|
|
|
@project_to_destroy = @forum
|
|
|
|
|
if api_request? || params[:confirm]
|
|
|
|
|
@project_to_destroy.destroy
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html { redirect_to admin_projects_path }
|
|
|
|
|
format.api { render_api_ok }
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
# hide project in layout
|
|
|
|
|
@project = nil
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|