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_external_user, only: [:statistics]
|
||||
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_after_action :verify_authorized, only: [:import_proforma_xml]
|
||||
@ -119,7 +118,7 @@ class ExercisesController < ApplicationController
|
||||
private :user_by_code_harbor_token
|
||||
|
||||
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
|
||||
private :exercise_params
|
||||
|
||||
@ -195,11 +194,6 @@ class ExercisesController < ApplicationController
|
||||
end
|
||||
private :set_file_types
|
||||
|
||||
def set_teams
|
||||
@teams = Team.all.order(:name)
|
||||
end
|
||||
private :set_teams
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
|
@ -10,8 +10,7 @@ class Exercise < ActiveRecord::Base
|
||||
after_initialize :set_default_values
|
||||
|
||||
belongs_to :execution_environment
|
||||
has_many :submissions
|
||||
belongs_to :team
|
||||
has_many :submission
|
||||
|
||||
has_many :external_users, source: :user, source_type: ExternalUser, through: :submissions
|
||||
has_many :internal_users, source: :user, source_type: InternalUser, through: :submissions
|
||||
|
@ -3,8 +3,6 @@ class InternalUser < ActiveRecord::Base
|
||||
|
||||
authenticates_with_sorcery!
|
||||
|
||||
has_and_belongs_to_many :teams
|
||||
|
||||
validates :email, presence: true, uniqueness: true
|
||||
validates :password, confirmation: true, if: :password_void?, on: :update, presence: true
|
||||
validates :role, inclusion: {in: ROLES}
|
||||
|
@ -13,23 +13,19 @@ class ExercisePolicy < AdminOrAuthorPolicy
|
||||
end
|
||||
|
||||
[:clone?, :destroy?, :edit?, :statistics?, :update?].each do |action|
|
||||
define_method(action) { admin? || author? || team_member? }
|
||||
define_method(action) { admin? || author?}
|
||||
end
|
||||
|
||||
[:implement?, :submit?, :reload?].each do |action|
|
||||
define_method(action) { everyone }
|
||||
end
|
||||
|
||||
def team_member?
|
||||
@record.team.try(:members, []).include?(@user) if @record.team
|
||||
end
|
||||
private :team_member?
|
||||
|
||||
class Scope < Scope
|
||||
def resolve
|
||||
if @user.admin?
|
||||
@scope.all
|
||||
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)
|
||||
else
|
||||
@scope.none
|
||||
|
@ -17,9 +17,6 @@
|
||||
= f.label(:instructions)
|
||||
= f.hidden_field(:instructions)
|
||||
.form-control.markdown
|
||||
/.form-group
|
||||
= f.label(:team_id)
|
||||
= f.collection_select(:team_id, @teams, :id, :name, {include_blank: true}, class: 'form-control')
|
||||
.checkbox
|
||||
label
|
||||
= f.check_box(:public)
|
||||
|
@ -12,7 +12,6 @@ h1
|
||||
= 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.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.public', value: @exercise.public?)
|
||||
= row(label: 'exercise.hide_file_tree', value: @exercise.hide_file_tree?)
|
||||
|
@ -34,8 +34,6 @@ de:
|
||||
instructions: Anweisungen
|
||||
maximum_score: Erreichbare Punktzahl
|
||||
public: Öffentlich
|
||||
team: Team
|
||||
team_id: Team
|
||||
title: Titel
|
||||
user: Autor
|
||||
allow_file_creation: "Dateierstellung erlauben"
|
||||
@ -91,9 +89,6 @@ de:
|
||||
files: Dateien
|
||||
score: Punktzahl
|
||||
user: Autor
|
||||
team:
|
||||
internal_user_ids: Mitglieder
|
||||
name: Name
|
||||
models:
|
||||
code_harbor_link:
|
||||
one: CodeHarbor-Link
|
||||
@ -128,9 +123,6 @@ de:
|
||||
submission:
|
||||
one: Abgabe
|
||||
other: Abgaben
|
||||
team:
|
||||
one: Team
|
||||
other: Teams
|
||||
errors:
|
||||
messages:
|
||||
together: 'muss zusammen mit %{attribute} definiert werden'
|
||||
|
@ -34,8 +34,6 @@ en:
|
||||
instructions: Instructions
|
||||
maximum_score: Maximum Score
|
||||
public: Public
|
||||
team: Team
|
||||
team_id: Team
|
||||
title: Title
|
||||
user: Author
|
||||
allow_file_creation: "Allow file creation"
|
||||
@ -91,9 +89,6 @@ en:
|
||||
files: Files
|
||||
score: Score
|
||||
user: Author
|
||||
team:
|
||||
internal_user_ids: Members
|
||||
name: Name
|
||||
models:
|
||||
code_harbor_link:
|
||||
one: CodeHarbor Link
|
||||
@ -128,9 +123,6 @@ en:
|
||||
submission:
|
||||
one: Submission
|
||||
other: Submissions
|
||||
team:
|
||||
one: Team
|
||||
other: Teams
|
||||
errors:
|
||||
messages:
|
||||
together: 'has to be set along with %{attribute}'
|
||||
|
@ -99,5 +99,4 @@ Rails.application.routes.draw do
|
||||
end
|
||||
end
|
||||
|
||||
resources :teams
|
||||
end
|
||||
|
Reference in New Issue
Block a user