Skip to content

Commit

Permalink
Merge pull request #35 from IT-CEREBRUM/CRB-3762
Browse files Browse the repository at this point in the history
Removing fagperson from fs import for uio
  • Loading branch information
Christina Skåre Nordtømme authored and GitHub Enterprise committed Feb 14, 2023
2 parents 2dc4d78 + 4bb330b commit 87fa917
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 30 deletions.
13 changes: 7 additions & 6 deletions Cerebrum/modules/fs/import_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ def __init__(self, gen_groups, include_delete, commit,
self.commit = commit
self.source = source

self.disregard_grace_for_affs = [
int(self.co.human2constant(x)) for x in
cereconf.FS_EXCLUDE_AFFILIATIONS_FROM_GRACE]

def init_reservation_group(self):
""" get callbacks to add/remove members in reservation group """
group_name = cereconf.FS_GROUP_NAME
Expand Down Expand Up @@ -361,7 +365,7 @@ def _db_add_person(self, person, person_info, pd):
aff_status)
if self.include_delete:
key_a = "%s:%s:%s" % (person.entity_id, ou, int(aff))
if key_a in self.old_aff:
if key_a in self.old_aff and int(aff_status) not in self.disregard_grace_for_affs:
self.old_aff[key_a] = False

self._register_cellphone(person, person_info)
Expand Down Expand Up @@ -606,17 +610,14 @@ def rem_old_aff(self, spare_active_account_affs=False):
they are.
"""

disregard_grace_for_affs = [
int(self.co.human2constant(x)) for x in
cereconf.FS_EXCLUDE_AFFILIATIONS_FROM_GRACE]

logger.info("Removing old FS affiliations")
stats = defaultdict(lambda: 0)
person = Factory.get("Person")(self.db)
person_ids = set()
for k in self.old_aff:
if not self.old_aff[k]:
# Aff still present in import files
#TODO: Checking if an affiliation is valid might still be important even if it exists in important files?
continue

person_id, ou_id, aff_id = (int(val) for val in k.split(':'))
Expand Down Expand Up @@ -646,7 +647,7 @@ def rem_old_aff(self, spare_active_account_affs=False):
grace_days = cereconf.FS_STUDENT_REMOVE_AFF_GRACE_DAYS
if (get_date(aff['last_date'])
> (date.today() - timedelta(days=grace_days)) and
int(aff['status']) not in disregard_grace_for_affs):
int(aff['status']) not in self.disregard_grace_for_affs):
logger.debug("Sparing aff (%s) for person_id=%r at ou_id=%r,"
" grace-period in effect",aff_id, person_id, ou_id)
stats['grace'] += 1
Expand Down
19 changes: 2 additions & 17 deletions contrib/no/uio/import_FS.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ def _get_person_data(self, person_info, fnr):
continue
# Get name
if dta_type in (
'fagperson',
'opptak',
'tilbud',
'evu',
Expand All @@ -211,17 +210,7 @@ def _get_person_data(self, person_info, fnr):
if 'personlopenr' in p:
personlopenr = p['personlopenr']
# Get affiliations
if dta_type in ('fagperson',):
self._process_affiliation(
self.co.affiliation_tilknyttet,
self.co.affiliation_tilknyttet_fagperson,
affiliations,
self._get_sko(p,
'faknr',
'instituttnr',
'gruppenr',
'institusjonsnr'))
elif dta_type in ('opptak',):
if dta_type in ('opptak',):
for row in x:
subtype = self.co.affiliation_status_student_opptak
if (self.studieprog2sko[row['studieprogramkode']]
Expand Down Expand Up @@ -429,7 +418,6 @@ def main():
Cerebrum.logutils.autoconf('cronjob', args)

rules = [
('fagperson', ('_arbeide', '_hjemsted', '_besok_adr')),
('aktiv', ('_semadr', '_hjemsted', None)),
('emnestud', ('_semadr', '_hjemsted', None)),
('evu', ('_job', '_hjem', None)),
Expand All @@ -442,8 +430,6 @@ def main():
'aktiv': 'opptak'
}
adr_map = {
'_arbeide': ('adrlin1_arbeide', 'adrlin2_arbeide', 'adrlin3_arbeide',
'postnr_arbeide', 'adresseland_arbeide'),
'_hjemsted': ('adrlin1_hjemsted', 'adrlin2_hjemsted',
'adrlin3_hjemsted', 'postnr_hjemsted',
'adresseland_hjemsted'),
Expand All @@ -452,8 +438,7 @@ def main():
'_job': ('adrlin1_job', 'adrlin2_job', 'adrlin3_job', 'postnr_job',
'adresseland_job'),
'_hjem': ('adrlin1_hjem', 'adrlin2_hjem', 'adrlin3_hjem',
'postnr_hjem', 'adresseland_hjem'),
'_besok_adr': ('institusjonsnr', 'faknr', 'instituttnr', 'gruppenr')
'postnr_hjem', 'adresseland_hjem')
}
fs_importer = FsImporterUio(args.gen_groups,
args.include_delete, args.commit,
Expand Down
7 changes: 0 additions & 7 deletions contrib/no/uio/import_from_FS.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,6 @@ def write_person_info(self, person_file):
f.write(
xml.xmlify_dbrow(d, xml.conv_colnames(cols), 'drgrad') + "\n")

# Fagpersoner
cols, fagpersoner = self._ext_cols(
self.fs.undervisning.list_fagperson_semester())
for p in fagpersoner:
f.write(
xml.xmlify_dbrow(
p, xml.conv_colnames(cols), 'fagperson') + "\n")

# Studenter med opptak, privatister (=opptak i studiepgraommet
# privatist) og Alumni
Expand Down

0 comments on commit 87fa917

Please sign in to comment.