Changeset 161ce5f for asadb


Ignore:
Timestamp:
Dec 24, 2012, 2:30:45 AM (13 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, space-access, stable, stage
Children:
0290330
Parents:
6559695
git-author:
Alex Dehnert <adehnert@…> (12/24/12 02:30:45)
git-committer:
Alex Dehnert <adehnert@…> (12/24/12 02:30:45)
Message:

Describe changes made by load_people (ASA-#192)

groups/load_people.py outputs a summary of the changes it made --- the numbers
of people processed, the usernames imported, etc.. However, it doesn't describe
what *specific* changes occurred --- what fields were updated, what account
class new users are in, etc.. This adds that data. In particular, showing the
account classes of freshly created and destroyed users will probably help to
notice any weird bursts of activity.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • asadb/groups/load_people.py

    r2538f75 r161ce5f  
    6262            # great, they're still in the dump
    6363            changed = False
     64            changes = []
    6465            dcm_person = dcm_people[django_person.username]
    6566            del dcm_people[django_person.username]
     67
     68            # Check for changes: first fields, then deletions
    6669            for key in fields:
    6770                if django_person.__dict__[key] != dcm_person[key]:
    6871                    changed = True
     72                    if key == 'mit_id':
     73                        changes.append((key, '[redacted]', '[redacted]', ))
     74                    else:
     75                        changes.append((key, django_person.__dict__[key], dcm_person[key]))
    6976                    if mutable:
    7077                        django_person.__dict__[key] = dcm_person[key]
     
    7481                    django_person.del_date = None
    7582                    stat_undel += 1
    76                     stat_people['undel'].append(django_person.username)
     83                    changes.append(('[account]', '[deleted]', '[undeleted]', ))
     84                    stat_people['undel'].append((django_person.username, changes))
     85
    7786            if changed:
     87                stat_name = ''
    7888                if mutable:
    7989                    django_person.mod_date = datetime.date.today()
    8090                    django_person.save()
    8191                    stat_changed += 1
    82                     stat_people['changed'].append(django_person.username)
     92                    stat_name = 'changed'
    8393                else:
    8494                    stat_mut_ign += 1
    85                     stat_people['mut_ign'].append(django_person.username)
     95                    stat_name = 'mut_ign'
     96                stat_people[stat_name].append((django_person.username, changes))
    8697            else:
    8798                stat_unchanged += 1
     99
    88100        else:
     101            # They're not in the dump
    89102            if django_person.del_date is None:
     103                stat_name = ''
    90104                if mutable:
    91105                    django_person.del_date = datetime.date.today()
    92106                    stat_del += 1
    93                     stat_people['del'].append(django_person.username)
     107                    stat_name = 'del'
    94108                    django_person.save()
    95109                else:
    96110                    stat_mut_ign += 1
    97                     stat_people['mut_ign'].append(django_person.username)
     111                    stat_name = 'mut_ign'
     112                changes = [('account_class', django_person.account_class, '[deleted]')]
     113                stat_people[stat_name].append((django_person.username, changes))
    98114            else:
    99115                stat_pre_del += 1
     116
     117    transaction.commit()
     118
     119    # Import new people from the DCM
    100120    for username, dcm_person in dcm_people.items():
    101121        stat_loops += 1
     
    108128        django_person.add_date = datetime.date.today()
    109129        stat_add += 1
    110         stat_people['add'].append(django_person.username)
     130        changes = [('account_class', '[missing]', dcm_person['account_class'], )]
     131        stat_people['add'].append((django_person.username, changes))
    111132        django_person.save()
    112133    transaction.commit()
     134
    113135    stats = {
    114136        'loops': stat_loops,
     
    147169
    148170    for change_type, people in stat_people.items():
    149         for person in people:
    150             print "%12s\t%s" % (change_type, person, )
     171        for person, changes in people:
     172            print "%12s\t%12s\t%s" % (change_type, person, changes, )
    151173        print ""
Note: See TracChangeset for help on using the changeset viewer.