-
-
Notifications
You must be signed in to change notification settings - Fork 17
added custom fields to user model #69
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also write some unit tests creating and committing models with some edge cases for this model.
cases are when email is verified but mobile num is not and vice versa.
unless both of them are not verified user is not verified.
for that purpose, you could do something like:
class User:
..
..
@property
def is_verified(self):
return self.otp_verified and self.email_verified
check again after running shell_plus or from DB model schema, i think its self.auth_user.email_verified ;
@ElijahAhianyo if working on JIRA tasks, use smart commits |
@ElijahAhianyo first un apply this particular migration and then remigrate after making changes |
@ElijahAhianyo I can do this section. You can focus on the rest of the requested changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would great if @milan-tom could merge his pr ElijahAhianyo#1 to your branch @ElijahAhianyo
Congratulations 🎉. DeepCode analyzed your code in 2.47 seconds and we found no issues. Enjoy a moment of no bugs ☀️. 👉 View analysis in DeepCode’s Dashboard | Configure the bot |
@milan-tom do the following to fix the ☝️ issue and bring more structure and clarity to overall testing :
[DEFAULT]
USERNAME =
PASSWORD =
EMAIL =
DB_USERNAME =
DB_PASSWORD =
[verified]
User =
Password
[unverified]
similarly here =
import six
import configparser
confg = configparser.ConfigParser()
confg.read(your ini file)
user = six.text_type(confg['unverified']['USER']) and so on.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@milan-tom left few comments. I've requested some changes. this will bring more structure as we bring test coverage to our codebase. i'll review again on those changes.
What is the purpose of |
Easy to google and understand |
I did Google it. However, I just don't understand why we need it when the values are converted to strings by default. I have made a solution that does not require it. |
Because you are assuming a lot of things: the underlying code is guaranteed to be yours and it behaves a certain way. Use six.ensure_text to ensure it gets the text input. Break that line with correct interface definition like: @dataclass(frozen=True)
class Credentials:
user: str
pass: str
something_else: int
class CredentialsFactoryLoader:
def __init__(self, config_file, credentials_class: credentials_class: TypeVar('Credentials', bound=True) = None, loader_class=None):
self.credentials_class = credentials_class
self.loader = loader_class(config_file)
def read_verified(self):
return self.credentials_class(self.loader.read_verified_config())
def read_unverified(self):
return self.credentials_class(self.loader.read_unverified_config())
class ConfigByteLoader():
// some logic to load
def sanitize(self):
value = {}
ensure whatever transformation you do here.
ensure_text where text field expected
ensure digits are converted
return value dict here;
def read_verified_config(self):
pass
class ConfigFileLoader():
def __init__(self, config_file: str):
self.config_setting = config.read_file(config_file)
def read_verified_config(self) -> dict:
ensure whatever transformation you do here.
ensure_text where text field expected
ensure digits are converted
return value dict here;
return dict(user=self.config_settings['user'], pass=self.config_settings['pass'])
// older loader ->
// creds_obj = CredentialsFactoryLoader(config_file, Credentials, ConfigFileLoader)
creds_obj = CredentialsFactoryLoader(config_file, Credentials, ConfigByteLoader)
create_user(**creds_obj.read_unverified()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format files
Could I use |
Yes, either one. six is compatibility module which we're already using. regardless, define interface so that we know what interface to conform to if we ever change the underlying abstraction. most likely, we will modify the config file soon; |
This pull request introduces 2 alerts when merging 5a5471a into 1a1ed31 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 56096ab into 1a1ed31 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 8feef55 into df1fc21 - view on LGTM.com new alerts:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of @codecakes' requested changes have been completed. The only failing checks are due to the following reasons:
- Formatting problems in some migrations ➔ Based upon my understanding, migrations shouldn't be edited manually
1 blank line required before class docstring (found 0) (D203)
error from Codacy Static Code Analysis ➔ PEP 257 has removed this recommendation and so I think this check should be removedWildcard import base
➔ This seems kind of unavoidable in this case as we want to build the dev settings file on top of the base settings fileNo name 'config' in module 'common'
➔ Not sure why this error appears despite there being a__init__.py
file incommon
Unused variable 'acc_type_ids'
error inapps/auth_zero/models.py
➔ Perhaps we should remove this variable although it is not part of this pr
Looks like in order to pass Codacy Static Code Analysis |
I have merged my branch; there are changes that need to be merged back here from master |
make sure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure
apps.common.config
absolute imports everywhere
Are there any remaining common.config
imports?
your code will throw errors on testing if there are any |
@marcelloromani this should be resolved now @milan-tom ? |
This change is