add rename ability to user model

pull/28/head
nate 2018-02-23 14:31:43 -08:00
parent 7da85faeed
commit f7bbdf3f0f
1 changed files with 14 additions and 2 deletions

View File

@ -152,13 +152,25 @@ class Townie(User):
return content
def rename_on_disk(self, old_username):
"""Assuming that this instance has a new name set, renames this user on
disk with self.username."""
error = _guarded_run([
'sudo',
'/tilde/bin/rename_user.py',
old_username,
self.username])
if error:
logging.error(error)
return
logging.info('Renamed {} to {}'.format(old_username, self.username))
class Pubkey(Model):
key_type = CharField(max_length=50,
blank=False,
null=False,
choices=SSH_TYPE_CHOICES,
)
choices=SSH_TYPE_CHOICES)
key = TextField(blank=False, null=False)
townie = ForeignKey(Townie)