Fixed the password change form on the client side, and fixed form handling in the...
authorJoseph Spiros <joseph.spiros@ithinksw.com>
Tue, 22 Mar 2011 19:12:27 +0000 (15:12 -0400)
committerJoseph Spiros <joseph.spiros@ithinksw.com>
Tue, 22 Mar 2011 19:12:27 +0000 (15:12 -0400)
contrib/gilbert/media/gilbert/plugins/auth.js
contrib/gilbert/plugins/auth.py
contrib/gilbert/plugins/models.py

index 6983748..97e1785 100644 (file)
@@ -32,39 +32,44 @@ Gilbert.lib.plugins.auth.Plugin = Ext.extend(Gilbert.lib.plugins.Plugin, {
                                                        for (var item_index in formspec.items) {
                                                                var item = formspec.items[item_index];
                                                                Ext.apply(item, {
-                                                                       plugins: [ Ext.ux.FieldLabeler ],
+                                                                       anchor: '100%',
                                                                });
                                                        }
-                                                       var change_password_window = application.create_window({
-                                                               layout: 'fit',
-                                                               resizable: true,
+                                                       var change_password_form = new Gilbert.lib.ui.DjangoForm(Ext.applyIf({
                                                                title: 'Change password',
+                                                               header: false,
                                                                iconCls: 'icon-key--pencil',
+                                                               bodyStyle: 'padding: 10px;',
+                                                               baseCls: 'x-plain',
+                                                               autoScroll: true,
+                                                               api: {
+                                                                       submit: Gilbert.api.plugins.auth.save_passwd_form,
+                                                               },
+                                                       }, formspec));
+                                                       var change_password_window = application.create_window({
+                                                               layout: 'fit',
+                                                               title: change_password_form.title,
+                                                               iconCls: change_password_form.iconCls,
+                                                               bodyStyle: 'padding: 5px; background: solid;',
                                                                width: 360,
-                                                               height: 100,
-                                                               items: change_password_form = new Ext.FormPanel(Ext.applyIf({
-                                                                       layout: {
-                                                                               type: 'vbox',
-                                                                               align: 'stretch',
-                                                                       },
-                                                                       baseCls: 'x-plain',
-                                                                       bodyStyle: 'padding: 5px;',
-                                                                       frame: true,
-                                                                       buttons: [{
+                                                               height: 240,
+                                                               maximizable: false,
+                                                               items: [change_password_form],
+                                                               bbar: [
+                                                                       '->',
+                                                                       {
                                                                                text: 'Change password',
                                                                                iconCls: 'icon-key--pencil',
                                                                                handler: function(button, event) {
                                                                                        change_password_form.getForm().submit({
                                                                                                success: function(form, action) {
                                                                                                        Ext.MessageBox.alert('Password changed', 'Your password has been changed.');
+                                                                                                       change_password_window.close();
                                                                                                },
                                                                                        });
                                                                                },
-                                                                       }],
-                                                                       api: {
-                                                                               submit: Gilbert.api.plugins.auth.save_passwd_form,
-                                                                       },
-                                                               }, formspec))
+                                                                       }
+                                                               ],
                                                        });
                                                        change_password_window.doLayout();
                                                        change_password_window.show(button.el);
index 0daaf85..66cfebc 100644 (file)
@@ -40,10 +40,10 @@ class Auth(Plugin):
        @ext_method(form_handler=True)
        def save_passwd_form(self, request):
                form = PasswordChangeForm(request.user, data=request.POST)
-               try:
+               if form.is_valid():
                        form.save()
                        return True, None
-               except:
+               else:
                        return False, form.errors
        
        @ext_method
index b765482..5217df3 100644 (file)
@@ -215,10 +215,10 @@ class ModelAdmin(Plugin):
                
                form = self.form_class(request.POST, request.FILES, instance=instance)
                
-               try:
+               if form.is_valid():
                        saved = form.save()
                        return True, None, saved.pk
-               except ValueError:
+               else:
                        return False, form.errors
        
        def data_serialize_object(self, obj):