# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: sgallagh@fedoraproject.org-20100419205648-\
#   3dk1bybf81j8hho3
# target_branch: bzr://bzr.fedorahosted.org/bzr/python-fedora/python-\
#   fedora-devel/
# testament_sha1: 60093b7f5710c3234061f0bf5991f5ae0604e748
# timestamp: 2010-04-19 16:56:57 -0400
# base_revision_id: toshio@fedoraproject.org-20100408181520-\
#   7mzxred8mrovqu9m
# 
# Begin patch
=== modified file 'fedora/django/auth/models.py'
--- fedora/django/auth/models.py	2010-03-15 23:22:05 +0000
+++ fedora/django/auth/models.py	2010-04-19 20:56:48 +0000
@@ -83,9 +83,29 @@
         if getattr(settings, 'FAS_GENERICEMAIL', True):
             u.email = u._get_email()
         u.save()
+        known_groups = []
+        for group in u.groups.values():
+            known_groups.append(group['id'])
+
+        fas_groups = []
         for group in user['approved_memberships']:
-            g = _new_group(group)
-            u.groups.add(g)
+            fas_groups.append(group['id'])
+
+        # This user has been added to one or more FAS groups
+        for group in (g for g in user['approved_memberships'] if g['id'] not in known_groups):
+            newgroup = _new_group(group)
+            u.groups.add(newgroup)
+
+        # This user has been removed from one or more FAS groups
+        for id in known_groups:
+            found = False
+            for g in user['approved_memberships']:
+                if g['id'] == id:
+                    found = True
+                    break
+            if not found:
+                u.groups.remove(authmodels.Group.objects.get(id=id))
+
         u.save()
         return u
 

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWdShxTgABNJ/gAVUQABZ4///
d8IOCr////BgCA8t8PvYUAGNrZWm2qlVRsNDRNQIyaGgyaHqAAAAAAAIJRtR6npNqBo0GIaBoDQG
mg0YjQc0xMmTRhMExNMAmAQwRgRgEUSU09Jqep7Rqh+k9JHkNTCbU0GjTBNqaACKSaaSp7ZKfkNF
T2o8qbaMqZ4lP1INGTRgR6gRSCAJkCaam01JPMIKeUe0UNAeoMajREA8KZiOCkdGFZPGXDv0jDaz
PQDQI4JCKbzhTjVgbI+EGEFUf75f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