Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delegate Account Creation #631

Merged
merged 6 commits into from
Oct 12, 2017

Conversation

m-j-mcdonald
Copy link
Contributor

@m-j-mcdonald m-j-mcdonald commented Sep 28, 2017

The final part of #614. In addition to account creation, this makes the delegate's email a required field (so that the delegate can receive an email with account login information).

@m-j-mcdonald m-j-mcdonald mentioned this pull request Sep 28, 2017
@m-j-mcdonald
Copy link
Contributor Author

Does anyone have some ideas for good unit tests on this? I have a few but I want to be confident that the accounts work as intended.

Copy link
Member

@kmeht kmeht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me. Are the advisor and chair portions of the app sufficiently built-out to start working on the delegates?

@@ -18,8 +18,7 @@ var DelegateSelect = React.createClass({
return (
<select
onChange={this.props.onChange}
value={this.props.selectedDelegateID}
disabled>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remind me why this was disabled in the first place?

Copy link
Contributor Author

@m-j-mcdonald m-j-mcdonald Oct 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was done in #576, I assume to disable some functionality before conference. This ties into why I opened #632

first_name=names[0], last_name=names[-1],
email=instance.email)
user.set_password(password)
user.save()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're hitting the DB twice here: once when we call create, and once when we callsave. We should only do it once (right here). Instead of using the manager's create method, you should be able to just construct a User object. If there's a particular reason we're saving twice, feel free to ignore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch; I'll fix this.

email=instance.email)
user.set_password(password)
user.save()
send_mail('A new account has been created for {0}!\n'.format(instance.name),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should really use templates for emails. We have #109 open for that, if you wanna assign that to a new developer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll find someone this weekend to work on it

password = BaseUserManager().make_random_password(10)
user = User.objects.create(delegate=instance, username=username,\
user_type=User.TYPE_DELEGATE,\
last_login=datetime.now(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a field we added? If it's default Django, wouldn't this be set by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's something we set when creating accounts for advisors; I wasn't sure of the motivation there so I figured it wouldn't hurt to include it here as well.

user.save()
send_mail('A new account has been created for {0}!\n'.format(instance.name),
'Username: {0}\n'.format(username) \
+ 'Password: {0}\n'.format(password) \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes, plaintext passwords. But, since delegates aren't creating their own accounts, I don't see an immediate way around this, other than forcing them to change their password the first time they log in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it isn't great, but the accounts themselves contain nothing sensitive and we need an efficient way to distribute the passwords.

@m-j-mcdonald m-j-mcdonald force-pushed the delegate_account_creation branch from 4de59db to 2bd63b0 Compare October 5, 2017 03:44
@m-j-mcdonald m-j-mcdonald merged commit c426f55 into bmun:master Oct 12, 2017
@m-j-mcdonald m-j-mcdonald deleted the delegate_account_creation branch October 12, 2017 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants