Skip to content

Commit

Permalink
Courses: Add open_format to season
Browse files Browse the repository at this point in the history
  • Loading branch information
sveredyuk committed Jun 19, 2021
1 parent 5fc1c2a commit 42b67cf
Show file tree
Hide file tree
Showing 18 changed files with 260 additions and 215 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ PATH
courses (0.1.0)
friendly_id
kaminari
rails
rails (= 5.2.5)
simple_form
slim-rails

Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/app/_header.slim
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ header.pk-header class="#{header_classlist.compact.join(' ')}"
ul.pk-header__li-list
- if admin?
li.pk-header__li-list-item = admin_link
- if student
- if student&.persisted?
li.pk-header__li-list-item = student_course_link(student)
li.pk-header__li-list-item = profile_link
li.pk-header__li-list-item = logout_link
Expand Down
162 changes: 81 additions & 81 deletions components/courses/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,58 @@ PATH
courses (0.1.0)
friendly_id
kaminari
rails
rails (= 5.2.5)
simple_form
slim-rails

GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.2.1)
actionpack (= 5.2.2.1)
actioncable (5.2.5)
actionpack (= 5.2.5)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.2.1)
actionpack (= 5.2.2.1)
actionview (= 5.2.2.1)
activejob (= 5.2.2.1)
actionmailer (5.2.5)
actionpack (= 5.2.5)
actionview (= 5.2.5)
activejob (= 5.2.5)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.2.1)
actionview (= 5.2.2.1)
activesupport (= 5.2.2.1)
rack (~> 2.0)
actionpack (5.2.5)
actionview (= 5.2.5)
activesupport (= 5.2.5)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.2.1)
activesupport (= 5.2.2.1)
actionview (5.2.5)
activesupport (= 5.2.5)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.2.2.1)
activesupport (= 5.2.2.1)
activejob (5.2.5)
activesupport (= 5.2.5)
globalid (>= 0.3.6)
activemodel (5.2.2.1)
activesupport (= 5.2.2.1)
activerecord (5.2.2.1)
activemodel (= 5.2.2.1)
activesupport (= 5.2.2.1)
activemodel (5.2.5)
activesupport (= 5.2.5)
activerecord (5.2.5)
activemodel (= 5.2.5)
activesupport (= 5.2.5)
arel (>= 9.0)
activestorage (5.2.2.1)
actionpack (= 5.2.2.1)
activerecord (= 5.2.2.1)
marcel (~> 0.3.1)
activesupport (5.2.2.1)
activestorage (5.2.5)
actionpack (= 5.2.5)
activerecord (= 5.2.5)
marcel (~> 1.0.0)
activesupport (5.2.5)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
arel (9.0.0)
builder (3.2.3)
builder (3.2.4)
capybara (3.15.0)
addressable
mini_mime (>= 0.1.3)
Expand All @@ -65,11 +65,11 @@ GEM
regexp_parser (~> 1.2)
xpath (~> 3.2)
coderay (1.1.2)
concurrent-ruby (1.1.5)
crass (1.0.4)
concurrent-ruby (1.1.9)
crass (1.0.6)
diff-lcs (1.3)
docile (1.3.1)
erubi (1.8.0)
erubi (1.10.0)
factory_bot (5.0.2)
activesupport (>= 4.2.0)
factory_bot_rails (5.0.1)
Expand All @@ -79,7 +79,7 @@ GEM
i18n (>= 0.7)
ffi (1.10.0)
formatador (0.2.5)
friendly_id (5.2.5)
friendly_id (5.4.2)
activerecord (>= 4.0.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
Expand All @@ -97,44 +97,43 @@ GEM
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
i18n (1.6.0)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
json (2.2.0)
kaminari (1.1.1)
kaminari (1.2.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.1.1)
kaminari-activerecord (= 1.1.1)
kaminari-core (= 1.1.1)
kaminari-actionview (1.1.1)
kaminari-actionview (= 1.2.1)
kaminari-activerecord (= 1.2.1)
kaminari-core (= 1.2.1)
kaminari-actionview (1.2.1)
actionview
kaminari-core (= 1.1.1)
kaminari-activerecord (1.1.1)
kaminari-core (= 1.2.1)
kaminari-activerecord (1.2.1)
activerecord
kaminari-core (= 1.1.1)
kaminari-core (1.1.1)
kaminari-core (= 1.2.1)
kaminari-core (1.2.1)
launchy (2.4.3)
addressable (~> 2.3)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.2.3)
loofah (2.10.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
lumberjack (1.0.13)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
marcel (1.0.1)
method_source (0.9.2)
mimemagic (0.3.3)
mini_mime (1.0.1)
mini_portile2 (2.4.0)
minitest (5.11.3)
mini_mime (1.1.0)
mini_portile2 (2.5.3)
minitest (5.14.4)
nenv (0.3.0)
nio4r (2.3.1)
nokogiri (1.10.1)
mini_portile2 (~> 2.4.0)
nio4r (2.5.7)
nokogiri (1.11.7)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
Expand All @@ -144,34 +143,35 @@ GEM
pry-rails (0.3.9)
pry (>= 0.10.4)
public_suffix (3.0.3)
rack (2.0.6)
racc (1.5.2)
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.2.1)
actioncable (= 5.2.2.1)
actionmailer (= 5.2.2.1)
actionpack (= 5.2.2.1)
actionview (= 5.2.2.1)
activejob (= 5.2.2.1)
activemodel (= 5.2.2.1)
activerecord (= 5.2.2.1)
activestorage (= 5.2.2.1)
activesupport (= 5.2.2.1)
rails (5.2.5)
actioncable (= 5.2.5)
actionmailer (= 5.2.5)
actionpack (= 5.2.5)
actionview (= 5.2.5)
activejob (= 5.2.5)
activemodel (= 5.2.5)
activerecord (= 5.2.5)
activestorage (= 5.2.5)
activesupport (= 5.2.5)
bundler (>= 1.3.0)
railties (= 5.2.2.1)
railties (= 5.2.5)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (5.2.2.1)
actionpack (= 5.2.2.1)
activesupport (= 5.2.2.1)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (5.2.5)
actionpack (= 5.2.5)
activesupport (= 5.2.5)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rake (12.3.2)
rake (13.0.3)
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
ffi (~> 1.0)
Expand Down Expand Up @@ -199,38 +199,38 @@ GEM
rspec-support (3.8.0)
ruby_dep (1.5.0)
shellany (0.0.1)
simple_form (4.1.0)
actionpack (>= 5.0)
activemodel (>= 5.0)
simple_form (5.1.0)
actionpack (>= 5.2)
activemodel (>= 5.2)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
slim (4.0.1)
slim (4.1.0)
temple (>= 0.7.6, < 0.9)
tilt (>= 2.0.6, < 2.1)
slim-rails (3.2.0)
actionpack (>= 3.1)
railties (>= 3.1)
slim (>= 3.0, < 5.0)
sprockets (3.7.2)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
temple (0.8.1)
thor (0.20.3)
temple (0.8.2)
thor (1.1.0)
thread_safe (0.3.6)
tilt (2.0.9)
tzinfo (1.2.5)
tilt (2.0.10)
tzinfo (1.2.9)
thread_safe (~> 0.1)
websocket-driver (0.7.0)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)

