Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
aoz-003
Commits
37534fb5
Verified
Commit
37534fb5
authored
Oct 04, 2018
by
Kaspar Vollenweider
👻
Browse files
add SemesterFeedback with all relations
parent
790e29e0
Changes
10
Hide whitespace changes
Inline
Side-by-side
app/models/assignment.rb
View file @
37534fb5
...
...
@@ -5,6 +5,7 @@ class Assignment < ApplicationRecord
has_many
:hours
,
as: :hourable
has_many
:feedbacks
,
as: :feedbackable
has_many
:trial_feedbacks
,
as: :trial_feedbackable
has_many
:semester_feedbacks
,
as: :semester_feedbackable
has_one
:assignment_log
validates
:client_id
,
uniqueness:
{
...
...
app/models/concerns/group_assignment_common.rb
View file @
37534fb5
...
...
@@ -7,6 +7,8 @@ module GroupAssignmentCommon
belongs_to
:group_offer
,
->
{
with_deleted
}
# include imported deleted group offers
has_many
:reminder_mailing_volunteers
,
as: :reminder_mailable
,
dependent: :destroy
has_many
:semester_feedbacks
,
as: :semester_feedbackable
has_one
:group_offer_category
,
through: :group_offer
has_one
:creator
,
->
{
with_deleted
},
through: :group_offer
...
...
app/models/semester_feedback.rb
0 → 100644
View file @
37534fb5
class
SemesterFeedback
<
ApplicationRecord
belongs_to
:author
,
->
{
with_deleted
},
class_name:
'User'
,
inverse_of:
'semester_feedbacks'
belongs_to
:semester_process_volunteer
has_one
:semester_process
,
through: :semester_process_volunteer
has_one
:volunteer
,
through: :semester_process_volunteer
# relates to either Assignment or GroupAssignment (not GroupOffer!)
belongs_to
:semester_feedbackable
,
polymorphic:
true
,
optional:
true
end
app/models/semester_process.rb
View file @
37534fb5
...
...
@@ -7,4 +7,5 @@ class SemesterProcess < ApplicationRecord
has_many
:semester_process_volunteers
,
dependent: :destroy
has_many
:volunteers
,
through: :semester_process_volunteers
has_many
:semester_feedbacks
,
through: :semester_process_volunteers
end
app/models/user.rb
View file @
37534fb5
...
...
@@ -97,6 +97,7 @@ class User < ApplicationRecord
has_many
:semester_process_commits
,
inverse_of:
'commited_by'
,
class_name:
'SemesterProcessVolunteer'
,
foreign_key:
'commited_by_id'
,
dependent: :nullify
has_many
:semester_feedbacks
,
inverse_of:
'author'
,
foreign_key:
'author_id'
,
dependent: :destroy
has_and_belongs_to_many
:department
...
...
app/models/volunteer.rb
View file @
37534fb5
...
...
@@ -74,6 +74,8 @@ class Volunteer < ApplicationRecord
has_many
:semester_process_volunteers
,
dependent: :destroy
has_many
:semester_processes
,
through: :semester_process_volunteers
has_many
:semester_feedbacks
,
through: :semester_process_volunteers
has_attached_file
:avatar
,
styles:
{
thumb:
'100x100#'
}
# Validations
...
...
db/migrate/20181004141844_create_semester_feedbacks.rb
0 → 100644
View file @
37534fb5
class
CreateSemesterFeedbacks
<
ActiveRecord
::
Migration
[
5.1
]
def
change
create_table
:semester_feedbacks
do
|
t
|
t
.
references
:author
,
references: :users
,
index:
true
t
.
references
:semester_process_volunteer
,
index:
false
# for relations to either Assignment or GroupAssignment (not GroupOffer!)
t
.
integer
:semester_feedbackable_id
t
.
string
:semester_feedbackable_type
t
.
text
:goals
t
.
text
:achievements
t
.
text
:future
t
.
text
:comments
t
.
boolean
:conversation
,
default:
false
t
.
datetime
:deleted_at
,
index:
true
t
.
timestamps
end
end
end
db/schema.rb
View file @
37534fb5
...
...
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201810041
3460
4
)
do
ActiveRecord
::
Schema
.
define
(
version:
201810041
4184
4
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -624,6 +624,23 @@ ActiveRecord::Schema.define(version: 20181004134604) do
t
.
index
[
"deleted_at"
],
name:
"index_reminder_mailings_on_deleted_at"
end
create_table
"semester_feedbacks"
,
force: :cascade
do
|
t
|
t
.
bigint
"author_id"
t
.
bigint
"semester_process_volunteer_id"
t
.
integer
"semester_feedbackable_id"
t
.
string
"semester_feedbackable_type"
t
.
text
"goals"
t
.
text
"achievements"
t
.
text
"future"
t
.
text
"comments"
t
.
boolean
"conversation"
,
default:
false
t
.
datetime
"deleted_at"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
index
[
"author_id"
],
name:
"index_semester_feedbacks_on_author_id"
t
.
index
[
"deleted_at"
],
name:
"index_semester_feedbacks_on_deleted_at"
end
create_table
"semester_process_volunteers"
,
force: :cascade
do
|
t
|
t
.
bigint
"volunteer_id"
t
.
bigint
"semester_process_id"
...
...
test/factories/semester_feedbacks.rb
0 → 100644
View file @
37534fb5
FactoryBot
.
define
do
factory
:semester_feedback
do
association
:author
,
factory: :user
volunteer
semester_process_volunteer
goals
'Goals text'
achievements
'Achievements text'
future
'Future text'
comments
'Comments text'
association
:semester_feedbackable
,
factory: :group_assignment
end
end
test/models/semester_feedback_test.rb
0 → 100644
View file @
37534fb5
require
'test_helper'
class
SemesterFeedbackTest
<
ActiveSupport
::
TestCase
# test "the truth" do
# assert true
# end
end
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment