Add created_by user to Task
This commit is contained in:
parent
18e38be6be
commit
b6f5295267
10 changed files with 35 additions and 7 deletions
|
@ -18,6 +18,7 @@ class TasksController < ApplicationController
|
|||
|
||||
def create
|
||||
@task = Task.new(current_user_id: current_user.id)
|
||||
@task.created_by = current_user
|
||||
@task.attributes=(task_params)
|
||||
if params[:periodic]
|
||||
@task.periodic_task_group = PeriodicTaskGroup.new
|
||||
|
|
|
@ -4,6 +4,7 @@ class Task < ApplicationRecord
|
|||
has_many :users, :through => :assignments
|
||||
belongs_to :workgroup
|
||||
belongs_to :periodic_task_group
|
||||
belongs_to :created_by, :class_name => 'User', :foreign_key => 'created_by_user_id'
|
||||
|
||||
scope :non_group, -> { where(workgroup_id: nil, done: false) }
|
||||
scope :done, -> { where(done: true) }
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
%dl.dl-horizontal
|
||||
%dt= heading_helper Task, :name
|
||||
%dd= @task.name
|
||||
%dt= heading_helper Task, :created_on
|
||||
%dd= format_time @task.created_on
|
||||
%dt= heading_helper Task, :created_by
|
||||
%dd= show_user @task.created_by
|
||||
- if @task.description.present?
|
||||
%dt= heading_helper Task, :description
|
||||
%dd= simple_format(@task.description)
|
||||
|
|
|
@ -167,6 +167,8 @@ de:
|
|||
phone2: Telefon 2
|
||||
shared_sync_method: Syncronisierungsmethode
|
||||
task:
|
||||
created_by: Erstellt von
|
||||
created_on: Erstellt am
|
||||
description: Beschreibung
|
||||
done: Erledigt?
|
||||
due_date: Wann erledigen?
|
||||
|
|
|
@ -179,6 +179,8 @@ en:
|
|||
shared_sync_method: How to synchronize
|
||||
url: Homepage
|
||||
task:
|
||||
created_by: Created by
|
||||
created_on: Created at
|
||||
description: Description
|
||||
done: Done?
|
||||
due_date: Due date
|
||||
|
|
|
@ -144,6 +144,8 @@ es:
|
|||
shared_sync_method: Cómo sincronizar
|
||||
url: Web
|
||||
task:
|
||||
created_by: Creado por
|
||||
created_on: Creado en
|
||||
description: Descripción
|
||||
done: Hecho?
|
||||
due_date: Fecha
|
||||
|
|
|
@ -128,6 +128,8 @@ fr:
|
|||
phone2: Autre téléphone
|
||||
url: Site web
|
||||
task:
|
||||
created_by: Crée par
|
||||
created_on: Créé le
|
||||
done: Fait?
|
||||
due_date: Echéance
|
||||
duration: Durée
|
||||
|
|
|
@ -165,6 +165,8 @@ nl:
|
|||
shared_sync_method: Hoe synchroniseren
|
||||
url: Homepage
|
||||
task:
|
||||
created_by: Gemaakt door
|
||||
created_on: Gemaakt op
|
||||
description: Beschrijving
|
||||
done: Gedaan?
|
||||
due_date: Voor wanneer?
|
||||
|
|
11
db/migrate/20181205000000_add_user_to_task.rb
Normal file
11
db/migrate/20181205000000_add_user_to_task.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
class AddUserToTask < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :tasks, :created_by_user_id, :integer
|
||||
|
||||
reversible do |dir|
|
||||
dir.up do
|
||||
change_column :tasks, :description, :text
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -503,7 +503,7 @@ ActiveRecord::Schema.define(version: 20181201000210) do
|
|||
|
||||
create_table "tasks", force: :cascade do |t|
|
||||
t.string "name", limit: 255, default: "", null: false
|
||||
t.string "description", limit: 255
|
||||
t.text "description", limit: 65535
|
||||
t.date "due_date"
|
||||
t.boolean "done", default: false
|
||||
t.integer "workgroup_id", limit: 4
|
||||
|
@ -512,6 +512,7 @@ ActiveRecord::Schema.define(version: 20181201000210) do
|
|||
t.integer "required_users", limit: 4, default: 1
|
||||
t.integer "duration", limit: 4, default: 1
|
||||
t.integer "periodic_task_group_id", limit: 4
|
||||
t.integer "created_by_user_id", limit: 4
|
||||
end
|
||||
|
||||
add_index "tasks", ["due_date"], name: "index_tasks_on_due_date", using: :btree
|
||||
|
|
Loading…
Reference in a new issue