Skip to content

Commit

Permalink
Merge pull request #143 from /issues/126/add-access-ends-picker
Browse files Browse the repository at this point in the history
Fix #126
  • Loading branch information
bodhish committed Dec 13, 2019
2 parents 318decc + fb7c944 commit eb14647
Show file tree
Hide file tree
Showing 48 changed files with 1,674 additions and 1,426 deletions.
3 changes: 1 addition & 2 deletions app/admin/founder.rb
Expand Up @@ -3,7 +3,7 @@

permit_params :name, :remote_avatar_url, :avatar, :startup_id, :about, :communication_address, :phone,
:college_id, :twitter_url, :linkedin_url, :personal_website_url, :blog_url, :angel_co_url, :github_url,
:behance_url, :skype_id, :exited, :excluded_from_leaderboard, roles: [], tag_list: []
:behance_url, :skype_id, :excluded_from_leaderboard, roles: [], tag_list: []

controller do
include DisableIntercom
Expand Down Expand Up @@ -169,7 +169,6 @@ def find_resource
end
end

row :exited
row :excluded_from_leaderboard
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -161,7 +161,7 @@ def authenticate_founder!
# User must be logged in.
authenticate_user!

return if current_founder.present? && !current_founder.exited?
return if current_founder.present? && current_founder.startup.exited_at.nil?

redirect_to 'https://www.sv.co'
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/founders_controller.rb
Expand Up @@ -5,7 +5,7 @@ class FoundersController < ApplicationController
def show
@founder = authorize(Founder.find(params[:id]))
# Show site wide notice to exited founders
@sitewide_notice = @founder.exited? if @founder.user == current_user
@sitewide_notice = @founder.startup.exited_at? if @founder.user == current_user
@timeline_events = Kaminari.paginate_array(events_for_display).page(params[:page]).per(20)
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/schools/courses_controller.rb
Expand Up @@ -94,7 +94,7 @@ def mark_teams_active

Startup.transaction do
course.startups.where(id: params[:team_ids]).each do |startup|
startup.update!(access_ends_at: nil)
startup.update!(access_ends_at: nil, exited_at: nil)
end

render json: { message: 'Teams marked active successfully!', error: nil }
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/schools/founders_controller.rb
Expand Up @@ -26,7 +26,7 @@ def update

form = Schools::Founders::EditForm.new(student)

response = if form.validate(params[:founder].merge(tags: params[:tags], coach_ids: params[:coach_ids]))
response = if form.validate(params[:founder].merge(tags: params[:tags], access_ends_at: params[:access_ends_at], coach_ids: params[:coach_ids]))
form.save
presenter = Schools::Founders::IndexPresenter.new(view_context, @course)
{ teams: presenter.teams, students: presenter.students, error: nil }
Expand Down
18 changes: 3 additions & 15 deletions app/forms/schools/founders/edit_form.rb
Expand Up @@ -3,27 +3,27 @@ module Founders
class EditForm < Reform::Form
property :name, validates: { presence: true }
property :team_name, virtual: true, validates: { presence: true }
property :exited, validates: { inclusion: { in: [true, false] } }
property :excluded_from_leaderboard, validates: { inclusion: { in: [true, false] } }
property :tags
property :coach_ids, virtual: true
property :title, virtual: true, validates: { presence: true }
property :affiliation, virtual: true
property :access_ends_at, virtual: true

def save
Founder.transaction do
school = model.school
model.user.update!(name: name, title: title, affiliation: affiliation)

model.startup.update!(name: override_team_name)
model.startup.update!(name: override_team_name, access_ends_at: access_ends_at)
model.tag_list = tags
model.excluded_from_leaderboard = excluded_from_leaderboard
model.save!

school.founder_tag_list << tags
school.save!

handle_exited(model, exited)
::Startups::AssignReviewerService.new(model.startup).assign(coach_ids)
end
end

Expand All @@ -32,18 +32,6 @@ def save
def override_team_name
model.startup.founders.one? ? name : team_name
end

def handle_exited(founder, exited)
if exited
::Founders::MarkAsExitedService.new(model.id).execute
else
# Re-assign team coaches.
::Startups::AssignReviewerService.new(founder.startup).assign(coach_ids)

# Reset exited if it has changed.
founder.update!(exited: false) if founder.exited?
end
end
end
end
end
22 changes: 22 additions & 0 deletions app/graphql/mutations/dropout_student.rb
@@ -0,0 +1,22 @@
module Mutations
class DropoutStudent < GraphQL::Schema::Mutation
argument :id, ID, required: true

description "Mark student as exited"

field :success, Boolean, null: false

def resolve(params)
mutator = DropoutStudentMutator.new(context, params)

if mutator.valid?
mutator.execute
mutator.notify(:success, 'Student updated successfully', 'Reloading page')
{ success: true }
else
mutator.notify_errors
{ success: false }
end
end
end
end
1 change: 1 addition & 0 deletions app/graphql/types/mutation_type.rb
Expand Up @@ -36,5 +36,6 @@ class MutationType < Types::BaseObject
field :update_review_checklist, mutation: Mutations::UpdateReviewChecklist, null: false
field :delete_school_admin, mutation: Mutations::DeleteSchoolAdmin, null: false
field :create_coach_note, mutation: Mutations::CreateCoachNote, null: false
field :dropout_student, mutation: Mutations::DropoutStudent, null: false
end
end
2 changes: 2 additions & 0 deletions app/javascript/packs/SchoolsCoursesStudentsPack.re
@@ -1,3 +1,5 @@
[@bs.config {jsx: 3}];

open StudentsPanel__Types;

type props = {
Expand Down

0 comments on commit eb14647

Please sign in to comment.