Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
warpinfra
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor 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
Sebastian
warpinfra
Commits
f67f8a0b
Commit
f67f8a0b
authored
8 years ago
by
Christian Dresen
Browse files
Options
Downloads
Patches
Plain Diff
[WarpPay] Added API Path for Categories
parent
a816c30e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
www/web/warppay/models.py
+4
-0
4 additions, 0 deletions
www/web/warppay/models.py
www/web/warppay/urls.py
+1
-0
1 addition, 0 deletions
www/web/warppay/urls.py
www/web/warppay/views.py
+13
-1
13 additions, 1 deletion
www/web/warppay/views.py
with
18 additions
and
1 deletion
www/web/warppay/models.py
+
4
−
0
View file @
f67f8a0b
...
...
@@ -9,6 +9,10 @@ class ProductCategory(models.Model):
def
__str__
(
self
):
return
self
.
name
class
ProductCategorySerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
model
=
ProductCategory
fields
=
[
'
id
'
,
'
name
'
]
class
Product
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
100
,
null
=
True
)
...
...
This diff is collapsed.
Click to expand it.
www/web/warppay/urls.py
+
1
−
0
View file @
f67f8a0b
...
...
@@ -6,6 +6,7 @@ urlpatterns = [
url
(
r
'
^api/users/$
'
,
views
.
user_list
),
url
(
r
'
^api/users/(?P<user_id>\w+)/$
'
,
views
.
user_list
),
url
(
r
'
^api/products/$
'
,
views
.
product_list
),
url
(
r
'
^api/categories/$
'
,
views
.
category_list
),
url
(
r
'
^api/gen_token/$
'
,
views
.
gen_token
),
url
(
r
'
^api/transaction/(?P<user_id>\w+)/$
'
,
views
.
transaction
),
...
...
This diff is collapsed.
Click to expand it.
www/web/warppay/views.py
+
13
−
1
View file @
f67f8a0b
from
django.db
import
IntegrityError
from
django.core.exceptions
import
ObjectDoesNotExist
from
warpauth.models
import
LdapUser
from
warppay.models
import
UserCredit
,
UserCreditSerializer
,
Product
,
ProductSerializer
,
Transaction
from
warppay.models
import
UserCredit
,
UserCreditSerializer
,
Product
,
ProductSerializer
,
ProductCategory
,
ProductCategorySerializer
,
Transaction
from
rest_framework.decorators
import
api_view
from
rest_framework.response
import
Response
from
rest_framework.authentication
import
TokenAuthentication
...
...
@@ -13,6 +13,18 @@ from rest_framework import status
# logging.getLogger('main').info(token.key)
@api_view
([
'
GET
'
,
'
PUT
'
])
#@authentication_classes((TokenAuthentication,))
#@permission_classes((IsAuthenticated,))
def
category_list
(
request
):
if
request
.
method
==
'
GET
'
:
products
=
ProductCategory
.
objects
.
all
()
serializer
=
ProductCategorySerializer
(
products
,
context
=
{
'
request
'
:
request
},
many
=
True
)
return
Response
(
serializer
.
data
)
return
Response
()
@api_view
([
'
GET
'
,
'
PUT
'
])
#@authentication_classes((TokenAuthentication,))
#@permission_classes((IsAuthenticated,))
...
...
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