Fix broken User link name (it was possible to change link name to one that was already used, validation was not working correctly).
authorPawel Solyga <Pawel.Solyga@gmail.com>
Tue, 11 Nov 2008 19:49:00 +0000
changeset 473 d01d5e3b0b5c
parent 472 519c298a4f87
child 474 0bf5af57cef9
Fix broken User link name (it was possible to change link name to one that was already used, validation was not working correctly). Patch by: Pawel Solyga
app/soc/views/models/user.py
app/soc/views/user/profile.py
--- a/app/soc/views/models/user.py	Tue Nov 11 01:02:56 2008 +0000
+++ b/app/soc/views/models/user.py	Tue Nov 11 19:49:00 2008 +0000
@@ -68,7 +68,7 @@
     properties = {'link_name': link_name}
     user = soc.logic.models.user.logic.getForFields(properties, unique=True)
 
-    if user and user.link_name != link_name:
+    if user and user.link_name == link_name:
       raise forms.ValidationError("This link name is already in use.")
 
     return link_name
--- a/app/soc/views/user/profile.py	Tue Nov 11 01:02:56 2008 +0000
+++ b/app/soc/views/user/profile.py	Tue Nov 11 19:49:00 2008 +0000
@@ -62,7 +62,7 @@
 
     user = id_user.getUserFromLinkName(link_name)
 
-    if user and not id_user.doesLinkNameBelongToId(link_name, user.id):
+    if user:
       raise forms.ValidationError("This link name is already in use.")
 
     return link_name