mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-07 09:01:38 -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)
|
self.bb = bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
||||||
l.addRow(bb)
|
l.addRow(bb)
|
||||||
bb.accepted.connect(self.accept), bb.rejected.connect(self.reject)
|
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):
|
def show_password(self):
|
||||||
for p in self.p1, self.p2:
|
for p in self.p1, self.p2:
|
||||||
@ -317,7 +318,7 @@ class NewUser(QDialog):
|
|||||||
return self.p1.text()
|
return self.p1.text()
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
if self.uw.isEditable():
|
if not self.uw.isReadOnly():
|
||||||
un = self.username
|
un = self.username
|
||||||
if not un:
|
if not un:
|
||||||
return error_dialog(self, _('Empty username'), _('You must enter a username'), show=True)
|
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):
|
def user_data(self, users):
|
||||||
with self.lock, self.conn:
|
with self.lock, self.conn:
|
||||||
c = self.conn.cursor()
|
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():
|
for name, data in users.iteritems():
|
||||||
res = serialize_restriction(data['restriction'])
|
res = serialize_restriction(data['restriction'])
|
||||||
r = 'y' if data['readonly'] else 'n'
|
r = 'y' if data['readonly'] else 'n'
|
||||||
c.execute('UPDATE users SET (pw, restriction, readonly) VALUES (?,?,?) WHERE name=?',
|
c.execute('UPDATE users SET pw=?, restriction=?, readonly=? WHERE name=?',
|
||||||
data['pw'], res, r, name)
|
(data['pw'], res, r, name))
|
||||||
if self.conn.changes() > 0:
|
if self.conn.changes() > 0:
|
||||||
continue
|
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()
|
self.refresh()
|
||||||
|
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user