remove rest of teams code -- NEED TO REMOVE TEAMS FROM DATABASE!
This commit is contained in:
@ -9,7 +9,6 @@ class ExercisesController < ApplicationController
|
|||||||
before_action :set_exercise, only: MEMBER_ACTIONS + [:clone, :implement, :run, :statistics, :submit, :reload]
|
before_action :set_exercise, only: MEMBER_ACTIONS + [:clone, :implement, :run, :statistics, :submit, :reload]
|
||||||
before_action :set_external_user, only: [:statistics]
|
before_action :set_external_user, only: [:statistics]
|
||||||
before_action :set_file_types, only: [:create, :edit, :new, :update]
|
before_action :set_file_types, only: [:create, :edit, :new, :update]
|
||||||
before_action :set_teams, only: [:create, :edit, :new, :update]
|
|
||||||
|
|
||||||
skip_before_filter :verify_authenticity_token, only: [:import_proforma_xml]
|
skip_before_filter :verify_authenticity_token, only: [:import_proforma_xml]
|
||||||
skip_after_action :verify_authorized, only: [:import_proforma_xml]
|
skip_after_action :verify_authorized, only: [:import_proforma_xml]
|
||||||
@ -119,7 +118,7 @@ class ExercisesController < ApplicationController
|
|||||||
private :user_by_code_harbor_token
|
private :user_by_code_harbor_token
|
||||||
|
|
||||||
def exercise_params
|
def exercise_params
|
||||||
params[:exercise].permit(:description, :execution_environment_id, :file_id, :instructions, :public, :hide_file_tree, :allow_file_creation, :team_id, :title, files_attributes: file_attributes).merge(user_id: current_user.id, user_type: current_user.class.name)
|
params[:exercise].permit(:description, :execution_environment_id, :file_id, :instructions, :public, :hide_file_tree, :allow_file_creation, :title, files_attributes: file_attributes).merge(user_id: current_user.id, user_type: current_user.class.name)
|
||||||
end
|
end
|
||||||
private :exercise_params
|
private :exercise_params
|
||||||
|
|
||||||
@ -195,11 +194,6 @@ class ExercisesController < ApplicationController
|
|||||||
end
|
end
|
||||||
private :set_file_types
|
private :set_file_types
|
||||||
|
|
||||||
def set_teams
|
|
||||||
@teams = Team.all.order(:name)
|
|
||||||
end
|
|
||||||
private :set_teams
|
|
||||||
|
|
||||||
def show
|
def show
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -10,8 +10,7 @@ class Exercise < ActiveRecord::Base
|
|||||||
after_initialize :set_default_values
|
after_initialize :set_default_values
|
||||||
|
|
||||||
belongs_to :execution_environment
|
belongs_to :execution_environment
|
||||||
has_many :submissions
|
has_many :submission
|
||||||
belongs_to :team
|
|
||||||
|
|
||||||
has_many :external_users, source: :user, source_type: ExternalUser, through: :submissions
|
has_many :external_users, source: :user, source_type: ExternalUser, through: :submissions
|
||||||
has_many :internal_users, source: :user, source_type: InternalUser, through: :submissions
|
has_many :internal_users, source: :user, source_type: InternalUser, through: :submissions
|
||||||
|
@ -3,8 +3,6 @@ class InternalUser < ActiveRecord::Base
|
|||||||
|
|
||||||
authenticates_with_sorcery!
|
authenticates_with_sorcery!
|
||||||
|
|
||||||
has_and_belongs_to_many :teams
|
|
||||||
|
|
||||||
validates :email, presence: true, uniqueness: true
|
validates :email, presence: true, uniqueness: true
|
||||||
validates :password, confirmation: true, if: :password_void?, on: :update, presence: true
|
validates :password, confirmation: true, if: :password_void?, on: :update, presence: true
|
||||||
validates :role, inclusion: {in: ROLES}
|
validates :role, inclusion: {in: ROLES}
|
||||||
|
@ -13,23 +13,19 @@ class ExercisePolicy < AdminOrAuthorPolicy
|
|||||||
end
|
end
|
||||||
|
|
||||||
[:clone?, :destroy?, :edit?, :statistics?, :update?].each do |action|
|
[:clone?, :destroy?, :edit?, :statistics?, :update?].each do |action|
|
||||||
define_method(action) { admin? || author? || team_member? }
|
define_method(action) { admin? || author?}
|
||||||
end
|
end
|
||||||
|
|
||||||
[:implement?, :submit?, :reload?].each do |action|
|
[:implement?, :submit?, :reload?].each do |action|
|
||||||
define_method(action) { everyone }
|
define_method(action) { everyone }
|
||||||
end
|
end
|
||||||
|
|
||||||
def team_member?
|
|
||||||
@record.team.try(:members, []).include?(@user) if @record.team
|
|
||||||
end
|
|
||||||
private :team_member?
|
|
||||||
|
|
||||||
class Scope < Scope
|
class Scope < Scope
|
||||||
def resolve
|
def resolve
|
||||||
if @user.admin?
|
if @user.admin?
|
||||||
@scope.all
|
@scope.all
|
||||||
elsif @user.internal_user?
|
elsif @user.internal_user?
|
||||||
|
#need to remove team query
|
||||||
@scope.where('user_id = ? OR public = TRUE OR (team_id IS NOT NULL AND team_id IN (SELECT t.id FROM teams t JOIN internal_users_teams iut ON t.id = iut.team_id WHERE iut.internal_user_id = ?))', @user.id, @user.id)
|
@scope.where('user_id = ? OR public = TRUE OR (team_id IS NOT NULL AND team_id IN (SELECT t.id FROM teams t JOIN internal_users_teams iut ON t.id = iut.team_id WHERE iut.internal_user_id = ?))', @user.id, @user.id)
|
||||||
else
|
else
|
||||||
@scope.none
|
@scope.none
|
||||||
|
@ -17,9 +17,6 @@
|
|||||||
= f.label(:instructions)
|
= f.label(:instructions)
|
||||||
= f.hidden_field(:instructions)
|
= f.hidden_field(:instructions)
|
||||||
.form-control.markdown
|
.form-control.markdown
|
||||||
/.form-group
|
|
||||||
= f.label(:team_id)
|
|
||||||
= f.collection_select(:team_id, @teams, :id, :name, {include_blank: true}, class: 'form-control')
|
|
||||||
.checkbox
|
.checkbox
|
||||||
label
|
label
|
||||||
= f.check_box(:public)
|
= f.check_box(:public)
|
||||||
|
@ -12,7 +12,6 @@ h1
|
|||||||
= row(label: 'exercise.description', value: render_markdown(@exercise.description))
|
= row(label: 'exercise.description', value: render_markdown(@exercise.description))
|
||||||
= row(label: 'exercise.execution_environment', value: link_to_if(policy(@exercise.execution_environment).show?, @exercise.execution_environment, @exercise.execution_environment))
|
= row(label: 'exercise.execution_environment', value: link_to_if(policy(@exercise.execution_environment).show?, @exercise.execution_environment, @exercise.execution_environment))
|
||||||
/= row(label: 'exercise.instructions', value: render_markdown(@exercise.instructions))
|
/= row(label: 'exercise.instructions', value: render_markdown(@exercise.instructions))
|
||||||
= row(label: 'exercise.team', value: @exercise.team ? link_to(@exercise.team, @exercise.team) : nil)
|
|
||||||
= row(label: 'exercise.maximum_score', value: @exercise.maximum_score)
|
= row(label: 'exercise.maximum_score', value: @exercise.maximum_score)
|
||||||
= row(label: 'exercise.public', value: @exercise.public?)
|
= row(label: 'exercise.public', value: @exercise.public?)
|
||||||
= row(label: 'exercise.hide_file_tree', value: @exercise.hide_file_tree?)
|
= row(label: 'exercise.hide_file_tree', value: @exercise.hide_file_tree?)
|
||||||
|
@ -34,8 +34,6 @@ de:
|
|||||||
instructions: Anweisungen
|
instructions: Anweisungen
|
||||||
maximum_score: Erreichbare Punktzahl
|
maximum_score: Erreichbare Punktzahl
|
||||||
public: Öffentlich
|
public: Öffentlich
|
||||||
team: Team
|
|
||||||
team_id: Team
|
|
||||||
title: Titel
|
title: Titel
|
||||||
user: Autor
|
user: Autor
|
||||||
allow_file_creation: "Dateierstellung erlauben"
|
allow_file_creation: "Dateierstellung erlauben"
|
||||||
@ -91,9 +89,6 @@ de:
|
|||||||
files: Dateien
|
files: Dateien
|
||||||
score: Punktzahl
|
score: Punktzahl
|
||||||
user: Autor
|
user: Autor
|
||||||
team:
|
|
||||||
internal_user_ids: Mitglieder
|
|
||||||
name: Name
|
|
||||||
models:
|
models:
|
||||||
code_harbor_link:
|
code_harbor_link:
|
||||||
one: CodeHarbor-Link
|
one: CodeHarbor-Link
|
||||||
@ -128,9 +123,6 @@ de:
|
|||||||
submission:
|
submission:
|
||||||
one: Abgabe
|
one: Abgabe
|
||||||
other: Abgaben
|
other: Abgaben
|
||||||
team:
|
|
||||||
one: Team
|
|
||||||
other: Teams
|
|
||||||
errors:
|
errors:
|
||||||
messages:
|
messages:
|
||||||
together: 'muss zusammen mit %{attribute} definiert werden'
|
together: 'muss zusammen mit %{attribute} definiert werden'
|
||||||
|
@ -34,8 +34,6 @@ en:
|
|||||||
instructions: Instructions
|
instructions: Instructions
|
||||||
maximum_score: Maximum Score
|
maximum_score: Maximum Score
|
||||||
public: Public
|
public: Public
|
||||||
team: Team
|
|
||||||
team_id: Team
|
|
||||||
title: Title
|
title: Title
|
||||||
user: Author
|
user: Author
|
||||||
allow_file_creation: "Allow file creation"
|
allow_file_creation: "Allow file creation"
|
||||||
@ -91,9 +89,6 @@ en:
|
|||||||
files: Files
|
files: Files
|
||||||
score: Score
|
score: Score
|
||||||
user: Author
|
user: Author
|
||||||
team:
|
|
||||||
internal_user_ids: Members
|
|
||||||
name: Name
|
|
||||||
models:
|
models:
|
||||||
code_harbor_link:
|
code_harbor_link:
|
||||||
one: CodeHarbor Link
|
one: CodeHarbor Link
|
||||||
@ -128,9 +123,6 @@ en:
|
|||||||
submission:
|
submission:
|
||||||
one: Submission
|
one: Submission
|
||||||
other: Submissions
|
other: Submissions
|
||||||
team:
|
|
||||||
one: Team
|
|
||||||
other: Teams
|
|
||||||
errors:
|
errors:
|
||||||
messages:
|
messages:
|
||||||
together: 'has to be set along with %{attribute}'
|
together: 'has to be set along with %{attribute}'
|
||||||
|
@ -99,5 +99,4 @@ Rails.application.routes.draw do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :teams
|
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user