Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
BeHub-web
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
Dominik Rosiek
BeHub-web
Commits
24635c2c
Commit
24635c2c
authored
Nov 21, 2015
by
Rafal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add userview, serializer
parent
eb2fff27
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
3 deletions
+23
-3
urls.py
BeHub/BeHub/urls.py
+1
-0
serializers.py
BeHub/Hub/serializers.py
+11
-2
views.py
BeHub/Hub/views.py
+11
-1
No files found.
BeHub/BeHub/urls.py
View file @
24635c2c
...
@@ -13,6 +13,7 @@ router.register(r'beacon_managers', hub_views.BeaconManagerViewSet)
...
@@ -13,6 +13,7 @@ router.register(r'beacon_managers', hub_views.BeaconManagerViewSet)
router
.
register
(
r'category'
,
hub_views
.
CategoryViewSet
)
router
.
register
(
r'category'
,
hub_views
.
CategoryViewSet
)
router
.
register
(
r'sites'
,
hub_views
.
SiteViewSet
)
router
.
register
(
r'sites'
,
hub_views
.
SiteViewSet
)
router
.
register
(
r'uuid'
,
hub_views
.
UuidBeaconViewSet
)
router
.
register
(
r'uuid'
,
hub_views
.
UuidBeaconViewSet
)
router
.
register
(
r'users'
,
hub_views
.
UserViewSet
)
urlpatterns
=
patterns
(
''
,
urlpatterns
=
patterns
(
''
,
...
...
BeHub/Hub/serializers.py
View file @
24635c2c
from
rest_framework
import
serializers
from
rest_framework
import
serializers
from
rest_framework.decorators
import
detail_route
,
list_route
from
django.contrib.auth.models
import
User
from
Hub.models
import
Beacon
,
BeaconManager
,
Category
,
Site
from
Hub.models
import
Beacon
,
BeaconManager
,
Category
,
Site
class
SiteSerializer
(
serializers
.
HyperlinkedModelSerializer
):
class
SiteSerializer
(
serializers
.
HyperlinkedModelSerializer
):
author
=
serializers
.
HyperlinkedRelatedField
(
view_name
=
'user-detail'
,
queryset
=
User
.
objects
.
all
())
class
Meta
:
class
Meta
:
model
=
Site
model
=
Site
fields
=
(
'id'
,
'url'
,
'link_url'
,
'description'
,
'category'
'author'
)
fields
=
(
'id'
,
'url'
,
'link_url'
,
'description'
,
'category'
,
'author'
)
class
UserSerializer
(
serializers
.
HyperlinkedModelSerializer
):
class
Meta
:
model
=
Site
fields
=
(
'id'
,
'url'
)
class
BeaconSerializer
(
serializers
.
HyperlinkedModelSerializer
):
class
BeaconSerializer
(
serializers
.
HyperlinkedModelSerializer
):
...
...
BeHub/Hub/views.py
View file @
24635c2c
from
django.contrib
import
auth
from
django.contrib
import
auth
from
django.contrib.auth
import
login
from
django.contrib.auth
import
login
from
django.contrib.auth.models
import
User
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.http
import
HttpResponseRedirect
,
HttpResponse
from
django.http
import
HttpResponseRedirect
,
HttpResponse
from
django.shortcuts
import
render
,
render_to_response
,
redirect
from
django.shortcuts
import
render
,
render_to_response
,
redirect
...
@@ -11,7 +12,8 @@ import rest_framework
...
@@ -11,7 +12,8 @@ import rest_framework
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
from
rest_framework.views
import
APIView
from
rest_framework.views
import
APIView
from
Hub.models
import
Beacon
,
BeaconManager
,
Site
,
Category
from
Hub.models
import
Beacon
,
BeaconManager
,
Site
,
Category
from
Hub.serializers
import
BeaconSerializer
,
BeaconManagerSerializer
,
SiteSerializer
,
CategorySerializer
from
Hub.serializers
import
BeaconSerializer
,
BeaconManagerSerializer
,
SiteSerializer
,
CategorySerializer
,
\
UserSerializer
class
BeaconViewSet
(
viewsets
.
ModelViewSet
):
class
BeaconViewSet
(
viewsets
.
ModelViewSet
):
...
@@ -21,6 +23,14 @@ class BeaconViewSet(viewsets.ModelViewSet):
...
@@ -21,6 +23,14 @@ class BeaconViewSet(viewsets.ModelViewSet):
queryset
=
Beacon
.
objects
.
all
()
queryset
=
Beacon
.
objects
.
all
()
serializer_class
=
BeaconSerializer
serializer_class
=
BeaconSerializer
class
UserViewSet
(
viewsets
.
ModelViewSet
):
"""
API for places
"""
queryset
=
User
.
objects
.
all
()
serializer_class
=
UserSerializer
class
BeaconManagerViewSet
(
viewsets
.
ModelViewSet
):
class
BeaconManagerViewSet
(
viewsets
.
ModelViewSet
):
"""
"""
API for places
API for places
...
...
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