mango r223 - in branches/django: . mango www
- From: ovitters svn gnome org
- To: svn-commits-list gnome org,gnome-sysadmin gnome org
- Subject: mango r223 - in branches/django: . mango www
- Date: Sun, 22 Jun 2008 17:23:38 +0000 (UTC)
Author: ovitters
Date: Sun Jun 22 17:23:38 2008
New Revision: 223
URL: http://svn.gnome.org/viewvc/mango?rev=223&view=rev
Log:
* mango/models.py (AccountRequest, AccountRequest.ault,
AccountRequest.ault, AccountRequest.ault, AccountGroups.ault,
Ftpmirrors, Ftpmirrors.Meta, Ftpmirrors.add_to_xml, FtpmirrorsForm,
FtpmirrorsForm.Meta, Webmirrors): Prevent some fields in various
models from being editable. Further, add an FtpmirrorsForm, based
upon Ftpmirrors model. Lastly, add an add_to_xml helper function to
the Ftpmirrors model.
* mango/urls.py: Add new edit ftpmirror view.
* mango/views.py (list_mirrors, edit_mirror): Create new view which
allows an ftpmirror to be updated. Make list_mirrors view use
add_to_xml helper function.
* www/list_ftpmirrors.xsl: Update the link used to edit an ftpmirror.
* www/update_ftpmirror.xsl: Add link back to list_mirrors view. Also
make sure the POST goes to the right place.
Modified:
branches/django/ (props changed)
branches/django/ChangeLog
branches/django/mango/models.py
branches/django/mango/urls.py
branches/django/mango/views.py
branches/django/www/list_ftpmirrors.xsl
branches/django/www/update_ftpmirror.xsl
Modified: branches/django/mango/models.py
==============================================================================
--- branches/django/mango/models.py (original)
+++ branches/django/mango/models.py Sun Jun 22 17:23:38 2008
@@ -9,6 +9,7 @@
from django.db import models
from django.conf import settings
+from django.newforms import ModelForm
import ldap
class AccountRequest(models.Model):
@@ -17,12 +18,12 @@
cn = models.CharField(max_length=255)
mail = models.EmailField(max_length=255)
comment = models.TextField()
- timestamp = models.DateTimeField()
+ timestamp = models.DateTimeField(editable=False)
authorizationkeys = models.TextField()
- status = models.CharField(max_length=1, default='P')
- is_new_account = models.CharField(max_length=1, default='Y')
- is_mail_verified = models.CharField(max_length=1, default='N')
- mail_token = models.CharField(max_length=40)
+ status = models.CharField(max_length=1, default='P', editable=False)
+ is_new_account = models.CharField(max_length=1, default='Y', editable=False)
+ is_mail_verified = models.CharField(max_length=1, default='N', editable=False)
+ mail_token = models.CharField(max_length=40, editable=False)
class Meta:
db_table = u'account_request'
@@ -31,7 +32,7 @@
request = models.ForeignKey(AccountRequest)
cn = models.CharField(max_length=15)
voucher_group = models.CharField(max_length=50, blank=True, null=True)
- verdict = models.CharField(max_length=1, default='P')
+ verdict = models.CharField(max_length=1, default='P', editable=False)
voucher = models.CharField(max_length=15, blank=True, null=True)
denial_message = models.CharField(max_length=255, blank=True, null=True)
class Meta:
@@ -51,18 +52,32 @@
db_table = u'foundationmembers'
class Ftpmirrors(models.Model):
+ id = models.AutoField(primary_key=True)
name = models.CharField(max_length=60, blank=True)
url = models.CharField(max_length=300, blank=True)
location = models.CharField(max_length=72, blank=True)
email = models.CharField(max_length=120, blank=True)
comments = models.TextField(blank=True)
description = models.TextField(blank=True)
- id = models.IntegerField(primary_key=True)
active = models.IntegerField(null=True, blank=True)
- last_update = models.DateTimeField()
+ last_update = models.DateTimeField(blank=True)
class Meta:
db_table = u'ftpmirrors'
+ def add_to_xml(self, ET, node):
+ fields = ('id', 'name', 'url', 'location', 'email', 'description', 'comments', 'last_update')
+ for field in fields:
+ n = ET.SubElement(node, field)
+ val = getattr(self, field)
+ if val is None: val = ''
+ n.text = unicode(val)
+ if self.active:
+ n = ET.SubElement(node, 'active')
+
+class FtpmirrorsForm(ModelForm):
+ class Meta:
+ model = Ftpmirrors
+
class Webmirrors(models.Model):
name = models.CharField(max_length=60, blank=True)
url = models.CharField(max_length=300, blank=True)
Modified: branches/django/mango/urls.py
==============================================================================
--- branches/django/mango/urls.py (original)
+++ branches/django/mango/urls.py Sun Jun 22 17:23:38 2008
@@ -1,6 +1,6 @@
from django.conf.urls.defaults import *
-from mango.views import current_datetime, list_users, test_index, list_accounts, edit_user, list_mirrors
+from mango.views import current_datetime, list_users, test_index, list_accounts, edit_user, list_mirrors, edit_mirror
import mango.settings
urlpatterns = patterns('',
@@ -9,6 +9,7 @@
(r'^%stest/$' % mango.settings.SITE_ROOT, test_index),
(r'^%saccounts/$' % mango.settings.SITE_ROOT, list_accounts),
(r'^%smirrors/$' % mango.settings.SITE_ROOT, list_mirrors),
+ (r'^%smirrors/edit/(?P<pk>\d+)/$' % mango.settings.SITE_ROOT, edit_mirror),
(r'^%susers/edit/(?P<user>\w+)/$' % mango.settings.SITE_ROOT, edit_user),
# Example:
# (r'^mango/', include('mango.foo.urls')),
Modified: branches/django/mango/views.py
==============================================================================
--- branches/django/mango/views.py (original)
+++ branches/django/mango/views.py Sun Jun 22 17:23:38 2008
@@ -142,13 +142,26 @@
for mirror in mirrors:
ftpnode = ET.SubElement(ftpnodes, 'ftpmirror')
- fields = ('id', 'name', 'url', 'location', 'email', 'description', 'comments', 'last_update')
- for field in fields:
- node = ET.SubElement(ftpnode, field)
- node.text = unicode(getattr(mirror, field))
- if mirror.active:
- node = ET.SubElement(ftpnode, 'active')
+ mirror.add_to_xml(ET, ftpnode)
return get_xmlresponse(doc, "list_ftpmirrors.xsl")
+def edit_mirror(request, pk):
+ doc, root = get_xmldoc('Update mirror', request)
+ el = ET.SubElement(root, 'updateftpmirror')
+
+ try:
+ mirror = models.Ftpmirrors.objects.get(pk=pk)
+ except mango.models.DoesNotExist:
+ raise Http404()
+
+ if request.method == 'POST':
+ f = models.FtpmirrorsForm(request.POST, instance=mirror)
+ f.save()
+
+ mirror.add_to_xml(ET, el)
+
+ return get_xmlresponse(doc, "update_ftpmirror.xsl")
+
+
Modified: branches/django/www/list_ftpmirrors.xsl
==============================================================================
--- branches/django/www/list_ftpmirrors.xsl (original)
+++ branches/django/www/list_ftpmirrors.xsl Sun Jun 22 17:23:38 2008
@@ -61,7 +61,7 @@
</xsl:choose>
</xsl:attribute>
<td>
- <a href="update_ftpmirror.php?id={id}">
+ <a href="edit/{id}/">
<xsl:apply-templates select="name"/>
</a>
</td>
Modified: branches/django/www/update_ftpmirror.xsl
==============================================================================
--- branches/django/www/update_ftpmirror.xsl (original)
+++ branches/django/www/update_ftpmirror.xsl Sun Jun 22 17:23:38 2008
@@ -10,12 +10,13 @@
<xsl:variable name="script" select="'update_ftpmirror.php'"/>
<xsl:template match="updateftpmirror">
+ <a href="../..">Mirrors</a> â <xsl:value-of select="id"/>
<xsl:apply-templates select="error"/>
<xsl:if test="boolean(updated)">
<p>FTP mirror updated.</p>
<xsl:apply-templates select="updated/change"/>
</xsl:if>
- <form enctype="multipart/form-data" method="POST" action="{$script}" name="form">
+ <form enctype="multipart/form-data" method="POST" action="." name="form">
<input type="hidden" name="mango_token" value="{/page/@token}"/>
<input type="hidden" name="idcheck" value="{id}"/>
<table class="form">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]