Last active
May 2, 2017 15:04
-
-
Save kstevens715/48b48470b6719b6fea7f25b9c54c409e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Documents | |
class Loader | |
def initialize(current_user_identity, current_organization, applicant, programs) | |
@current_user_identity = current_user_identity | |
@current_organization = current_organization | |
@applicant = applicant | |
@programs = programs | |
@panels = {} | |
end | |
def load(sub_panel=:documents) | |
sub_panel = sub_panel.to_sym | |
@panels[sub_panel] ||= load_for_real(sub_panel) | |
end | |
private | |
attr_reader :applicant, :current_user_identity, :current_organization, :programs | |
def load_for_real(subpanel) | |
if sub_panel.to_sym == :admissions_uploaded_documents | |
if feature?('applicant_attachments') | |
applicant.attachments. | |
by_organization(current_organization). | |
order("applicant_attachments.created_at DESC") | |
end | |
else | |
Documents::DocumentType.current_user_identity = current_user_identity | |
documents = ::Documents.for_applicant_in_programs(applicant, programs, sub_panel.to_sym) || [] | |
documents.sort_by { |document| document.title } | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment