handle renaming in pre_save

I chose pre_save so that if renaming fails, the db and disk remain consistent.
pull/28/head
nate 2018-02-23 14:31:58 -08:00
parent f7bbdf3f0f
commit 0a5dae85a3
1 changed files with 6 additions and 1 deletions

View File

@ -200,11 +200,16 @@ def on_townie_pre_save(sender, instance, **kwargs):
existing = existing[0]
if not existing.reviewed and instance.reviewed == True:
# See if we need to create this user on disk.
if not existing.reviewed and instance.reviewed is True:
instance.create_on_disk()
instance.send_welcome_email()
instance.write_authorized_keys()
# See if this user needs a rename on disk
if existing.username != instance.username:
instance.rename_on_disk(existing.username)
def _guarded_run(cmd_args, **run_args):
"""Given a list of args representing a command invocation as well as var