Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
Shoppe
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mongo101
Shoppe
Commits
de3ea93c
Commit
de3ea93c
authored
5 years ago
by
Ahmad Anvari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add balance to user model
parent
124c18d3
master
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
user.py
db/user.py
+9
-2
No files found.
db/user.py
View file @
de3ea93c
...
...
@@ -12,7 +12,8 @@ class User(Model):
first_name
=
dictionary
[
"first_name"
],
last_name
=
dictionary
[
"last_name"
],
email
=
dictionary
[
"email"
],
hashed_password
=
dictionary
[
"hashed_password"
]
hashed_password
=
dictionary
[
"hashed_password"
],
balance
=
dictionary
[
"balance"
],
)
u
.
__id
=
str
(
dictionary
[
"_id"
])
return
u
...
...
@@ -29,15 +30,18 @@ class User(Model):
res
[
"email"
]
=
self
.
__email
if
self
.
__hashed_password
is
not
None
:
res
[
"hashed_password"
]
=
self
.
__hashed_password
if
self
.
__balance
is
not
None
:
res
[
"balance"
]
=
self
.
__balance
return
res
def
__init__
(
self
,
first_name
,
last_name
,
email
,
hashed_password
):
def
__init__
(
self
,
first_name
,
last_name
,
email
,
hashed_password
,
balance
):
self
.
__id
=
None
self
.
__first_name
=
first_name
self
.
__last_name
=
last_name
self
.
__email
=
email
self
.
__hashed_password
=
hashed_password
self
.
__balance
=
balance
@
staticmethod
def
get_collection
():
...
...
@@ -70,3 +74,6 @@ class User(Model):
def
compare_password
(
self
,
new_password
):
new_hashed_password
=
hashlib
.
md5
(
new_password
.
encode
())
.
hexdigest
()
return
self
.
__hashed_password
==
new_hashed_password
def
__repr__
(
self
):
return
self
.
__email
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment