From 17843716e2b14b52524341d00adb5730a1953c14 Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Thu, 5 Aug 2010 09:31:48 +0200 Subject: [PATCH] implement baseParams and display of general errors as a messagebox --- pyweb/djextdirect.py | 13 +++++++++++-- pyweb/mumble/templates/mumble/mumble.html | 4 +--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pyweb/djextdirect.py b/pyweb/djextdirect.py index 2ca0cb4..cf2d0b4 100644 --- a/pyweb/djextdirect.py +++ b/pyweb/djextdirect.py @@ -68,10 +68,18 @@ Ext.ux.%(clsname)s = function( config ){ Ext.extend( Ext.ux.%(clsname)s, Ext.form.FormPanel, { load: function(){ - this.getForm().load({ params: {pk: this.pk} }); + this.getForm().load({ params: Ext.applyIf( {pk: this.pk}, this.baseParams ) }); }, submit: function(){ - this.getForm().submit({ params: {pk: this.pk} }); + this.getForm().submit({ + params: Ext.applyIf( {pk: this.pk}, this.baseParams ), + failure: function( form, action ){ + if( action.failureType == Ext.form.Action.SERVER_INVALID && + typeof action.result.errors[''] != 'undefined' ){ + Ext.Msg.alert( "Error", action.result.errors[''] ); + } + } + }); }, } ); @@ -483,6 +491,7 @@ class Provider( object ): 'fileUpload: ' + simplejson.dumps(hasfiles) + ',' 'defaults: { "anchor": "-20px" },' 'paramsAsHash: true,' + 'baseParams: {},' 'autoScroll: true,' """buttons: [{ text: "Submit", diff --git a/pyweb/mumble/templates/mumble/mumble.html b/pyweb/mumble/templates/mumble/mumble.html index 3fe1d47..fbb601c 100644 --- a/pyweb/mumble/templates/mumble/mumble.html +++ b/pyweb/mumble/templates/mumble/mumble.html @@ -72,9 +72,7 @@ xtype: "{{ RegForm|lower }}", pk: {% if MumbleAccount %}{{ MumbleAccount.id }}{% else %}-1{% endif %}, labelWidth: 150, - submit: function(){ - this.getForm().submit({ params: {serverid: {{MumbleServer.id}}, pk: this.pk } }); - }, + baseParams: {serverid: {{MumbleServer.id}} }, }, {% if MumbleAccount %} {% if IsAdmin %}