Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ECE651_Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chris Li
ECE651_Backend
Commits
322778ba
Commit
322778ba
authored
2 years ago
by
Yirou Qiu
Browse files
Options
Downloads
Patches
Plain Diff
modified bill model, delete 'title', add 'wallet'
parent
7aa9c490
No related branches found
No related tags found
1 merge request
!7
Yrq/feature/bill api
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
core/api/bill.py
+8
-8
8 additions, 8 deletions
core/api/bill.py
core/models/bill.py
+18
-8
18 additions, 8 deletions
core/models/bill.py
core/serializers/bill.py
+1
-1
1 addition, 1 deletion
core/serializers/bill.py
with
27 additions
and
17 deletions
core/api/bill.py
+
8
−
8
View file @
322778ba
...
@@ -8,10 +8,10 @@ from rest_framework import permissions, authentication
...
@@ -8,10 +8,10 @@ from rest_framework import permissions, authentication
class
BillListCreate
(
mixins
.
ListModelMixin
,
mixins
.
CreateModelMixin
,
generics
.
GenericAPIView
):
class
BillListCreate
(
mixins
.
ListModelMixin
,
mixins
.
CreateModelMixin
,
generics
.
GenericAPIView
):
queryset
=
Bill
.
objects
.
all
()
queryset
=
Bill
.
objects
.
all
()
serializer_class
=
BillSerializer
serializer_class
=
BillSerializer
#
authentication_classes = [
authentication_classes
=
[
#
authentication.SessionAuthentication,
authentication
.
SessionAuthentication
,
#
authentication.TokenAuthentication
authentication
.
TokenAuthentication
#
]
]
permission_classes
=
(
permissions
.
IsAuthenticated
,)
permission_classes
=
(
permissions
.
IsAuthenticated
,)
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
...
@@ -50,10 +50,10 @@ class BillDetail(mixins.RetrieveModelMixin,
...
@@ -50,10 +50,10 @@ class BillDetail(mixins.RetrieveModelMixin,
generics
.
GenericAPIView
):
generics
.
GenericAPIView
):
queryset
=
Bill
.
objects
.
all
()
queryset
=
Bill
.
objects
.
all
()
serializer_class
=
BillSerializer
serializer_class
=
BillSerializer
#
authentication_classes = [
authentication_classes
=
[
#
authentication.SessionAuthentication,
authentication
.
SessionAuthentication
,
#
authentication.TokenAuthentication
authentication
.
TokenAuthentication
#
]
]
permission_classes
=
(
permissions
.
IsAuthenticated
,)
permission_classes
=
(
permissions
.
IsAuthenticated
,)
lookup_field
=
"
pk
"
lookup_field
=
"
pk
"
...
...
This diff is collapsed.
Click to expand it.
core/models/bill.py
+
18
−
8
View file @
322778ba
...
@@ -42,12 +42,12 @@ class BillSearchQuerySet(models.QuerySet):
...
@@ -42,12 +42,12 @@ class BillSearchQuerySet(models.QuerySet):
qs
=
self
.
filter
(
user
=
user
).
filter
(
lookup
)
qs
=
self
.
filter
(
user
=
user
).
filter
(
lookup
)
return
qs
return
qs
def
searchTitle
(
self
,
keyword
,
user
=
None
):
#
def searchTitle(self, keyword, user=None):
lookup
=
Q
(
title__contains
=
keyword
)
#
lookup = Q(title__contains = keyword)
qs
=
self
.
filter
(
lookup
)
#
qs = self.filter(lookup)
if
user
is
not
None
:
#
if user is not None:
qs
=
self
.
filter
(
user
=
user
).
filter
(
lookup
)
#
qs = self.filter(user=user).filter(lookup)
return
qs
#
return qs
# def categorieAmount(self, date, categories, user=None):
# def categorieAmount(self, date, categories, user=None):
...
@@ -65,7 +65,7 @@ class Bill(UUIDModel):
...
@@ -65,7 +65,7 @@ class Bill(UUIDModel):
user
=
models
.
ForeignKey
(
User
,
default
=
1
,
null
=
True
,
on_delete
=
models
.
SET_NULL
)
user
=
models
.
ForeignKey
(
User
,
default
=
1
,
null
=
True
,
on_delete
=
models
.
SET_NULL
)
title
=
models
.
CharField
(
max_length
=
120
)
#
title = models.CharField(max_length = 120)
date
=
models
.
DateField
(
verbose_name
=
"
payment time
"
,
default
=
datetime
.
date
.
today
)
date
=
models
.
DateField
(
verbose_name
=
"
payment time
"
,
default
=
datetime
.
date
.
today
)
...
@@ -92,4 +92,14 @@ class Bill(UUIDModel):
...
@@ -92,4 +92,14 @@ class Bill(UUIDModel):
)
)
categories
=
models
.
SmallIntegerField
(
verbose_name
=
"
bill categories
"
,
choices
=
categories
,
default
=
11
)
categories
=
models
.
SmallIntegerField
(
verbose_name
=
"
bill categories
"
,
choices
=
categories
,
default
=
11
)
\ No newline at end of file
wallet
=
(
(
1
,
"
checking account
"
),
(
2
,
"
credit account
"
),
(
3
,
"
cash
"
),
(
4
,
"
savings account
"
),
(
5
,
"
other
"
)
)
wallet
=
models
.
SmallIntegerField
(
verbose_name
=
"
wallet
"
,
choices
=
wallet
,
default
=
3
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
core/serializers/bill.py
+
1
−
1
View file @
322778ba
...
@@ -12,7 +12,7 @@ class BillSerializer(serializers.ModelSerializer):
...
@@ -12,7 +12,7 @@ class BillSerializer(serializers.ModelSerializer):
fields
=
(
fields
=
(
'
user
'
,
'
user
'
,
'
url
'
,
'
url
'
,
'
tit
le
'
,
'
wal
le
t
'
,
'
date
'
,
'
date
'
,
'
datetime
'
,
'
datetime
'
,
'
price
'
,
'
price
'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment