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
|
def create
|
||||||
@task = Task.new(current_user_id: current_user.id)
|
@task = Task.new(current_user_id: current_user.id)
|
||||||
|
@task.created_by = current_user
|
||||||
@task.attributes=(task_params)
|
@task.attributes=(task_params)
|
||||||
if params[:periodic]
|
if params[:periodic]
|
||||||
@task.periodic_task_group = PeriodicTaskGroup.new
|
@task.periodic_task_group = PeriodicTaskGroup.new
|
||||||
|
|
|
@ -4,6 +4,7 @@ class Task < ApplicationRecord
|
||||||
has_many :users, :through => :assignments
|
has_many :users, :through => :assignments
|
||||||
belongs_to :workgroup
|
belongs_to :workgroup
|
||||||
belongs_to :periodic_task_group
|
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 :non_group, -> { where(workgroup_id: nil, done: false) }
|
||||||
scope :done, -> { where(done: true) }
|
scope :done, -> { where(done: true) }
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
%dl.dl-horizontal
|
%dl.dl-horizontal
|
||||||
%dt= heading_helper Task, :name
|
%dt= heading_helper Task, :name
|
||||||
%dd= @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?
|
- if @task.description.present?
|
||||||
%dt= heading_helper Task, :description
|
%dt= heading_helper Task, :description
|
||||||
%dd= simple_format(@task.description)
|
%dd= simple_format(@task.description)
|
||||||
|
|
|
@ -167,6 +167,8 @@ de:
|
||||||
phone2: Telefon 2
|
phone2: Telefon 2
|
||||||
shared_sync_method: Syncronisierungsmethode
|
shared_sync_method: Syncronisierungsmethode
|
||||||
task:
|
task:
|
||||||
|
created_by: Erstellt von
|
||||||
|
created_on: Erstellt am
|
||||||
description: Beschreibung
|
description: Beschreibung
|
||||||
done: Erledigt?
|
done: Erledigt?
|
||||||
due_date: Wann erledigen?
|
due_date: Wann erledigen?
|
||||||
|
|
|
@ -179,6 +179,8 @@ en:
|
||||||
shared_sync_method: How to synchronize
|
shared_sync_method: How to synchronize
|
||||||
url: Homepage
|
url: Homepage
|
||||||
task:
|
task:
|
||||||
|
created_by: Created by
|
||||||
|
created_on: Created at
|
||||||
description: Description
|
description: Description
|
||||||
done: Done?
|
done: Done?
|
||||||
due_date: Due date
|
due_date: Due date
|
||||||
|
|
|
@ -144,6 +144,8 @@ es:
|
||||||
shared_sync_method: Cómo sincronizar
|
shared_sync_method: Cómo sincronizar
|
||||||
url: Web
|
url: Web
|
||||||
task:
|
task:
|
||||||
|
created_by: Creado por
|
||||||
|
created_on: Creado en
|
||||||
description: Descripción
|
description: Descripción
|
||||||
done: Hecho?
|
done: Hecho?
|
||||||
due_date: Fecha
|
due_date: Fecha
|
||||||
|
|
|
@ -128,6 +128,8 @@ fr:
|
||||||
phone2: Autre téléphone
|
phone2: Autre téléphone
|
||||||
url: Site web
|
url: Site web
|
||||||
task:
|
task:
|
||||||
|
created_by: Crée par
|
||||||
|
created_on: Créé le
|
||||||
done: Fait?
|
done: Fait?
|
||||||
due_date: Echéance
|
due_date: Echéance
|
||||||
duration: Durée
|
duration: Durée
|
||||||
|
|
|
@ -165,6 +165,8 @@ nl:
|
||||||
shared_sync_method: Hoe synchroniseren
|
shared_sync_method: Hoe synchroniseren
|
||||||
url: Homepage
|
url: Homepage
|
||||||
task:
|
task:
|
||||||
|
created_by: Gemaakt door
|
||||||
|
created_on: Gemaakt op
|
||||||
description: Beschrijving
|
description: Beschrijving
|
||||||
done: Gedaan?
|
done: Gedaan?
|
||||||
due_date: Voor wanneer?
|
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
|
15
db/schema.rb
15
db/schema.rb
|
@ -502,16 +502,17 @@ ActiveRecord::Schema.define(version: 20181201000210) do
|
||||||
add_index "suppliers", ["name"], name: "index_suppliers_on_name", unique: true, using: :btree
|
add_index "suppliers", ["name"], name: "index_suppliers_on_name", unique: true, using: :btree
|
||||||
|
|
||||||
create_table "tasks", force: :cascade do |t|
|
create_table "tasks", force: :cascade do |t|
|
||||||
t.string "name", limit: 255, default: "", null: false
|
t.string "name", limit: 255, default: "", null: false
|
||||||
t.string "description", limit: 255
|
t.text "description", limit: 65535
|
||||||
t.date "due_date"
|
t.date "due_date"
|
||||||
t.boolean "done", default: false
|
t.boolean "done", default: false
|
||||||
t.integer "workgroup_id", limit: 4
|
t.integer "workgroup_id", limit: 4
|
||||||
t.datetime "created_on", null: false
|
t.datetime "created_on", null: false
|
||||||
t.datetime "updated_on", null: false
|
t.datetime "updated_on", null: false
|
||||||
t.integer "required_users", limit: 4, default: 1
|
t.integer "required_users", limit: 4, default: 1
|
||||||
t.integer "duration", limit: 4, default: 1
|
t.integer "duration", limit: 4, default: 1
|
||||||
t.integer "periodic_task_group_id", limit: 4
|
t.integer "periodic_task_group_id", limit: 4
|
||||||
|
t.integer "created_by_user_id", limit: 4
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "tasks", ["due_date"], name: "index_tasks_on_due_date", using: :btree
|
add_index "tasks", ["due_date"], name: "index_tasks_on_due_date", using: :btree
|
||||||
|
|
Loading…
Reference in a new issue