Commits

Chris Jones committed ed989f8

Fixed bug in ttl. Doing int(<var) on an empty variable casts the var to 0. Added a check so that it doesnt set the key to expire right away. Also updated js to forward to the right page for sorted sets.

Comments (0)

Files changed (3)

     member_name = TextField('Member', validators=[Required()])
     member_value = TextField('Value', validators=[Required()])
 
-class ZSetForm(StringForm):
+class ZSetForm(ListSetForm):
     """
     Form for creating a ZSet
     """
     form = ZSetForm(request.form or None)
     if form.validate_on_submit():
         key = request.form['key_name']
-        value = request.form['key_value']
+        member = request.form['member']
         key_ttl = request.form['key_ttl']
         score = request.form['score']
 
         if not r:
             return redirect(url_for('setup'))
 
-        r.zadd(key, value, score)
+        r.zadd(key, member, score)
 
         try:
             key_ttl = int(key_ttl)
-            r.expire(key, key_ttl)
+            if key_ttl > 0:
+                r.expire(key, key_ttl)
         except ValueError:
             pass
 

static/js/redbeard.js

                 },
                 'Sorted Set': {
                     'action': function() {
+                        window.location = '/key/new/zset';
                     }
                 }
             }

templates/new_zset.html

 {% block leftblock %}
 <article>
 	<header>
-		<h1>Add New ZSet</h1>
+		<h1>Add New Sorted Set</h1>
 	</header>
 	{% from "_partials.html" import render_field %}
 	<form action="{{ url_for('new_zset') }}" method="post" id="new_key_form">
 		{{ form.csrf }}
 		{{ render_field(form.key_name) }}
-		{{ render_field(form.key_value) }}
+		{{ render_field(form.member) }}
 		{{ render_field(form.score) }}
 		{{ render_field(form.key_ttl, type="number", class="optional") }}
 		<a href="{{ url_for('index') }}" id="cancel">cancel</a>