This commit was manufactured by cvs2svn to create branch
[plcapi.git] / PLC / Persons.py
index 7a2e635..7c1a8fd 100644 (file)
@@ -4,7 +4,7 @@
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id$
+# $Id: Persons.py,v 1.38 2007/08/22 19:54:07 tmack Exp $
 #
 
 from types import StringTypes
@@ -100,8 +100,15 @@ class Person(Row):
         if len(domain) < 2:
             raise invalid_email
 
-        conflicts = Persons(self.api, [email])
-        for person in conflicts:
+               # check only against users on the same peer  
+       if 'peer_id' in self:
+            namespace_peer_id = self['peer_id']
+        else:
+            namespace_peer_id = None
+         
+       conflicts = Persons(self.api, {'email':email,'peer_id':namespace_peer_id}) 
+       
+       for person in conflicts:
             if 'person_id' not in self or self['person_id'] != person['person_id']:
                 raise PLCInvalidArgument, "E-mail address already in use"
 
@@ -210,6 +217,18 @@ class Person(Row):
         self['site_ids'].remove(site_id)
         self['site_ids'].insert(0, site_id)
 
+    def update_last_updated(self, commit = True):
+        """
+        Update last_updated field with current time
+        """
+       
+       assert 'person_id' in self
+       assert self.table_name
+       
+       self.api.db.do("UPDATE %s SET last_updated = CURRENT_TIMESTAMP " % (self.table_name) + \
+                       " where person_id = %d" % (self['person_id']) )
+        self.sync(commit)
+
     def delete(self, commit = True):
         """
         Delete existing user.