Skip to content

Commit

Permalink
Merge pull request #39 from IT-CEREBRUM/CRB-3739_extra
Browse files Browse the repository at this point in the history
Finish CRB-3739 find_sko()
  • Loading branch information
Christina Skåre Nordtømme authored and GitHub Enterprise committed Feb 13, 2023
2 parents 384ae9d + dfa0822 commit 2dc4d78
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
15 changes: 4 additions & 11 deletions Cerebrum/modules/bofhd/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,19 +257,12 @@ def get_target_disk(path):
def get_target_ou_by_stedkode(stedkode):
ou = Factory.get("OU")(self.db)

if len(stedkode) != 6 or not stedkode.isdigit():
raise CerebrumError("Expected a six-digit stedkode.")

try:
ou.find_stedkode(
stedkode[0:2],
stedkode[2:4],
stedkode[4:6],
cereconf.DEFAULT_INSTITUSJONSNR
)
ou.find_sko(stedkode)
except ValueError:
raise CerebrumError("Expected a six-digit stedkode")
except Errors.NotFoundError:
raise CerebrumError("Stedkode %s was not found." % stedkode)

raise CerebrumError("Could not find Organizational Unit with stedkode=%s" % stedkode)
return ou

#
Expand Down
2 changes: 0 additions & 2 deletions Cerebrum/modules/no/orgera/ou_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ def get_ou_by_sko(db, sko):
"""
Fetch an OU object by stedkode
"""
if len(sko) != 6 or not sko.isdigit():
raise ValueError('Invalid stedkode: %s' % repr(sko))

ou = Factory.get('OU')(db)
ou.find_sko(sko)
Expand Down

0 comments on commit 2dc4d78

Please sign in to comment.