Added WorkItems as a new subject for TrackedTimeEntries.

- Made TrackedTimeEntries polymorphic to belong to both Lecture and WorkItems models
- Added associated migrations for existing data
- Added to administrate UI
This commit is contained in:
2023-10-07 15:53:31 +01:00
parent f121c990e8
commit 6a2f053bb6
11 changed files with 158 additions and 8 deletions
+3 -2
View File
@@ -1,8 +1,9 @@
class Course < ApplicationRecord
has_many :lectures, dependent: :destroy
has_many :work_items, dependent: :destroy
# A course has a standalone connection to its recordings. To be shown they must be associated with a lecture but we
# track those not associated with a lecture to avoid duplication.
# A course has a standalone connection to its recordings. To be displayed they must be associated with a lecture but
# we them independently to avoid re-importing lectures.
has_many :recordings, dependent: :destroy
def import_from_calendar!
+1 -1
View File
@@ -2,7 +2,7 @@ class Lecture < ApplicationRecord
belongs_to :course
has_one :recording, dependent: :nullify
has_many :tracked_time_entries, dependent: :destroy
has_many :tracked_time_entries, dependent: :destroy, as: :subject
enum :kind, [
:lecture,
+1 -1
View File
@@ -1,5 +1,5 @@
class TrackedTimeEntry < ApplicationRecord
belongs_to :lecture
belongs_to :subject, polymorphic: true
enum :kind, [
:concurrent,
+1
View File
@@ -1,3 +1,4 @@
class WorkItem < ApplicationRecord
belongs_to :course
has_many :tracked_time_entries, dependent: :destroy, as: :subject
end