[cpif] r405 - in trunk: backend frontend-web frontend-web/skins/default

svn at argo.es svn at argo.es
Fri Oct 19 06:50:16 CEST 2007


Author: jcea
Date: Fri Oct 19 06:50:12 2007
New Revision: 405

Log:
Los usuarios pueden visualizar y cambiar su zona horaria.



Modified:
   trunk/backend/database.py
   trunk/backend/upgrade.py
   trunk/frontend-web/globales.py
   trunk/frontend-web/skins/default/profile.html
   trunk/frontend-web/url_perfil_POST.py

Modified: trunk/backend/database.py
==============================================================================
--- trunk/backend/database.py	(original)
+++ trunk/backend/database.py	Fri Oct 19 06:50:12 2007
@@ -1,7 +1,7 @@
 # $Id$
 
 
-VERSION_DB="2007101801"
+VERSION_DB="2007101901"
 
 import globales
 
@@ -274,7 +274,7 @@
 
   usuario["avatar"]=name
 
-def usuario_update(conn,nick,clave=None,OpenIDs=None) :
+def usuario_update(conn,nick,clave=None,OpenIDs=None,TZ=None) :
   root=conn.get_root()
   usuarios=root["usuarios"]["usuarios"]
 
@@ -289,6 +289,9 @@
     if old_OpenIDs!=OpenIDs : # Solo grabamos si ha habido cambios
       old_OpenIDs.clear() # Este tipo es persistente, asi que lo reutilizamos
       old_OpenIDs.update(OpenIDs)
+
+  if (TZ!=None) and (TZ!=usuario["tz"]) :
+    usuario["tz"]=TZ
 
 def usuario_ask_new_email(conn,nick,email) :
   nick_normalizado=normaliza_nick(nick)

Modified: trunk/backend/upgrade.py
==============================================================================
--- trunk/backend/upgrade.py	(original)
+++ trunk/backend/upgrade.py	Fri Oct 19 06:50:12 2007
@@ -487,3 +487,12 @@
 
     conn.commit()
 
+  if root["version del foro"]=="2007101801" :
+    print "Actualizando la base de datos: 2007101801 -> 2007101901"
+    root["version del foro"]="2007101901"
+
+    for usuario in root["usuarios"]["usuarios"].values() :
+      usuario["tz"]=usuario["tz"].zone
+
+    conn.commit()
+

Modified: trunk/frontend-web/globales.py
==============================================================================
--- trunk/frontend-web/globales.py	(original)
+++ trunk/frontend-web/globales.py	Fri Oct 19 06:50:12 2007
@@ -12,6 +12,6 @@
 # Global version of the program
 version=None
 
-# Global TimeZone
-import pytz
-tz=pytz.timezone("Europe/Madrid")
+# Default TimeZone
+tz="Europe/Madrid"
+

Modified: trunk/frontend-web/skins/default/profile.html
==============================================================================
--- trunk/frontend-web/skins/default/profile.html	(original)
+++ trunk/frontend-web/skins/default/profile.html	Fri Oct 19 06:50:12 2007
@@ -4,13 +4,13 @@
 <tr><td>Clave nueva:</td><td><input type="password" name="clave1" size="25" value="" /></td></tr>
 <tr><td>Confirma clave nueva:</td><td><input type="password" name="clave2" size="25" value="" /></td></tr>
 <tr><td>Correo electr&oacute;nico:</td><td>%(profile email)s</td></tr>
-<tr><td>Nueva direcci&oacute;n de<br/>correo electr&oacute;nico:</td><td><input type="text" name="new_email" size=30 value="" /> </td></tr>
+<tr><td>Nueva direcci&oacute;n de<br/>correo electr&oacute;nico:</td><td><input type="text" name="new_email" size=30 value="" /></td></tr>
 <tr><td>Servidores OpenID:</td><td><input type="text" name="OpenID1" size=55 value="%(profile openid1)s" /></td></tr>
 <tr><td align=right>(opcionales)</td><td><input type="text" name="OpenID2" size=55 value="%(profile openid2)s" /></td></tr>
 <tr><td align=right>(opcionales)</td><td><input type="text" name="OpenID3" size=55 value="%(profile openid3)s" /></td></tr>
 <tr><td align=right>(opcionales)</td><td><input type="text" name="OpenID4" size=55 value="%(profile openid4)s" /></td></tr>
 <tr><td align=right>(opcionales)</td><td><input type="text" name="OpenID5" size=55 value="%(profile openid5)s" /></td></tr>
-<tr><td align=right>Zona Horaria:</td><td>%(TZ)s</td></tr>
+<tr><td>Zona Horaria [<a href="http://www.timezoneconverter.com/">?</a>]:</td><td><input type="text" name="TZ" size=30 value="%(TZ)s" /></td></tr>
 <tr><td>Nuevo avatar:</td><td><input type="file" name="avatar" size=45 value="" /></td></tr>
 <tr><td>%(profile avatar)s</td></tr>
 <tr><td colspan=2 align=right><input class="form-element" type="submit" name="submit" value="Cambia perfil"/></td></tr>

Modified: trunk/frontend-web/url_perfil_POST.py
==============================================================================
--- trunk/frontend-web/url_perfil_POST.py	(original)
+++ trunk/frontend-web/url_perfil_POST.py	Fri Oct 19 06:50:12 2007
@@ -26,10 +26,21 @@
   clave1=cuerpo.getfirst("clave1")
   clave2=cuerpo.getfirst("clave2")
   new_email=cuerpo.getfirst("new_email")
+  TZ=cuerpo.getfirst("TZ")
   avatar=cuerpo.getfirst("avatar")
-  if clave1==None or clave2==None or new_email==None or avatar==None: # Comprobamos el caso de campos inexistentes
+
+  # Comprobamos el caso de campos inexistentes
+  if clave1==None or clave2==None or new_email==None or avatar==None or TZ==None :
     return None
 
+  import pytz
+  try :
+    pytz.timezone(TZ)  # Comprobamos si esa zona es valida
+  except :
+    pagina.load_url(["error"])
+    pagina.load_dict({"generic_message": "<h1>La zona horaria especificada es inv&aacute;lida</h1>"})
+    return pagina.web()
+   
   clave1=clave1.strip()
   clave2=clave2.strip()
   OpenIDs=set()
@@ -79,7 +90,7 @@
     smtp.enqueue(conn,[new_email],"\r\n".join(texto))
 
 
-  database.usuario_update(conn,usuario_pedido,clave=clave1,OpenIDs=OpenIDs)
+  database.usuario_update(conn,usuario_pedido,clave=clave1,OpenIDs=OpenIDs,TZ=TZ)
 
   pagina.load_dict({"generic_message": "<h1>Cambio de perfil exitoso</h1>"})
   return pagina.web()



More information about the cpif mailing list