mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
More work on GUI for user management
This commit is contained in:
parent
1b3d29e7f8
commit
6907bb3d50
@ -303,6 +303,7 @@ class NewUser(QDialog):
|
||||
self.bb = bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
||||
l.addRow(bb)
|
||||
bb.accepted.connect(self.accept), bb.rejected.connect(self.reject)
|
||||
(self.uw if not username else self.p1).setFocus(Qt.OtherFocusReason)
|
||||
|
||||
def show_password(self):
|
||||
for p in self.p1, self.p2:
|
||||
@ -317,7 +318,7 @@ class NewUser(QDialog):
|
||||
return self.p1.text()
|
||||
|
||||
def accept(self):
|
||||
if self.uw.isEditable():
|
||||
if not self.uw.isReadOnly():
|
||||
un = self.username
|
||||
if not un:
|
||||
return error_dialog(self, _('Empty username'), _('You must enter a username'), show=True)
|
||||
|
@ -168,14 +168,18 @@ class UserManager(object):
|
||||
def user_data(self, users):
|
||||
with self.lock, self.conn:
|
||||
c = self.conn.cursor()
|
||||
remove = self.all_user_names - set(users)
|
||||
if remove:
|
||||
c.executemany('DELETE FROM users WHERE name=?', (remove,))
|
||||
for name, data in users.iteritems():
|
||||
res = serialize_restriction(data['restriction'])
|
||||
r = 'y' if data['readonly'] else 'n'
|
||||
c.execute('UPDATE users SET (pw, restriction, readonly) VALUES (?,?,?) WHERE name=?',
|
||||
data['pw'], res, r, name)
|
||||
c.execute('UPDATE users SET pw=?, restriction=?, readonly=? WHERE name=?',
|
||||
(data['pw'], res, r, name))
|
||||
if self.conn.changes() > 0:
|
||||
continue
|
||||
c.execute('INSERT INTO USERS (name, pw, restriction, readonly)', name, data['pw'], res, r)
|
||||
c.execute('INSERT INTO USERS (name, pw, restriction, readonly) VALUES (?, ?, ?, ?)',
|
||||
(name, data['pw'], res, r))
|
||||
self.refresh()
|
||||
|
||||
def refresh(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user