mango r235 - in branches/django: . mango www



Author: ovitters
Date: Sun Jun 22 22:29:42 2008
New Revision: 235
URL: http://svn.gnome.org/viewvc/mango?rev=235&view=rev

Log:
	* mango/views.py (add_form_errors_to_xml, edit_mirror): Add new
	function which checks if the form is valid. If not, it adds the errors
	to the XML. Needs to be renamed to better clarify what it does. In
	edit_mirror, make use of this helper function.
	* www/list_ftpmirrors.xsl: Update link to new ftp mirror to follow
	Django style.


Modified:
   branches/django/   (props changed)
   branches/django/ChangeLog
   branches/django/mango/views.py
   branches/django/www/list_ftpmirrors.xsl

Modified: branches/django/mango/views.py
==============================================================================
--- branches/django/mango/views.py	(original)
+++ branches/django/mango/views.py	Sun Jun 22 22:29:42 2008
@@ -64,6 +64,16 @@
     node = ET.SubElement(pagednode, 'page_num')
     node.text = unicode(page.number)
 
+def add_form_errors_to_xml(root, form):
+    """Adds form errors to the XML node specified by root"""
+
+    valid = form.is_valid()
+    if not valid:
+        for field, errors in form.errors.items():
+            node = ET.SubElement(root, 'formerror', {'type': field})
+
+    return valid
+
 def current_datetime(request):
     now = datetime.datetime.now()
     html = "<html><body>It is now %s.</body></html>" % now
@@ -202,7 +212,8 @@
 
     if request.method == 'POST':
         f = models.FtpmirrorsForm(request.POST, instance=mirror)
-        f.save()
+        if add_form_errors_to_xml(el, f):
+            f.save()
 
     mirror.add_to_xml(ET, el)
 

Modified: branches/django/www/list_ftpmirrors.xsl
==============================================================================
--- branches/django/www/list_ftpmirrors.xsl	(original)
+++ branches/django/www/list_ftpmirrors.xsl	Sun Jun 22 22:29:42 2008
@@ -22,7 +22,7 @@
        </noscript>
       </td>
       <td align="center">
-       <a class="button" href="new_ftpmirror.php?reload=true">New FTP mirror</a>
+      <a class="button" href="add/">New FTP mirror</a>
       </td>
       <td align="right">
        <xsl:if test="boolean(ftpmirror)">



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]