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

wth - (SPARCFulfillment) Make the Klok Import Resource Format Rule St… #247

Merged
merged 1 commit into from Nov 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 14 additions & 12 deletions app/controllers/imports_controller.rb
Expand Up @@ -40,19 +40,21 @@ def create
respond_to do |format|
if import.save
import.update_attribute(:title, determine_if_proof_report ? I18n.t('imports.proof_report_submit') : I18n.t('imports.klok_report_submit'))
log_file, valid = import.generate(import.xml_file, determine_if_proof_report)
import.update_attribute(:file, File.open(log_file))
@valid = valid
if @valid
format.js
format.html { redirect_to imports_path }
else
import.destroy
format.js
begin
log_file, valid = import.generate(import.xml_file, determine_if_proof_report)
import.update_attribute(:file, File.open(log_file))
@valid = valid
if @valid
format.js
format.html { redirect_to imports_path }
else
import.destroy
format.js
end
rescue
format.js { render js: "swal('Improper Klok Format', 'Klok File is improperly formatted, name must be formatted as - Name (NetId)', 'error');" }
format.html { render :new }
end
else
format.js
format.html { render :new }
end
end
end
Expand Down
14 changes: 9 additions & 5 deletions app/models/klok/person.rb
Expand Up @@ -27,9 +27,13 @@ class Klok::Person < ActiveRecord::Base
has_many :klok_projects, class_name: 'Klok::Project', foreign_key: :resource_id, through: :klok_entries

def local_identity
ldap_uid = name.split(" ").last.gsub(/[\(\)]*/, '')
ldap_uid += "@musc.edu" #### TODO, update Klok so that @musc.edu is added
Identity.where(ldap_uid: ldap_uid).first
end

if name.match(/\([^()]*\)(?![^\[]*])/).nil?
ldap_uid = name.split(" ").last.gsub(/[\(\)]*/, '')
ldap_uid += "@musc.edu" #### TODO, update Klok so that @musc.edu is added
Identity.where(ldap_uid: ldap_uid).first
else
raise StandardError, "Improper Format"
end
end
end