Skip to content

Commit

Permalink
P20-57: Display modal when parent permission is not requested
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-vavilov committed May 1, 2024
1 parent 90cd18e commit 5a6fd0c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
7 changes: 5 additions & 2 deletions dashboard/app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,13 @@
= render partial: 'layouts/logo'
- if current_user && Policies::Lti.early_access_banner_available?(current_user)
= render partial: 'lti/v1/early_access_banner'

-# CAP parent permission warnings
- if Cpa.cpa_experience(request) == Cpa::ALL_USER_LOCKOUT_WARNING
- if current_user && (student_lockout_date = Policies::ChildAccount.lockout_date(current_user))
= render partial: 'policy_compliance/pre_lockdown/parent_permission_modal',
locals: {student_uuid: current_user.uuid, lockout_date: student_lockout_date}
- unless Policies::ChildAccount::ComplianceState.request_sent?(current_user)
= render partial: 'policy_compliance/pre_lockdown/parent_permission_modal',
locals: {student_uuid: current_user.uuid, lockout_date: student_lockout_date}

- page = yield

Expand Down
24 changes: 11 additions & 13 deletions dashboard/lib/policies/child_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,6 @@ module ComplianceState
# The maximum number of times a student can resend a request to a parent.
MAX_PARENT_PERMISSION_RESENDS = 3

def self.state_policy(user)
return unless user.us_state
STATE_POLICY[user.us_state]
end

# The date on which the student's account will be locked if the account is not compliant.
def self.lockout_date(user)
return DateTime.parse('2024-07-01')
return if compliant?(user)

state_policy(user).try(:[], :lockout_date)
end

# Is this user compliant with our Child Account Policy(cap)?
# For students under-13, in Colorado, with a personal email login: we require
# parent permission before the student can start using their account.
Expand All @@ -76,6 +63,17 @@ def self.user_predates_policy?(user)
parent_permission_required?(user) && user.created_at < STATE_POLICY[user.us_state][:start_date]
end

# The date on which the student's account will be locked if the account is not compliant.
def self.lockout_date(user)
return if compliant?(user)
state_policy(user).try(:[], :lockout_date)
end

private_class_method def self.state_policy(user)
return unless user.us_state
STATE_POLICY[user.us_state]
end

# Check if parent permission is required for this account according to our
# Child Account Policy.
private_class_method def self.parent_permission_required?(user)
Expand Down

0 comments on commit 5a6fd0c

Please sign in to comment.