Changeset 94f3a39


Ignore:
Timestamp:
Mar 28, 2012, 6:16:55 AM (14 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, space-access, stable, stage
Children:
5680065
Parents:
96ef09f
git-author:
Alex Dehnert <adehnert@…> (03/28/12 06:14:59)
git-committer:
Alex Dehnert <adehnert@…> (03/28/12 06:16:55)
Message:

Come closer to handling shared storage

Location:
asadb/space
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • asadb/space/diffs.py

    r57a2ad6 r94f3a39  
    144144        new_data = the_space.build_access(time=new_time)
    145145        all_spaces[the_space.pk] = the_space
    146         init_groups(group_data, old_data[1])
    147         init_groups(group_data, new_data[1])
     146        init_groups(group_data, old_data[2])
     147        init_groups(group_data, new_data[2])
    148148        for group_pk, group in group_data.items():
    149149            if group_pk in old_data[0] or group_pk in new_data[0]:
  • asadb/space/models.py

    r9dfb3d5 r94f3a39  
    4242                Usually, the sets will each have one member, but ID 999999999 is decently likely to have several.
    4343                The SpaceAccessListEntrys will be filtered to reflect assignments as of that time.
     44            access_by_id:
     45                ID -> (Name -> (Set Group.pk))
     46                Indicates who has access. Grouped by ID number and name.
     47                Usually, each ID dict will have one member, but ID 999999999 is, again, likely to have several.
     48                This is intended for rooms that have one access list (e.g., W20-437 and W20-441)
    4449            assignments:
    4550                [SpaceAssignment]
     
    6570            aces = aces.filter(group=group)
    6671        access = {}    # Group.pk -> (ID -> Set name)
     72        access_by_id = {} # ID -> (Name -> (Set Group.pk))
    6773        for assignment in assignments:
    6874            if assignment.group.pk not in access:
     
    7177            if ace.group.pk in access:
    7278                access[ace.group.pk][ace.card_number].add(ace.name)
     79                if ace.card_number not in access_by_id:
     80                    access_by_id[ace.card_number] = collections.defaultdict(set)
     81                access_by_id[ace.card_number][ace.name].add(ace.group.pk)
    7382            else:
    7483                # This group appears to no longer have access...
    7584                errors.append("Group %s no longer has access to %s, but has live ACEs." % (ace.group, self, ))
    76         return access, assignments, aces, errors
     85        return access, access_by_id, assignments, aces, errors
    7786
    7887reversion.register(Space)
Note: See TracChangeset for help on using the changeset viewer.