Skip to content

Commit

Permalink
WIP: Allow contributors for submissions
Browse files Browse the repository at this point in the history
  • Loading branch information
MrSerth committed Jul 17, 2023
1 parent 46dad67 commit a879297
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 5 deletions.
9 changes: 9 additions & 0 deletions app/models/concerns/contributor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

module Contributor
extend ActiveSupport::Concern

included do
has_many :submissions, as: :contributor
end
end
13 changes: 13 additions & 0 deletions app/models/concerns/contributor_creation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module ContributorCreation
extend ActiveSupport::Concern
include Contributor

included do
belongs_to :contributor, polymorphic: true
alias_method :user, :contributor
alias_method :author, :user
alias_method :creator, :user
end
end
5 changes: 5 additions & 0 deletions app/models/programming_group.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

class ProgrammingGroup < ApplicationRecord
include Contributor
end
2 changes: 1 addition & 1 deletion app/models/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class Submission < ApplicationRecord
include Context
include Creation
include ContributorCreation
include ActionCableHelper

CAUSES = %w[assess download file render run save submit test autosave requestComments remoteAssess
Expand Down
13 changes: 13 additions & 0 deletions db/migrate/20230717103719_add_contributors.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

class AddContributors < ActiveRecord::Migration[7.0]
def change
create_table :programming_groups, id: :uuid do |t|
t.string :name
t.timestamps
end

rename_column :submissions, :user_id, :contributor_id
rename_column :submissions, :user_type, :contributor_type
end
end
14 changes: 10 additions & 4 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2023_03_20_220012) do
ActiveRecord::Schema[7.0].define(version: 2023_07_17_103719) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
enable_extension "pgcrypto"
Expand Down Expand Up @@ -350,6 +350,12 @@
t.index ["external_users_id"], name: "index_lti_parameters_on_external_users_id"
end

create_table "programming_groups", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "proxy_exercises", id: :serial, force: :cascade do |t|
t.string "title"
t.string "description"
Expand Down Expand Up @@ -453,15 +459,15 @@
create_table "submissions", id: :serial, force: :cascade do |t|
t.integer "exercise_id"
t.float "score"
t.integer "user_id"
t.integer "contributor_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "cause"
t.string "user_type"
t.string "contributor_type"
t.bigint "study_group_id"
t.index ["contributor_id"], name: "index_submissions_on_contributor_id"
t.index ["exercise_id"], name: "index_submissions_on_exercise_id"
t.index ["study_group_id"], name: "index_submissions_on_study_group_id"
t.index ["user_id"], name: "index_submissions_on_user_id"
end

create_table "subscriptions", id: :serial, force: :cascade do |t|
Expand Down

0 comments on commit a879297

Please sign in to comment.