Add created_by user to Task

This commit is contained in:
Patrick Gansterer 2020-03-06 13:04:03 +01:00
parent 18e38be6be
commit b6f5295267
10 changed files with 35 additions and 7 deletions

View file

@ -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

View file

@ -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) }

View file

@ -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)

View file

@ -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?

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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?

View 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

View file

@ -502,16 +502,17 @@ ActiveRecord::Schema.define(version: 20181201000210) do
add_index "suppliers", ["name"], name: "index_suppliers_on_name", unique: true, using: :btree
create_table "tasks", force: :cascade do |t|
t.string "name", limit: 255, default: "", null: false
t.string "description", limit: 255
t.string "name", limit: 255, default: "", null: false
t.text "description", limit: 65535
t.date "due_date"
t.boolean "done", default: false
t.boolean "done", default: false
t.integer "workgroup_id", limit: 4
t.datetime "created_on", null: false
t.datetime "updated_on", null: false
t.integer "required_users", limit: 4, default: 1
t.integer "duration", limit: 4, default: 1
t.datetime "created_on", null: false
t.datetime "updated_on", null: false
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