[ckan-changes] commit/ckan: zephod: [ux,user/edit][l]: Fixed the user edit form; stripped preview functionality from front- and back-end.

Bitbucket commits-noreply at bitbucket.org
Sat Sep 24 14:28:42 UTC 2011


1 new changeset in ckan:

http://bitbucket.org/okfn/ckan/changeset/351f35255709/
changeset:   351f35255709
branch:      temp-deployment-without-solr
user:        zephod
date:        2011-09-20 19:26:03
summary:     [ux,user/edit][l]: Fixed the user edit form; stripped preview functionality from front- and back-end.
affected #:  9 files (-1 bytes)

--- a/ckan/controllers/user.py	Sat Sep 24 15:20:16 2011 +0100
+++ b/ckan/controllers/user.py	Tue Sep 20 18:26:03 2011 +0100
@@ -169,7 +169,6 @@
     def edit(self, id=None, data=None, errors=None, error_summary=None):
         context = {'model': model, 'session': model.Session,
                    'user': c.user or c.author,
-                   'preview': 'preview' in request.params,
                    'save': 'save' in request.params,
                    'schema': self._edit_form_to_db_schema(),
                    }
@@ -180,7 +179,7 @@
                 abort(400, _('No user specified'))
         data_dict = {'id': id}
 
-        if (context['save'] or context['preview']) and not data:
+        if (context['save']) and not data:
             return self._save_edit(id, context)
 
         try:
@@ -223,15 +222,6 @@
             data_dict['id'] = id
             user = get_action('user_update')(context, data_dict)
 
-            if context['preview']:
-                about = request.params.getone('about')
-                c.preview = self._format_about(about)
-                c.user_about = about
-                c.full_name = request.params.get('fullname','')
-                c.email = request.params.getone('email')
-
-                return self.edit(id, data_dict)
-
             h.redirect_to(controller='user', action='read', id=user['id'])
         except NotAuthorized:
             abort(401, _('Unauthorized to edit user %s') % id)


--- a/ckan/logic/action/update.py	Sat Sep 24 15:20:16 2011 +0100
+++ b/ckan/logic/action/update.py	Tue Sep 20 18:26:03 2011 +0100
@@ -339,7 +339,6 @@
 
     model = context['model']
     user = context['user']
-    preview = context.get('preview', False)
     schema = context.get('schema') or default_update_user_schema() 
     id = data_dict['id']
 
@@ -357,11 +356,8 @@
 
     user = user_dict_save(data, context)
     
-    if not preview:
-        model.repo.commit()        
-        return user_dictize(user, context)
-
-    return data
+    model.repo.commit()        
+    return user_dictize(user, context)
 
 ## Modifications for rest api
 


--- a/ckan/public/css/style.css	Sat Sep 24 15:20:16 2011 +0100
+++ b/ckan/public/css/style.css	Tue Sep 20 18:26:03 2011 +0100
@@ -789,6 +789,7 @@
   -moz-border-radius: 5px;
   border: 1px solid #CCC;
   padding: 0 5px 5px 10px;
