forked from vician/AgileDwarf
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
3,361 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
class BurndownController < ApplicationController | ||
unloadable | ||
|
||
before_filter :find_project, :authorize | ||
|
||
def show | ||
# data for filters | ||
@sprints = Sprints.all_sprints(@project) | ||
@project_id = @project.id | ||
@assignables = @project.assignable_users | ||
|
||
spentcond = ["time_entries.project_id = ?", @project.id] | ||
restcondtasks = ["project_id = ?", @project.id] | ||
|
||
# sprint filter | ||
@selected = params[:sprint] || 'all' | ||
if @selected == 'none' | ||
spentcond[0] += ' and fixed_version_id is null' | ||
restcondtasks[0] += ' and fixed_version_id is null' | ||
elsif @selected != 'all' | ||
spentcond[0] += ' and fixed_version_id = ?' | ||
spentcond << @selected | ||
restcondtasks[0] += ' and fixed_version_id = ?' | ||
restcondtasks << @selected | ||
end | ||
|
||
# user filter | ||
@user = params[:user] || 'all' | ||
if @user == 'current' | ||
spentcond[0] += ' and user_id = ?' | ||
spentcond << User.current.id | ||
restcondtasks[0] += ' and assigned_to_id = ?' | ||
restcondtasks << User.current.id | ||
elsif @user != 'all' | ||
spentcond[0] += ' and user_id = ?' | ||
spentcond << @user | ||
restcondtasks[0] += ' and assigned_to_id = ?' | ||
restcondtasks << @user | ||
end | ||
|
||
# spent series | ||
spent_arr = [] | ||
TimeEntry.find(:all, :select => 'spent_on, sum(hours) as spent', :conditions => spentcond, :joins => [:issue], :group => 'spent_on').each{|spent| | ||
spent_arr << '["' + spent.spent_on.to_s + '",' + spent.spent + ']' | ||
} | ||
@spent = '[' + spent_arr.join(',') + ']' | ||
|
||
# rest series | ||
# full issue list | ||
@tasks = {} | ||
SprintsTasks.find(:all, :select => 'DATE(created_on) as created_on, id, done_ratio, estimated_hours', :conditions => restcondtasks).each{|task| @tasks[task['id']] = task} | ||
@tasks = @tasks.to_json | ||
# issue changes | ||
@changes = [] | ||
# restcondchanges = ActiveRecord::Base::sanitize_sql(restcondtasks) | ||
restcondchanges = ActiveRecord::Base.send(:sanitize_sql, restcondtasks, '') | ||
ActiveRecord::Base.connection.select_all("select * from (select old_value as value, journalized_id as issueId, prop_key, DATE(journals.created_on) created_on from `journals` inner join journal_details on (journals.id = journal_id) inner join issues on (issues.id = journalized_id) where journalized_type = 'Issue' and property = 'attr' and (prop_key = 'estimated_hours' or prop_key = 'done_ratio') and #{restcondchanges} order by journals.id desc) a group by `issueId`, created_on, prop_key order by created_on desc").each{|row| @changes << row} | ||
@changes = @changes.to_json | ||
end | ||
|
||
private | ||
|
||
def find_project | ||
# @project variable must be set before calling the authorize filter | ||
@project = Project.find(params[:project_id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
class SprintsController < ApplicationController | ||
unloadable | ||
|
||
before_filter :find_project, :authorize | ||
|
||
def create | ||
attribs = params.select{|k,v| k != 'id' and Sprints.column_names.include? k } | ||
attribs = Hash[*attribs.flatten] | ||
sprint = Sprints.new(attribs) | ||
begin | ||
sprint.save! | ||
rescue => e | ||
render :text => e.message.blank? ? e.to_s : e.message, :status => 400 | ||
return | ||
end | ||
|
||
result = sprint.errors.length | ||
status = (result == 0 ? 200 : 400) | ||
|
||
respond_to do |format| | ||
format.html { render :text => sprint.id, :status => status} | ||
end | ||
end | ||
|
||
def inplace | ||
# element_id filtered too! | ||
attribs = params.select{|k,v| k != 'id' && k != 'project_id' && Sprints.column_names.include?(k) } | ||
attribs.flatten! | ||
param_id = attribs[0] | ||
attribs = Hash[*attribs] | ||
sprint = Sprints.find(params[:id]) | ||
begin | ||
result = sprint.update_attributes(attribs) | ||
rescue => e | ||
render :text => e.message.blank? ? e.to_s : e.message, :status => 400 | ||
return | ||
end | ||
|
||
status = (result ? 200 : 400) | ||
sprint.reload | ||
|
||
text = sprint[param_id] | ||
respond_to do |format| | ||
format.html { render :text => text, :status => status } | ||
end | ||
end | ||
|
||
private | ||
|
||
def find_project | ||
# @project variable must be set before calling the authorize filter | ||
@project = Project.find(params[:project_id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class SprintsMainController < ApplicationController | ||
unloadable | ||
|
||
before_filter :find_project, :authorize | ||
|
||
def list | ||
@backlog = SprintsTasks.get_backlog(@project) | ||
@sprints = Sprints.all_sprints(@project) | ||
@sprints.each{|s| s['tasks'] = SprintsTasks.get_tasks_by_sprint(@project, [s.id])} | ||
@assignables = {} | ||
@project.assignable_users.each{|u| @assignables[u.id] = u.firstname + ' ' + u.lastname} | ||
@project_id = @project.id | ||
# TODO: option | ||
@closed_status = 3 | ||
end | ||
|
||
private | ||
|
||
def find_project | ||
# @project variable must be set before calling the authorize filter | ||
@project = Project.find(params[:project_id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
class SprintsMineController < ApplicationController | ||
unloadable | ||
|
||
before_filter :find_project, :authorize | ||
|
||
def list | ||
# data for filters | ||
@sprints = Sprints.open_sprints(@project) | ||
@project_id = @project.id | ||
@assignables = @project.assignable_users | ||
|
||
# filter values | ||
@selected = params[:sprint] || (@sprints[0].nil? ? 'all' : @sprints[0].id.to_s) | ||
case @selected | ||
when 'all' | ||
sprint = nil | ||
when 'none' | ||
sprint = 'null' | ||
else | ||
sprint = @selected | ||
end | ||
user = @user = params[:user] || 'current' | ||
user = nil if @user == 'all' | ||
|
||
# new + in progress + resolved | ||
# TODO: add option for statuses | ||
@columns = [SprintsTasks.get_tasks_by_status(@project, 1, sprint, user), | ||
SprintsTasks.get_tasks_by_status(@project, 2, sprint, user), SprintsTasks.get_tasks_by_status(@project, 3, sprint, user)] | ||
end | ||
|
||
private | ||
|
||
def find_project | ||
# @project variable must be set before calling the authorize filter | ||
@project = Project.find(params[:project_id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
class TasksController < ApplicationController | ||
unloadable | ||
|
||
before_filter :find_project, :authorize | ||
|
||
def update | ||
task = SprintsTasks.find(params[:id]) | ||
begin | ||
result = task.update_and_position!(params) | ||
rescue => e | ||
render :text => e.message.blank? ? e.to_s : e.message, :status => 400 | ||
return | ||
end | ||
|
||
task.reload | ||
status = (result ? 200 : 400) | ||
|
||
respond_to do |format| | ||
format.html { render :nothing => true, :status => status } | ||
end | ||
end | ||
|
||
def create | ||
attribs = params.select{|k,v| k != 'id' and SprintsTasks.column_names.include? k } | ||
attribs = Hash[*attribs.flatten] | ||
# TODO: add tracker setting | ||
attribs['tracker_id'] = attribs['tracker_id'] || 4 | ||
attribs['author_id'] = User.current.id | ||
task = SprintsTasks.new(attribs) | ||
begin | ||
task.save! | ||
rescue => e | ||
render :text => e.message.blank? ? e.to_s : e.message, :status => 400 | ||
return | ||
end | ||
|
||
result = task.errors.length | ||
status = (result == 0 ? 200 : 400) | ||
|
||
respond_to do |format| | ||
format.html { render :text => task.id, :status => status} | ||
end | ||
end | ||
|
||
def tooltip | ||
task = SprintsTasks.find(params[:id]) | ||
text = task.description.blank? ? l(:label_task_field_description_empty) : task.description | ||
text.gsub!(/\n/, '<br/>') | ||
respond_to do |format| | ||
format.html { render :text => text, :status => 200 } | ||
end | ||
end | ||
|
||
def spent | ||
# TODO: add option for activity | ||
spenttime = TimeEntry.new({:hours => params[:hours], :activity_id => 9, :user => User.current, :project => @project, :spent_on => Date.today, :issue_id => params[:id]}) | ||
begin | ||
spenttime.save! | ||
rescue => e | ||
render :text => e.message.blank? ? e.to_s : e.message, :status => 400 | ||
return | ||
end | ||
|
||
result = spenttime.errors.length | ||
status = (result == 0 ? 200 : 400) | ||
|
||
respond_to do |format| | ||
format.html { render :text => spenttime.hours, :status => status } | ||
end | ||
end | ||
|
||
|
||
def inplace | ||
# element_id filtered too! | ||
attribs = params.select{|k,v| k != 'id' && k != 'project_id' && SprintsTasks.column_names.include?(k) } | ||
attribs.flatten! | ||
param_id = attribs[0] | ||
attribs = Hash[*attribs] | ||
task = SprintsTasks.find(params[:id], :include => :assigned_to) | ||
begin | ||
task.init_journal(User.current) | ||
result = task.update_attributes(attribs) | ||
rescue => e | ||
render :text => e.message.blank? ? e.to_s : e.message, :status => 400 | ||
return | ||
end | ||
|
||
status = (result ? 200 : 400) | ||
task.reload | ||
|
||
new_value = param_id == 'assigned_to_id' ? task.assigned_to : task[param_id] | ||
respond_to do |format| | ||
format.html { render :text => new_value, :status => status } | ||
end | ||
end | ||
|
||
private | ||
|
||
def find_project | ||
# @project variable must be set before calling the authorize filter | ||
@project = Project.find(params[:project_id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class Sprints < Version | ||
unloadable | ||
|
||
validate :start_and_end_dates | ||
|
||
named_scope :open_sprints, lambda { |project| | ||
{ | ||
:order => 'ir_start_date ASC, ir_end_date ASC', | ||
:conditions => [ "status = 'open' and project_id = ?", project.id ] | ||
} | ||
} | ||
|
||
named_scope :all_sprints, lambda { |project| | ||
{ | ||
:order => 'ir_start_date ASC, ir_end_date ASC', | ||
:conditions => [ "project_id = ?", project.id ] | ||
} | ||
} | ||
|
||
def start_and_end_dates | ||
errors.add_to_base("Sprint cannot end before it starts") if self.ir_start_date && self.ir_end_date && self.ir_start_date >= self.ir_end_date | ||
end | ||
|
||
def tasks | ||
SprintsTasks.get_tasks_by_sprint(self.project, self.id) | ||
end | ||
|
||
end |
Oops, something went wrong.