Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
web: bundle exec puma -C config/puma.rb
release: bundle exec rails db:migrate && bundle exec rake projects:create_experience_cs_examples integration_tests:dispatch
release: bundle exec rails db:migrate && bundle exec rake integration_tests:dispatch
worker: bundle exec good_job start --max-threads=8
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,6 @@ assets asynchronously. Configure `EXPERIENCE_CS_API_KEY` to the same secret as
Experience CS's `EDITOR_API_SYNC_API_KEY`. The corresponding request header is
accepted for public project create/update and global Scratch asset upload.

`PUT /api/experience-cs/projects/:identifier/migrate` lets the service replace
an exact locale-less Experience CS user-project stub with its Markdown
instructions and Scratch content. Project-scoped migration assets use
`POST /api/experience-cs/projects/:identifier/assets/:filename` and remain
subject to the project's normal viewing permissions.

### Code Editor for Education

Editor API provides routes for managing resources such as schools, school classes and lessons, as well as for inviting teachers and managing student accounts via `profile` requests.
66 changes: 0 additions & 66 deletions app/controllers/api/experience_cs_project_migrations_controller.rb

This file was deleted.

26 changes: 2 additions & 24 deletions app/controllers/api/scratch/assets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ module Scratch
class AssetsController < ApiController
include ActiveStorage::SetCurrent

prepend_before_action :load_experience_cs_service_user, only: %i[create_global create_migration]
prepend_before_action :load_experience_cs_service_user, only: %i[create_global]
before_action :authorize_user, except: %i[show]
prepend_before_action :load_project_from_header, only: %i[show create]
authorize_resource :project_from_header, except: %i[create_global create_migration]
before_action :load_migration_project, only: :create_migration
before_action :authorize_migration_asset, only: :create_migration
authorize_resource :project_from_header, except: %i[create_global]

def show
filename_with_extension = "#{params[:id]}.#{params[:format]}"
Expand All @@ -36,15 +34,6 @@ def create
)
end

def create_migration
create_asset(
project: @migration_project,
uploaded_user_id: @migration_project.user_id,
filename: "#{params[:id]}.#{params[:format]}",
reject_conflicting_content: true
)
end

def create_global
authorize! :create_global, ScratchAsset

Expand Down Expand Up @@ -131,17 +120,6 @@ def load_project_from_header
project_type: Project::Types::CODE_EDITOR_SCRATCH
)
end

def load_migration_project
@migration_project = Project.find_by!(
identifier: params.expect(:project_id),
locale: nil
)
end

def authorize_migration_asset
authorize! :upload_migration_asset, @migration_project
end
end
end
end
4 changes: 3 additions & 1 deletion app/jobs/salesforce/lesson_sync_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module Salesforce
class LessonSyncJob < SalesforceSyncJob
MODEL_CLASS = Salesforce::Lesson

EXPERIENCE_CS_SALESFORCE_PROJECT_TYPE = 'scratch'

FIELD_MAPPINGS = {
lesson_uuid__c: :id,
classroom__r__classroomuuid__c: :school_class_id,
Expand Down Expand Up @@ -47,7 +49,7 @@ def mapped_attributes(lesson:)
end

def project_type_attribute(lesson)
return Project::Types::SCRATCH if lesson.project&.origin == Project::Origins::EXPERIENCE_CS
return EXPERIENCE_CS_SALESFORCE_PROJECT_TYPE if lesson.project&.origin == Project::Origins::EXPERIENCE_CS

lesson.project&.project_type
end
Expand Down
7 changes: 0 additions & 7 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def initialize(user)

define_editor_admin_abilities(user)
define_experience_cs_admin_abilities(user)
define_experience_cs_service_abilities(user)
end

private
Expand Down Expand Up @@ -161,12 +160,6 @@ def define_experience_cs_admin_abilities(user)
define_school_import_abilities(user)
end

def define_experience_cs_service_abilities(user)
return unless user&.experience_cs_service_account?

can %i[migrate_from_experience_cs upload_migration_asset], Project, &:experience_cs_migration_target?
end

def school_teacher_can_manage_lesson?(user:, school:, lesson:)
is_my_lesson = lesson.school_id == school.id && lesson.user_id == user.id
is_my_class = lesson.school_class&.teacher_ids&.include?(user.id)
Expand Down
12 changes: 4 additions & 8 deletions app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ class Project < ApplicationRecord
module Types
PYTHON = 'python'
HTML = 'html'
SCRATCH = 'scratch'
CODE_EDITOR_SCRATCH = 'code_editor_scratch'

ALL = [PYTHON, HTML, CODE_EDITOR_SCRATCH].freeze
end

module Origins
EXPERIENCE_CS = 'experience_cs'
end

EXPERIENCE_CS_PROJECT_TYPES = [Types::SCRATCH, Types::CODE_EDITOR_SCRATCH].freeze

belongs_to :school, optional: true
belongs_to :lesson, optional: true
belongs_to :parent, optional: true, class_name: :Project, foreign_key: :remixed_from_id, inverse_of: :remixes
Expand Down Expand Up @@ -45,6 +44,7 @@ module Origins
validate :project_with_instructions_must_belong_to_school
validate :project_with_school_id_has_school_project
validate :school_project_school_matches_project_school
validates :project_type, inclusion: { in: Types::ALL }
validates :origin, inclusion: { in: [Origins::EXPERIENCE_CS], allow_nil: true }
validate :origin_cannot_change, on: :update

Expand Down Expand Up @@ -108,11 +108,7 @@ def scratch_project?
end

def public_experience_cs_project?
user_id.nil? && school_id.nil? && EXPERIENCE_CS_PROJECT_TYPES.include?(project_type)
end

def experience_cs_migration_target?
user_id.present? && school_id.present? && project_type == Types::SCRATCH
user_id.nil? && school_id.nil? && scratch_project?
end

def self_and_ancestors
Expand Down
2 changes: 1 addition & 1 deletion app/models/scratch_asset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def response_content_type
private

def belongs_to_scratch_project
return if project.blank? || Project::EXPERIENCE_CS_PROJECT_TYPES.include?(project.project_type)
return if project.blank? || project.scratch_project?

errors.add(:project, 'must be a Scratch project')
end
Expand Down
3 changes: 0 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
mount GraphiQL::Rails::Engine, at: '/graphql', graphql_path: '/graphql#execute' unless Rails.env.production?

namespace :api do
put '/experience-cs/projects/:id/migrate', to: 'experience_cs_project_migrations#update'
post '/experience-cs/projects/:project_id/assets/:id.:format', to: 'scratch/assets#create_migration'

namespace :scratch do
resources :projects, only: %i[show update create]
get '/assets/internalapi/asset/:id.:format/get/' => 'assets#show'
Expand Down
1 change: 0 additions & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
if Rails.env.development?
Rake::Task['projects:create_all'].invoke
Rake::Task['for_education:seed_a_school_with_lessons_and_students'].invoke
Rake::Task['projects:create_experience_cs_examples'].invoke
end
Loading
Loading