Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Founders to Students #1309

Merged
merged 42 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
21eaa52
fix: Rename founders controller to students controller
youmari May 28, 2023
be9ec18
fix: Rename Founders to students
youmari May 28, 2023
4c5de81
fix: Rename Founder to Student
youmari May 28, 2023
d693633
Fix Styles effected by RTL-UI changes (#1279)
yash-learner Apr 28, 2023
22ac6fd
Add functionality to log user name changes (#1273)
kaisersakhi May 2, 2023
ac7b23d
Organisation admins and school admins can see the inactive cohorts (#…
yash-learner May 3, 2023
a0453e5
Increase i18n coverage (#1204)
mabras May 9, 2023
dbebb07
Remove unused assets (#1184)
mabras May 9, 2023
13acacc
Separate primary and secondary nav names (#1288)
harigopal May 9, 2023
dc86798
Make the certificate ID a link (#1275)
mabras May 10, 2023
1a63ee7
List students based on the last seen status in students page (#1289)
kaisersakhi May 11, 2023
a2cbd2d
Always center the school name (#1276)
mabras May 12, 2023
5ba1b45
Fix text overflow in footer links (#1286)
youmari May 13, 2023
5bd887b
Require confirmation when closing review tab that has some feedback (…
yash-learner May 16, 2023
f9280af
Remove faculty_id from target table (#1290)
kaisersakhi May 17, 2023
3e0ac6c
Document some essential env vars with defaults [skip ci]
harigopal May 17, 2023
d855020
fix: School names do not show in email form (#1304)
youmari May 22, 2023
f9c2ee4
Specify exact version of Node.js [skip ci]
harigopal May 23, 2023
6be02c8
Show a custom page when Discord account linking is required (#1292)
harigopal May 24, 2023
2fa6e21
Merge remote-tracking branch 'upstream/master' into fix/Rename-founde…
youmari May 28, 2023
8857ddc
fix: Rubocop
youmari May 28, 2023
8b5c69e
fix
youmari May 28, 2023
6cd5132
fix: more rename
youmari May 29, 2023
95ccb53
fix: test
youmari May 29, 2023
cae5f1a
Merge branch 'master' into fix/Rename-founders-to-students
youmari Jun 7, 2023
eab43a6
fix: more rename
youmari Jun 8, 2023
73a7b18
fix
youmari Jun 8, 2023
e74d4d3
fix locales
youmari Jun 8, 2023
b71ad90
fix docs
mabras Jun 8, 2023
d83b72e
Merge branch 'master' into fix/Rename-founders-to-students
bodhish Jul 18, 2023
fbe6ece
Clean up delete account service
bodhish Jul 18, 2023
15bf429
Update the migration
bodhish Jul 18, 2023
76aad9e
Clean up current student
bodhish Jul 18, 2023
bf388dc
More changes
bodhish Jul 18, 2023
1cd9a68
Clean up more instances of founder
bodhish Jul 18, 2023
be6f2b2
Add migration for updating the taggings
bodhish Jul 18, 2023
695a771
Fix faculty policy spec
bodhish Jul 18, 2023
7431ddd
Update the LMS version
bodhish Jul 18, 2023
7a0b148
Make the migration performant
bodhish Jul 18, 2023
5f2fc4d
Update the migration to deal with tags
bodhish Jul 18, 2023
418a502
Fix a slow query
bodhish Jul 18, 2023
cbbb714
Merge branch 'master' into fix/Rename-founders-to-students
bodhish Jul 20, 2023
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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- "docs/**"
env:
PF_IMAGE_NAME: pupilfirst
PF_VERSION: "2023.1"
PF_VERSION: "2023.2"
YARN_CHECKSUM_BEHAVIOR: ignore
jobs:
tests:
Expand Down
46 changes: 6 additions & 40 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class ApplicationController < ActionController::Base
helper_method :avatar
helper_method :current_host
helper_method :current_school
helper_method :current_founder
helper_method :current_coach
helper_method :current_school_admin

Expand Down Expand Up @@ -89,29 +88,6 @@ def current_coach
@current_coach ||= current_user&.faculty
end

def current_founder
@current_founder ||=
begin
if current_user.present?
founder_id = read_cookie(:founder_id)

# Founders in current school for the user
founders = current_user.founders

# Try to select founder from value stored in cookie.
founder =
if founder_id.present?
founders.not_dropped_out.find_by(id: founder_id)
else
nil
end

# Return selected founder, if any, or return the first founder (if any).
founder.presence || founders.not_dropped_out.first
end
end
end

def current_school_admin
@current_school_admin ||=
begin
Expand Down Expand Up @@ -158,10 +134,9 @@ def observable_redirect_to(url)
def pundit_user
OpenStruct.new(
current_user: current_user,
current_founder: current_founder,
current_school: current_school,
current_coach: current_coach,
current_school_admin: current_school_admin,
current_school_admin: current_school_admin
)
end

Expand Down Expand Up @@ -203,15 +178,6 @@ def sign_out_if_required
redirect_to root_url if service.signed_out?
end

def authenticate_founder!
# User must be logged in.
authenticate_user!

return if current_founder.present? && !current_founder.dropped_out_at?

redirect_to root_path
end

def storable_location?
non_html_response =
destroy_user_session_path ||
Expand All @@ -230,7 +196,7 @@ def store_user_location

def avatar(
name,
founder: nil,
student: nil,
faculty: nil,
version: :mid,
background_shape: :circle
Expand All @@ -239,15 +205,15 @@ def avatar(
return helpers.image_tag(faculty.image).html_safe
end

if founder.present? && founder.avatar.attached?
return helpers.image_tag(founder.avatar_variant(version)).html_safe
if student.present? && student.avatar.attached?
return helpers.image_tag(student.avatar_variant(version)).html_safe
end

Scarf::InitialAvatar
.new(
name,
font_family: ["Source Sans Pro", "sans-serif"],
background_shape: background_shape,
background_shape: background_shape
)
.svg
.html_safe
Expand All @@ -258,7 +224,7 @@ def domain_redirection_required?

return false if current_domain.primary? || current_school.domains.one?
!Schools::Configuration.new(
current_school,
current_school
).disable_primary_domain_redirection?
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/discord_account_requirable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def require_discord_account

# Redirect only if the user is an active student in the course.
unless current_user
.founders
.students
.joins(cohort: :course)
.where(courses: { id: course.id })
.merge(Cohort.active)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def find_course
def save_tag
return if params[:tag].blank?

if params[:tag].in?(current_school.founder_tag_list)
if params[:tag].in?(current_school.student_tag_list)
session[:applicant_tag] = params[:tag]
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/organisations/students_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ class StudentsController < ApplicationController

# GET /org/students/:id
def show
student = authorize Founder.find(params[:id])
student = authorize Student.find(params[:id])
@presenter = StudentPresenter.new(view_context, student)
end

# GET /org/students/:id/submissions
def submissions
student = authorize Founder.find(params[:id])
student = authorize Student.find(params[:id])
@presenter = StudentPresenter.new(view_context, student)
raise_not_found if @presenter.reviewed_submissions.empty?
end
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/organisations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def prepare_courses

course[:active_students] = @organisation
.users
.joins(:founders)
.where(founders: { cohort_id: cohort_ids })
.joins(:students)
.where(students: { cohort_id: cohort_ids })
.distinct
.count

Expand All @@ -65,9 +65,9 @@ def prepare_counts
scope = @organisation.users

{
total_students: scope.joins(:founders).distinct.count,
total_students: scope.joins(:students).distinct.count,
active_students:
scope.joins(founders: :cohort).merge(Cohort.active).distinct.count
scope.joins(students: :cohort).merge(Cohort.active).distinct.count
}
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class FoundersController < ApplicationController
class StudentsController < ApplicationController
# GET /students/:id/report
def report
student = authorize(Founder.find(params[:id]))
student = authorize(Student.find(params[:id]))
@course = student.course
render html: '', layout: 'app_router'
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/targets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def show
def details_v2
student =
current_user
.founders
.students
.joins(:course)
.where(courses: { id: @course.id })
.first if current_user.present?
Expand Down
2 changes: 1 addition & 1 deletion app/forms/schools/coaches/update_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def faculty

def clear_faculty_enrollments
FacultyCohortEnrollment.where(faculty: faculty).destroy_all
FacultyFounderEnrollment.where(faculty: faculty).destroy_all
FacultyStudentEnrollment.where(faculty: faculty).destroy_all
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/concerns/query_authorize_coach.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ def query_authorized?

return false if course&.school != current_school

current_user.faculty.cohorts.exists?(id: submission.founders.first.cohort)
current_user.faculty.cohorts.exists?(id: submission.students.first.cohort)
end
end
2 changes: 1 addition & 1 deletion app/graphql/concerns/query_authorize_community_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def authorized_create?

# User should have access to the community
current_user
.founders
.students
.includes(:course)
.where(courses: { id: community.courses })
.any?
Expand Down
6 changes: 3 additions & 3 deletions app/graphql/concerns/query_authorize_student.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def query_authorized?
# Has access to school
return false unless course&.school == current_school && student.present?

# Founder has access to the course
# Student has access to the course
return false unless !student.cohort.ended?

# Level must be accessible.
Expand All @@ -28,7 +28,7 @@ def target_can_be_completed?
def student
@student ||=
current_user
.founders
.students
.joins(:level)
.where(levels: { course_id: course })
.first
Expand All @@ -44,7 +44,7 @@ def target

def students
if target.team_target? && student.team.exists?
student.team.founders
student.team.students
else
[student]
end
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/concerns/validate_course_export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class RequireValidTags < GraphQL::Schema::Validator
def validate(_object, _context, value)
course = Course.find_by(id: value[:course_id])
current_school = course&.school
tags = current_school.founder_tags.where(id: value[:tag_ids])
tags = current_school.student_tags.where(id: value[:tag_ids])
return if value[:tag_ids].count == tags.count
I18n.t("mutations.export_course_report.tag_not_found_error")
end
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/concerns/validate_student_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def validate(_object, context, value)
course = target.course
student =
context[:current_user]
.founders
.students
.joins(:level)
.where(levels: { course_id: course })
.first
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/concerns/validate_submission_gradable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def validate(_object, _context, value)
submission_review_allowed =
(days_since_submission < submission_review_allowed_days)

if (submission.founders.active.empty? && !submission_review_allowed)
if (submission.students.active.empty? && !submission_review_allowed)
return(
I18n.t('validate_submission_gradable.owners_should_be_active.error')
)
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/mutations/create_course_export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def resolve(_params)
end

def tags
@tags ||= current_school.founder_tags.where(id: @params[:tag_ids])
@tags ||= current_school.student_tags.where(id: @params[:tag_ids])
end

def cohorts
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/mutations/create_grading.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def allow_token_auth?
end

def update_coach_note
submission.founders.each do |student|
submission.students.each do |student|
CoachNote.create!(
note: @params[:note],
author_id: current_user.id,
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/mutations/create_student_from_applicant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def resolve(_params)
end

def convert_applicant
Founder.transaction do
Student.transaction do
student =
Applicants::CreateStudentService.new(applicant).create(@params[:tags])

Expand Down
2 changes: 1 addition & 1 deletion app/graphql/mutations/create_students.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def emails_must_be_valid

def soft_limit_student_count
if @cohort.blank? || @cohort.course.blank? ||
@cohort.course.founders.count < 100_000
@cohort.course.students.count < 100_000
return
end

Expand Down
4 changes: 2 additions & 2 deletions app/graphql/mutations/create_team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def size_grater_than_two

def students_should_belong_to_the_same_cohort
if @cohort
.founders
.students
.where(id: @value[:student_ids], team_id: nil)
.count == @value[:student_ids].count
return
Expand All @@ -71,7 +71,7 @@ def create_team
end

def students
@students ||= cohort.founders.where(id: @params[:student_ids])
@students ||= cohort.students.where(id: @params[:student_ids])
end

def cohort
Expand Down
8 changes: 4 additions & 4 deletions app/graphql/mutations/create_topic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ def topic_category
def create_subscribers(topic)
users =
User
.joins(faculty: :faculty_founder_enrollments)
.joins(faculty: :faculty_student_enrollments)
.where(
faculty: {
faculty_founder_enrollments: {
founder_id: current_user.founders.active
faculty_student_enrollments: {
student_id: current_user.students.active
}
}
)
Expand All @@ -107,7 +107,7 @@ def target
def target_accessible?(some_target)
current_school_admin.present? || current_user.faculty.present? ||
current_user
.founders
.students
.joins(:course)
.exists?(courses: { id: some_target.course.id })
end
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/mutations/destroy_team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def resolve(_params)

def destroy_team
Team.transaction do
team.founders.each { |student| student.update!(team: nil) }
team.students.each { |student| student.update!(team: nil) }
team.reload.destroy!
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/graphql/mutations/re_activate_student.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def resolve(_params)

class ValidateStudentStatus < GraphQL::Schema::Validator
def validate(_object, _context, value)
@student = Founder.find_by(id: value[:id])
@student = Student.find_by(id: value[:id])

return if @student.dropped_out_at?

Expand All @@ -37,7 +37,7 @@ def resource_school
end

def student
@student ||= Founder.find_by(id: @params[:id])
@student ||= Student.find_by(id: @params[:id])
end
end
end
2 changes: 1 addition & 1 deletion app/graphql/mutations/re_run_github_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class StudentHasAGithubAccount < GraphQL::Schema::Validator
def validate(_object, _context, value)
submission = TimelineEvent.find_by(id: value[:submission_id])

if submission.founders.first.github_repository.blank?
if submission.students.first.github_repository.blank?
return I18n.t("mutations.re_run_github_action.validation_error.student_has_no_github_account")
end
end
Expand Down
Loading
Loading