Merge branch 'feature/edit-recurring-task'
Conflicts: config/locales/en.yml
This commit is contained in:
commit
ec03d579d0
8 changed files with 97 additions and 55 deletions
|
|
@ -1,21 +1,21 @@
|
|||
# encoding: utf-8
|
||||
class TasksController < ApplicationController
|
||||
#auto_complete_for :user, :nick
|
||||
|
||||
|
||||
def index
|
||||
@non_group_tasks = Task.non_group.includes(assignments: :user)
|
||||
@groups = Workgroup.includes(open_tasks: {assignments: :user})
|
||||
end
|
||||
|
||||
|
||||
def user
|
||||
@unaccepted_tasks = Task.unaccepted_tasks_for(current_user)
|
||||
@accepted_tasks = Task.accepted_tasks_for(current_user)
|
||||
end
|
||||
|
||||
|
||||
def new
|
||||
@task = Task.new(current_user_id: current_user.id)
|
||||
end
|
||||
|
||||
|
||||
def create
|
||||
@task = Task.new(params[:task])
|
||||
if params[:periodic]
|
||||
|
|
@ -27,24 +27,25 @@ class TasksController < ApplicationController
|
|||
render :template => "tasks/new"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def show
|
||||
@task = Task.find(params[:id])
|
||||
end
|
||||
|
||||
|
||||
def edit
|
||||
@task = Task.find(params[:id])
|
||||
@periodic = !!params[:periodic]
|
||||
@task.current_user_id = current_user.id
|
||||
if @task.periodic?
|
||||
flash.now[:alert] = I18n.t('tasks.edit.warning_periodic').html_safe
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def update
|
||||
@task = Task.find(params[:id])
|
||||
task_group = @task.periodic_task_group
|
||||
was_periodic = @task.periodic?
|
||||
prev_due_date = @task.due_date
|
||||
@task.attributes=(params[:task])
|
||||
if @task.errors.empty? && @task.save
|
||||
task_group.update_tasks_including(@task, prev_due_date) if params[:periodic]
|
||||
flash[:notice] = I18n.t('tasks.update.notice')
|
||||
if was_periodic && !@task.periodic?
|
||||
flash[:notice] = I18n.t('tasks.update.notice_converted')
|
||||
|
|
@ -58,7 +59,7 @@ class TasksController < ApplicationController
|
|||
render :template => "tasks/edit"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
task = Task.find(params[:id])
|
||||
# Save user_ids to update apple statistics after destroy
|
||||
|
|
@ -73,7 +74,7 @@ class TasksController < ApplicationController
|
|||
|
||||
redirect_to tasks_url, :notice => I18n.t('tasks.destroy.notice')
|
||||
end
|
||||
|
||||
|
||||
# assign current_user to the task and set the assignment to "accepted"
|
||||
# if there is already an assignment, only accepted will be set to true
|
||||
def accept
|
||||
|
|
@ -85,23 +86,23 @@ class TasksController < ApplicationController
|
|||
end
|
||||
redirect_to user_tasks_path, :notice => I18n.t('tasks.accept.notice')
|
||||
end
|
||||
|
||||
|
||||
# deletes assignment between current_user and given task
|
||||
def reject
|
||||
Task.find(params[:id]).users.delete(current_user)
|
||||
redirect_to :action => "index"
|
||||
end
|
||||
|
||||
|
||||
def set_done
|
||||
Task.find(params[:id]).update_attribute :done, true
|
||||
redirect_to tasks_url, :notice => I18n.t('tasks.set_done.notice')
|
||||
end
|
||||
|
||||
|
||||
# Shows all tasks, which are already done
|
||||
def archive
|
||||
@tasks = Task.done.page(params[:page]).per(@per_page).order('tasks.updated_on DESC').includes(assignments: :user)
|
||||
end
|
||||
|
||||
|
||||
# shows workgroup (normal group) to edit weekly_tasks_template
|
||||
def workgroup
|
||||
@group = Group.find(params[:workgroup_id])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue