Fix management of deletedContributors in sync process
Benjamin Renard

Benjamin Renard commited on 2014-01-31 01:24:26
Showing 1 changed files, with 10 additions and 8 deletions.

... ...
@@ -113,8 +113,8 @@ class Group(object):
113 113
 
114 114
   def restoreContributor(self, email):
115 115
     contributor=Contributor()
116
-    contributor.load(self.deletedContributors[email])
117
-    for uuid in self.deletedContributions:
116
+    contributor.load(self.deletedContributors[email].export())
117
+    for uuid in self.deletedContributions.keys():
118 118
       if self.deletedContributions[uuid].contributor==contributor.email and self.deletedContributions[uuid].lastChange==contributor.deletionTime:
119 119
         self.contributions[uuid]=Contribution()
120 120
         self.contributions[uuid].load(self.deletedContributions[uuid].export())
... ...
@@ -127,9 +127,9 @@ class Group(object):
127 127
 
128 128
   def deleteContributor(self, email, time):
129 129
     contributor=Contributor()
130
-    contributor.load(self.contributors[email])
130
+    contributor.load(self.contributors[email].export())
131 131
     contributor.deletionTime=time
132
-    for uuid in self.contributions:
132
+    for uuid in self.contributions.keys():
133 133
       if self.contributions[uuid].contributor==email:
134 134
         self.deletedContributions[uuid]=Contribution()
135 135
         self.deletedContributions[uuid].load(self.contributions[uuid].export())
... ...
@@ -146,7 +146,7 @@ class Group(object):
146 146
     ret.name=group.name
147 147
 
148 148
     ## Deleted Contributors
149
-    for email in self.deletedContributors:
149
+    for email in self.deletedContributors.keys():
150 150
       if email not in group.deletedContributors:
151 151
         logging.debug('Contributor %s not deleted on the other' % email)
152 152
         lastChange=0
... ...
@@ -164,7 +164,7 @@ class Group(object):
164 164
           group.deleteContributor(email,self.deletedContributors[email].deletionTime)
165 165
       ret.deletedContributors[email]=self.deletedContributors[email]
166 166
 
167
-    for email in group.deletedContributors:
167
+    for email in group.deletedContributors.keys():
168 168
       if email not in ret.deletedContributors:
169 169
         logging.debug('Contributor %s not deleted on me' % email)
170 170
         lastChange=0
... ...
@@ -183,9 +183,11 @@ class Group(object):
183 183
       ret.deletedContributors[email]=group.deletedContributors[email]
184 184
 
185 185
     ## Contributors
186
-    ret.contributors=self.contributors
186
+    for email in self.contributors:
187
+      if email not in ret.deletedContributors:
188
+        ret.contributors[email]=self.contributors[email]
187 189
     for email in group.contributors:
188
-      if email not in ret.contributors:
190
+      if email not in ret.contributors and email not in ret.deletedContributors:
189 191
         ret.contributors[email]=group.contributors[email]
190 192
 
191 193
     ## Deleted Contributions
192 194