Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix #37 -- py3 compatibility
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed May 29, 2015
1 parent cf6fbef commit 30d5333
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion coil/data/templates/jinja/coil_post_edit.tmpl
Expand Up @@ -22,7 +22,7 @@
>
{% for auid, aname in users %}
<option
{% if auid == current_auid %}
{% if int(auid) == int(current_auid) %}
selected
{% endif %}
value="{{ auid }}">{{ aname }}</option>
Expand Down
3 changes: 2 additions & 1 deletion coil/data/templates/jinja/coil_users.tmpl
Expand Up @@ -87,7 +87,8 @@ $('#deleteModal').on('show.bs.modal', function (event) {
{% endfor %}
<tr><form action="{{ url_for('acp_users_edit') }}" method="POST">{{ editform.csrf_token }}
<td class="uid"><strong>Create:</strong></td>
<td colspan="4"><input name="username" placeholder="New user" class="form-control input-sm"></td>
<td colspan="4"><input name="username" placeholder="New user"
class="form-control input-sm"><input type="hidden" name="action" value="new"></td>
<td><button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-plus-square fa-fw"></i> Create</button></td>
</form></tr>
<tr><form action="{{ url_for('acp_users_import') }}" method="POST" enctype="multipart/form-data">{{ importform.csrf_token }}
Expand Down
2 changes: 1 addition & 1 deletion coil/data/templates/mako/coil_post_edit.tmpl
Expand Up @@ -22,7 +22,7 @@
>
% for auid, aname in users:
<option
%if auid == current_auid:
%if int(auid) == int(current_auid):
selected
% endif
value="${auid}">${aname}</option>
Expand Down
2 changes: 1 addition & 1 deletion coil/tasks.py
Expand Up @@ -59,7 +59,7 @@ def build(dburl, sitedir, mode):
out = []

while p.poll() is None:
nl = p.stderr.readline()
nl = p.stderr.readline().decode('utf-8')
for k in milestones:
if k in nl:
milestones[k] = 1
Expand Down
32 changes: 17 additions & 15 deletions coil/web.py
Expand Up @@ -253,7 +253,7 @@ def generate_menu():
needs_rebuild = db.get('site:needs_rebuild')
else:
needs_rebuild = site.coil_needs_rebuild
if needs_rebuild not in ('0', '-1'):
if needs_rebuild not in (u'0', u'-1', b'0', b'-1'):
return ('</li><li><a href="{0}"><i class="fa fa-fw '
'fa-warning"></i> <strong>Rebuild</strong></a></li>'.format(
url_for('rebuild')))
Expand Down Expand Up @@ -671,7 +671,7 @@ def edit(path):
meta['author'] = get_user(meta['author.uid']).realname
current_auid = int(meta['author.uid'])
author_change_success = True
except:
except Exception:
author_change_success = False
if (not current_user.can_transfer_post_authorship or
not author_change_success):
Expand Down Expand Up @@ -711,10 +711,11 @@ def edit(path):
if db is not None:
uids = db.hgetall('users').values()
for u in uids:
u = u.decode('utf-8')
realname, active = db.hmget('user:{0}'.format(u),
'realname', 'active')
if active == '1':
users.append((u, realname))
if active in (u'1', b'1'):
users.append((u, realname.decode('utf-8')))
else:
for u, d in app.config['COIL_USERS'].items():
if d['active']:
Expand Down Expand Up @@ -785,6 +786,7 @@ def api_rebuild():
rq.cancel_job('build', db)
rq.cancel_job('orphans', db)
db.set('site:needs_rebuild', '0')
site.coil_needs_rebuild = '1'

return d

Expand Down Expand Up @@ -1003,17 +1005,17 @@ def acp_users():
if request.args.get('status') == 'undeleted':
alert = 'User undeleted.'
alert_status = 'success'
else:
uids = db.hgetall('users').values()
USERS = sorted([(int(i), get_user(i)) for i in uids], key=operator.itemgetter(0))
return render('coil_users.tmpl',
context={'title': 'Users',
'USERS': USERS,
'alert': alert,
'alert_status': alert_status,
'delform': UserDeleteForm(),
'editform': UserEditForm(),
'importform': UserImportForm()})

uids = db.hgetall('users').values()
USERS = sorted([(int(i), get_user(i)) for i in uids], key=operator.itemgetter(0))
return render('coil_users.tmpl',
context={'title': 'Users',
'USERS': USERS,
'alert': alert,
'alert_status': alert_status,
'delform': UserDeleteForm(),
'editform': UserEditForm(),
'importform': UserImportForm()})


@app.route('/users/edit/', methods=['POST'])
Expand Down

0 comments on commit 30d5333

Please sign in to comment.