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

Implement "Add user setting to choose between words based random alias and uuid alias" #5

Closed
wants to merge 11 commits into from

Conversation

doanguyen
Copy link
Contributor

No description provided.

class="btn btn-success">Random Alias
</button>
</form>
<div class="btn-group" role="group">
Copy link
Contributor

Choose a reason for hiding this comment

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

the indentation doesn't look right here, maybe your IDE mixes up space and tab?

<div class="small-text mb-3">Choose how to create your email alias by default</div>
<form method="post" class="form-inline">
<input type="hidden" name="form-name" value="change-alias-generator">
<select class="custom-select mr-sm-2" name="alias-generator-scheme" id="alias-generator-scheme">
Copy link
Contributor

Choose a reason for hiding this comment

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

the id="alias-generator-scheme" can be removed here I think

app/models.py Outdated
class User(db.Model, ModelMixin, UserMixin):
__tablename__ = "users"
email = db.Column(db.String(128), unique=True, nullable=False)
salt = db.Column(db.String(128), nullable=False)
password = db.Column(db.String(128), nullable=False)
name = db.Column(db.String(128), nullable=False)
is_admin = db.Column(db.Boolean, nullable=False, default=False)
alias_generator = db.Column(db.Integer, nullable=True, default=AliasGeneratorEnum.word.value)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can use nullable=False here? A field is easier to work with when it's non-nullable, that's why fields are generally non-nullable. Exception made for the ones that null value makes sense like profile_picture_id, custom_domain_id.

app/models.py Outdated
def generate_email() -> str:
"""generate an email address that does not exist before"""
random_email = random_words() + "@" + EMAIL_DOMAIN
def generate_email(scheme: int = 1, in_hex: bool = False) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

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

scheme: int = 1 could be replaced by scheme: int = AliasGeneratorEnum.word. The reason for that is enum should be used instead of its value.

@nguyenkims
Copy link
Contributor

Overall the PR looks good! I have checkout it locally and tested, the feature works well 👍.

I just left some comments, some might be a bit "nitpicking" as I try to minimize the code change as much as possible ...

Don't hesitate to use black to reformat the Python code. Some IDEs might break black formattings so please make sure to run black before creating the commit.

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.

None yet

2 participants