Expand All @@ -250,4 +250,4 @@ DEPENDENCIES
sqlite3 (~> 1.3.6)

BUNDLED WITH
1.16.1
1.17.2
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def graduate_policy(season)
end

def seasons_params
params.require(:season).permit(:title, :start_at, :finish_at, :status, :description)
params.require(:season).permit(:title, :start_at, :finish_at, :status, :description, :open_format)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def new
end

def create
@student = Student::Create.call(student_params, current_season.id, current_user.id)
@student = Student::Create.call(student_params, current_season, current_user.id)
react_to student.save
end

Expand Down
1 change: 1 addition & 0 deletions components/courses/app/helpers/courses/season_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def courses_register_link(season, student)
end

def courses_send_test_task_link(season, student)
return if season.open_format?
return unless ::Courses::Season::SendTestTaskPolicy.new(season, student).allowed?

if student.test_task
Expand Down
9 changes: 5 additions & 4 deletions components/courses/app/services/courses/student/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@ def self.call(*args)
new(*args).call
end

def initialize(student_params, season_id, user_id)
def initialize(student_params, season, user_id)
@student_params = student_params
@season_id = season_id
@season = season
@user_id = user_id
end

def call
@student = ::Courses::Student.new(student_params)
@student.season_id = season_id
@student.season = season
@student.user_id = user_id
@student.status = Courses::Student::ATTENDING if season.open_format?
@student
end

private

attr_reader :student_params, :season_id, :user_id
attr_reader :student_params, :season, :user_id
end
end
end
4 changes: 2 additions & 2 deletions components/courses/app/services/courses/test_task/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
module Courses
class TestTask < ApplicationRecord
class Update < ApplicationService
def initialize(test_task, mentor, status:, notes: nil)
def initialize(test_task, mentor, status: Courses::TestTask::ON_REVIEW, notes: nil)
@test_task = test_task
@mentor = mentor
@status = status || Courses::TestTask::ON_REVIEW
@status = status
@notes = notes || test_task.notes
end

Expand Down
2 changes: 2 additions & 0 deletions components/courses/app/views/admin/courses/seasons/form.slim
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

= simple_form_for [:admin, season], as: :season do |f|
.fields
.six.wide.field.ui.slider.checkbox = f.input :open_format, as: :boolean
.sixteen.wide.field.right-align
= admin_back_link('courses_seasons')
= f.button :submit
Expand All @@ -13,6 +14,7 @@
.six.wide.field = f.input :title
.six.wide.field = f.input :start_at, as: :datetime
.six.wide.field = f.input :finish_at, as: :datetime

.fields
.sixteen.wide.field
= f.input :description, input_html: { rows: 30, class: Simplemde::CONTAINER_CLASS }
2 changes: 1 addition & 1 deletion components/courses/courses.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |s|

s.add_dependency 'friendly_id'
s.add_dependency 'kaminari'
s.add_dependency 'rails'
s.add_dependency 'rails', '5.2.5'
s.add_dependency 'simple_form'
s.add_dependency 'slim-rails'

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddOpenFormatToCourses < ActiveRecord::Migration[5.2]
def change
add_column :courses_seasons, :open_format, :boolean, default: false
end
end
Loading

0 comments on commit 42b67cf

Please sign in to comment.