+  width: 32em;
 }
 
 div.markdown-preview {
@@ -1081,21 +1082,21 @@
 /* = Twitter.Bootstrap Form Buttons = */
 /* ================================== */
 div.form-submit {
-    background: #eee;
-    padding: 20px;
-    margin-bottom: 8px;
-    border: 1px solid #ccc;
-    border-left: none;
-    border-right: none;
-    height: 60px;
+  background: #eee;
+  padding: 20px;
+  margin-bottom: 8px;
+  border: 1px solid #ccc;
+  border-left: none;
+  border-right: none;
 }
-
 div.form-submit p.hints {
-    display: block;
-    width: 50%;
-    float: right;
+  width: 50%;
+  float: right;
+  margin: 0;
 }
-
+div.clear {
+  clear: both;
+}
 
 .pretty-button {
   cursor: pointer;


--- a/ckan/public/scripts/application.js	Sat Sep 24 15:20:16 2011 +0100
+++ b/ckan/public/scripts/application.js	Tue Sep 20 18:26:03 2011 +0100
@@ -23,16 +23,14 @@
       $('#save').val("Add Dataset");
     }
 
+    // Buttons with href-action should navigate when clicked
+    $('input.href-action').click(function(e) {
+      e.preventDefault();
+      window.location = ($(e.target).attr('action'));
+    });
+    
     var isDatasetEdit = $('body.package.edit').length > 0;
     if (isDatasetEdit) {
-      // Set up the cancel button
-      $('input#cancel').show();
-      $('input#cancel').click(function(e) {
-        e.preventDefault();
-        window.location = ($(e.target).attr('action'));
-      });
-
-
       // Selectively enable the upload button
       var storageEnabled = $.inArray('storage',CKAN.plugins)>=0;
       if (storageEnabled) {


--- a/ckan/templates/package/edit_form.html	Sat Sep 24 15:20:16 2011 +0100
+++ b/ckan/templates/package/edit_form.html	Tue Sep 20 18:26:03 2011 +0100
@@ -25,7 +25,6 @@
       </div><div class="submit">
-        <input name="preview" type="submit" value="Preview" />
         ${h.submit('save', _('Save'))}
       </div>
 


--- a/ckan/templates/package/new_package_form.html	Sat Sep 24 15:20:16 2011 +0100
+++ b/ckan/templates/package/new_package_form.html	Tue Sep 20 18:26:03 2011 +0100
@@ -257,14 +257,15 @@
 </div><div class="form-submit">
+  <input id="save" tabindex="99" class="pretty-button primary" name="save" type="submit" value="Save Changes" />
+  <py:if test="c.pkg">
+    <input id="cancel" tabindex="100" class="pretty-button href-action" name="cancel" type="reset" value="Cancel" action="${h.url_for(controller='package', action='read', id=c.pkg.name)}" />
+  </py:if><p class="hints"><strong>Important:</strong> By submitting content, you agree to release your contributions
     under the <a href="http://opendatacommons.org/licenses/odbl/1.0/">Open Database License</a>. Please <strong>refrain</strong> from editing this page if you are <strong>not</strong> happy to do this.
   </p>
-  <input id="save" tabindex="99" class="pretty-button primary" name="save" type="submit" value="Save Changes" />
-  <py:if test="c.pkg">
-    <input id="cancel" tabindex="100" class="pretty-button" name="cancel" type="reset" value="Cancel" action="${h.url_for(controller='package', action='read', id=c.pkg.name)}" />
-  </py:if>
+  <div class="clear"></div></div>
 
 


--- a/ckan/templates/user/edit.html	Sat Sep 24 15:20:16 2011 +0100
+++ b/ckan/templates/user/edit.html	Tue Sep 20 18:26:03 2011 +0100
@@ -9,49 +9,6 @@
   </py:def><div py:match="content">
-    <a href="#preview" py:if="c.preview">(skip to preview)</a>
-
-    <form id="user-edit" action="" method="post" class="simple-form" 
-      xmlns:py="http://genshi.edgewall.org/"
-      xmlns:xi="http://www.w3.org/2001/XInclude"
-      >
-      <fieldset>
-        <legend>Base details</legend>
-        <label for="fullname">Full name:</label>
-        <input name="fullname" value="${c.user_fullname}" /><br/>
-         
-        <label for="email">E-Mail:</label>
-        <input name="email" value="${c.user_email}" /><br/>
-      </fieldset>
-      <fieldset>
-        <legend>Change your password</legend>
-        <label for="password1">Password:</label>
-        <input type="password" name="password1" value="" />
-        <br/>
-        <label for="password2">Password (repeat):</label>
-        <input type="password" name="password2" value="" />
-        <br/>
-      </fieldset>
-      <label for="about">About user:</label>
-      <textarea id="about" rows="5" name="about" cols="60">${c.user_about}</textarea>
-      <p class="small" i18n:msg="">You can use <a href="http://daringfireball.net/projects/markdown/syntax">Markdown formatting</a> here.</p>
-
-      <div>
-        <input name="preview" type="submit" value="Preview" />
-        ${h.submit('save', _('Save'))}
-      </div>
-    </form>
-
-
-    <div id="preview" style="margin-left: 20px;" py:if="c.preview">
-      <hr />
-      <h2>Preview</h2>
-      <h4>Full name: ${c.full_name}</h4>
-      <div style="border: 2px dashed red; padding: 5px;"> 
-        ${c.preview}
-      </div>
-    </div>
-
     ${Markup(c.form)}
   </div>
 


--- a/ckan/templates/user/edit_user_form.html	Sat Sep 24 15:20:16 2011 +0100
+++ b/ckan/templates/user/edit_user_form.html	Tue Sep 20 18:26:03 2011 +0100
@@ -19,6 +19,19 @@
      
     <dt><label for="email">E-Mail:</label></dt><dd><input type="text" name="email" value="${data.get('email','')}" /></dd>
+    
+    <dt><label for="about">About:</label></dt>
+    <dd class="description-field">
+      <div class="markdown-editor">
+        <ul class="tabs">
+          <li><a href="#" action="write" class="selected">Write</a></li>
+          <li><a href="#" action="preview">Preview</a></li>
+        </ul>
+        <textarea class="markdown-input" tabindex="3" name="about" id="about" placeholder="A little about you...">${data.get('about','')}</textarea>
+        <div class="markdown-preview" style="display: none;"></div>
+        <span class="hints">You can use <a href="http://daringfireball.net/projects/markdown/syntax">Markdown formatting</a> here.</span>
+      </div>
+    </dd></dl></fieldset><fieldset>
@@ -30,13 +43,9 @@
     <dd><input type="password" name="password2" value="" /></dd></dl></fieldset>
-  <label for="about">About user:</label>
-  <textarea id="about" rows="5" name="about" cols="60">${data.get('about','')}</textarea>
-  <p class="small" i18n:msg="">You can use <a href="http://daringfireball.net/projects/markdown/syntax">Markdown formatting</a> here.</p>
-
-  <div>
-    <input name="preview" type="submit" value="Preview" />
-    ${h.submit('save', _('Save'))}
+  <div class="form-submit">
+    <input id="save" class="pretty-button primary" name="save" type="submit" value="Save Changes" />
+    <input id="cancel" class="pretty-button href-action" name="cancel" type="reset" value="Cancel" action="${h.url_for(controller='user', action='read')}" /></div></form>
 


--- a/ckan/tests/functional/test_user.py	Sat Sep 24 15:20:16 2011 +0100
+++ b/ckan/tests/functional/test_user.py	Tue Sep 20 18:26:03 2011 +0100
@@ -482,13 +482,6 @@
         fv['about'] = new_about
         fv['password1'] = new_password
         fv['password2'] = new_password
-        res = fv.submit('preview', extra_environ={'REMOTE_USER':username})
-        
-        # preview
-        main_res = self.main_div(res)
-        assert 'Edit User: testedit' in main_res, main_res
-        in_preview = main_res[main_res.find('Preview'):]
-        assert new_about in in_preview, in_preview
 
         # commit
         res = fv.submit('save', extra_environ={'REMOTE_USER':username})      
@@ -533,14 +526,6 @@
         fv['password1'] = ''
         fv['password2'] = ''
 
-        res = fv.submit('preview', extra_environ={'REMOTE_USER':username})
-        
-        # preview
-        main_res = self.main_div(res)
-        assert 'Edit User: testedit2' in main_res, main_res
-        in_preview = main_res[main_res.find('Preview'):]
-        assert new_about in in_preview, in_preview
-
         # commit
         res = fv.submit('save', extra_environ={'REMOTE_USER':username})      
         assert res.status == 302, self.main_div(res).encode('utf8')
@@ -603,7 +588,6 @@
         assert 'Edit User: ' in main_res, main_res
         assert 'Test About <a href="http://spamsite.net">spamsite</a>' in main_res, main_res
         fv = res.forms['user-edit']
-        res = fv.submit('preview', extra_environ={'REMOTE_USER':username})
         # commit
         res = fv.submit('save', extra_environ={'REMOTE_USER':username})      
         assert res.status == 200, res.status

Repository URL: https://bitbucket.org/okfn/ckan/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.




More information about the ckan-changes mailing list