mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 15:20:13 +01:00
first cleanups of review feature
This commit is contained in:
parent
7f10c7b963
commit
3a07010338
8 changed files with 46 additions and 66 deletions
|
|
@ -2,7 +2,7 @@ class ProjectsController < ApplicationController
|
|||
|
||||
helper :application, :todos, :notes
|
||||
before_filter :set_source_view
|
||||
before_filter :set_project_from_params, :only => [:update, :destroy, :show, :edit]
|
||||
before_filter :set_project_from_params, :only => [:update, :destroy, :show, :edit, :set_reviewed]
|
||||
before_filter :default_context_filter, :only => [:create, :update]
|
||||
skip_before_filter :login_required, :only => [:index]
|
||||
prepend_before_filter :login_or_feed_token_required, :only => [:index]
|
||||
|
|
@ -34,34 +34,23 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def review
|
||||
## select project that need reviewing
|
||||
@projects_to_review = current_user.projects.select {|p| p.needs_review?(current_user)}
|
||||
|
||||
## select project that are stalled
|
||||
@stalled_projects = current_user.projects.select {|p| p.stalled?}
|
||||
|
||||
## select project that are stalled
|
||||
@blocked_projects = current_user.projects.select {|p| p.blocked?}
|
||||
|
||||
## select projects that are current
|
||||
@current_projects = current_user.projects.select {|p| not(p.needs_review?(current_user))}
|
||||
|
||||
@page_title = t('projects.list_reviews')
|
||||
@projects = current_user.projects.all
|
||||
@contexts = current_user.contexts.all
|
||||
@projects_to_review = current_user.projects.select {|p| p.needs_review?(current_user)}
|
||||
@stalled_projects = current_user.projects.select {|p| p.stalled?}
|
||||
@blocked_projects = current_user.projects.select {|p| p.blocked?}
|
||||
@current_projects = current_user.projects.select {|p| not(p.needs_review?(current_user))}
|
||||
|
||||
init_not_done_counts(['project'])
|
||||
init_project_hidden_todo_counts(['project'])
|
||||
if params[:only_active_with_no_next_actions]
|
||||
@projects = current_user.projects.active.select { |p| count_undone_todos(p) == 0 }
|
||||
else
|
||||
@projects = current_user.projects.all
|
||||
end
|
||||
current_user.projects.cache_note_counts
|
||||
|
||||
@page_title = t('projects.list_reviews')
|
||||
@count = @projects_to_review.count + @blocked_projects.count + @stalled_projects.count + @current_projects.count
|
||||
|
||||
@no_projects = current_user.projects.empty?
|
||||
current_user.projects.cache_note_counts
|
||||
@new_project = current_user.projects.build
|
||||
render
|
||||
end
|
||||
|
||||
def done
|
||||
|
|
@ -79,12 +68,10 @@ class ProjectsController < ApplicationController
|
|||
@range_high = @range_low + @projects.size - 1
|
||||
|
||||
init_not_done_counts(['project'])
|
||||
render
|
||||
end
|
||||
|
||||
def set_reviewed
|
||||
@project = current_user.projects.find(params[:id])
|
||||
@project.last_reviewed = Time.now
|
||||
@project.last_reviewed = Time.zone.now
|
||||
@project.save
|
||||
redirect_to :action => 'show'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ module ProjectsHelper
|
|||
:url => order_projects_path
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
def set_element_visible(id,test)
|
||||
if (test)
|
||||
page.show id
|
||||
|
|
@ -30,7 +30,7 @@ module ProjectsHelper
|
|||
end
|
||||
html
|
||||
end
|
||||
|
||||
|
||||
def project_next_prev_mobile
|
||||
html = ''
|
||||
unless @previous_project.nil?
|
||||
|
|
@ -61,7 +61,7 @@ module ProjectsHelper
|
|||
def summary(project)
|
||||
project_description = ''
|
||||
project_description += sanitize(markdown( project.description )) unless project.description.blank?
|
||||
project_description += content_tag(:p,
|
||||
project_description += content_tag(:p,
|
||||
"#{count_undone_todos_phrase(p)}. " + t('projects.project_state', :state => project.state)
|
||||
)
|
||||
project_description
|
||||
|
|
@ -69,12 +69,7 @@ module ProjectsHelper
|
|||
|
||||
def needsreview_class(item)
|
||||
raise "item must be a Project " unless item.kind_of? Project
|
||||
|
||||
if item.needs_review?(current_user)
|
||||
return "needsreview"
|
||||
else
|
||||
return "needsnoreview"
|
||||
end
|
||||
return item.needs_review?(current_user) ? "needsreview" : "needsnoreview"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -109,28 +109,20 @@ class Project < ActiveRecord::Base
|
|||
|
||||
def needs_review?(current_user)
|
||||
return true if last_reviewed.nil?
|
||||
return (active? && (last_reviewed < current_user.time - current_user.prefs.review_period.days))
|
||||
return (active? && (last_reviewed < current_user.time - current_user.prefs.review_period.days))
|
||||
end
|
||||
|
||||
def blocked?
|
||||
## mutually exclusive for stalled and blocked
|
||||
return false if stalled?
|
||||
return false if completed?
|
||||
is_blocked = true
|
||||
todos.each do |t|
|
||||
is_blocked = false if (!t.completed? && !t.deferred? && !t.pending?)
|
||||
end
|
||||
return is_blocked
|
||||
# blocked is uncompleted project with deferred or pending todos, but no next actions
|
||||
return false if self.stalled? || self.completed?
|
||||
return !self.todos.deferred_or_blocked.empty?
|
||||
end
|
||||
|
||||
|
||||
def stalled?
|
||||
return true if todos.count == 0
|
||||
return false if completed?
|
||||
is_stalled = true
|
||||
todos.each do |t|
|
||||
is_stalled = false if (!t.completed?)
|
||||
end
|
||||
return is_stalled
|
||||
# stalled is active/hidden project with no active todos
|
||||
return false if self.completed?
|
||||
return self.todos.not_completed.empty?
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,19 @@
|
|||
<%-
|
||||
total_count ||= -1
|
||||
total_count_string = total_count!=-1 ? " / #{total_count}" : ""
|
||||
suppress_sort_menu ||= false
|
||||
suppress_drag_handle ||= false
|
||||
-%>
|
||||
<div class="project-state-group" id="list-<%= state %>-projects-container" <%= " style=\"display:none\"" if project_state_group.empty? %>>
|
||||
<h2>
|
||||
<span id="<%= state %>-projects-count" class="badge"><%= project_state_group.length%><%= total_count_string%></span>
|
||||
|
||||
<%= t('common.last' ) unless (state == 'review' || state == 'stalled' || state == 'blocked' || state == 'current')%>
|
||||
<%= t('states.'+state+'_plural' )%>
|
||||
<%= t('common.last' ) unless ( ['review','stalled','blocked','current'].include?(state) )%>
|
||||
<%= t('states.'+state+'_plural' )%>
|
||||
<%= t('common.projects') %><%= total_count==-1 ? "" : " ("+link_to("Show all", done_projects_path)+")"%>
|
||||
|
||||
</h2>
|
||||
<% unless suppress_sort_menu %>
|
||||
<div class="menu_sort"><span class="sort_separator"><%= t('common.sort.sort') %> </span>
|
||||
<div class="alpha_sort">
|
||||
<%= link_to(t("common.sort.alphabetically"), alphabetize_projects_path(:state => state),
|
||||
|
|
@ -20,8 +23,9 @@
|
|||
:id => "#{state}_actionize_link", :class => "actionize_link", :title => t('common.sort.by_task_count_title'), :x_confirm_message => t('common.sort.by_task_count_title_confirm')) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div id="list-<%= state %>-projects" class="project-list">
|
||||
<%= render :partial => 'projects/project_listing', :collection => project_state_group %>
|
||||
<%= render :partial => 'projects/project_listing', :collection => project_state_group, :locals => {:suppress_drag_handle => suppress_drag_handle} %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<div id="projects-empty-nd" style="<%= @no_projects ? 'display:block' : 'display:none'%>">
|
||||
<div class="message"><p><%= t('projects.no_projects') %></p></div>
|
||||
</div>
|
||||
<%= render :partial => 'project_state_group', :object => @projects_to_review, :locals => { :state => 'review'} %>
|
||||
<%= render :partial => 'project_state_group', :object => @stalled_projects, :locals => { :state => 'stalled'} %>
|
||||
<%= render :partial => 'project_state_group', :object => @blocked_projects, :locals => { :state => 'blocked'} %>
|
||||
<%= render :partial => 'project_state_group', :object => @current_projects, :locals => { :state => 'current'} %>
|
||||
<%= render :partial => 'project_state_group', :object => @projects_to_review, :locals => { :state => 'review', :suppress_sort_menu => true, :suppress_drag_handle => true} %>
|
||||
<%= render :partial => 'project_state_group', :object => @stalled_projects, :locals => { :state => 'stalled', :suppress_sort_menu => true, :suppress_drag_handle => true} %>
|
||||
<%= render :partial => 'project_state_group', :object => @blocked_projects, :locals => { :state => 'blocked', :suppress_sort_menu => true, :suppress_drag_handle => true} %>
|
||||
<%= render :partial => 'project_state_group', :object => @current_projects, :locals => { :state => 'current', :suppress_sort_menu => true, :suppress_drag_handle => true} %>
|
||||
|
|
|
|||
|
|
@ -12,15 +12,15 @@ ActionController::Routing::Routes.draw do |map|
|
|||
contexts.resources :todos, :name_prefix => "context_"
|
||||
end
|
||||
|
||||
map.resources :projects, :collection => {:order => :post, :alphabetize => :post, :actionize => :post, :done => :get},
|
||||
:member => {:done_todos => :get, :all_done_todos => :get, :set_reviewed => :get} do |projects|
|
||||
projects.resources :todos, :name_prefix => "project_"
|
||||
map.resources :projects,
|
||||
:collection => {:order => :post, :alphabetize => :post, :actionize => :post, :done => :get},
|
||||
:member => {:done_todos => :get, :all_done_todos => :get, :set_reviewed => :post} do |projects|
|
||||
projects.resources :todos, :name_prefix => "project_"
|
||||
end
|
||||
|
||||
map.with_options :controller => :projects do |projects|
|
||||
# projects.home '', :action => "index"
|
||||
projects.review 'review', :action => :review
|
||||
end
|
||||
map.with_options :controller => :projects do |projects|
|
||||
projects.review 'review', :action => :review
|
||||
end
|
||||
|
||||
map.resources :notes
|
||||
|
||||
|
|
@ -29,7 +29,6 @@ ActionController::Routing::Routes.draw do |map|
|
|||
:collection => {:check_deferred => :post, :filter_to_context => :post, :filter_to_project => :post, :done => :get, :all_done => :get
|
||||
}
|
||||
|
||||
|
||||
map.with_options :controller => :todos do |todos|
|
||||
todos.home '', :action => "index"
|
||||
todos.tickler 'tickler.:format', :action => "list_deferred"
|
||||
|
|
@ -104,7 +103,6 @@ ActionController::Routing::Routes.draw do |map|
|
|||
map.search 'search', :controller => 'search', :action => 'index'
|
||||
map.data 'data', :controller => 'data', :action => 'index'
|
||||
|
||||
map.connect '/selenium_helper/login', :controller => 'selenium_helper', :action => 'login' if Rails.env == 'test'
|
||||
Translate::Routes.translation_ui(map) if Rails.env != "production"
|
||||
|
||||
# Install the default route as the lowest priority.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
class AddLastReviewedToProject < ActiveRecord::Migration
|
||||
|
||||
def self.up
|
||||
add_column :projects, :last_reviewed, :timestamp
|
||||
execute 'update projects set last_reviewed = created_at where last_reviewed IS NULL'
|
||||
execute 'UPDATE projects SET last_reviewed = created_at WHERE last_reviewed IS NULL'
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :projects, :last_reviewed
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
class AddNextReviewPreferences < ActiveRecord::Migration
|
||||
|
||||
def self.up
|
||||
add_column :preferences, :review_period, :integer, :default => 14, :null => false
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :preferences, :review_period
|
||||
remove_column :preferences, :review_period
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue