Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
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
ops
jumpserver
Commits
64582319
Commit
64582319
authored
Aug 23, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add api file
parent
9a6d20b6
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
0 deletions
+52
-0
settings.py
apps/jumpserver/settings.py
+10
-0
urls.py
apps/jumpserver/urls.py
+4
-0
api.py
apps/users/api.py
+9
-0
api_urls.py
apps/users/api_urls.py
+17
-0
serializers.py
apps/users/serializers.py
+12
-0
No files found.
apps/jumpserver/settings.py
View file @
64582319
...
@@ -48,6 +48,7 @@ INSTALLED_APPS = [
...
@@ -48,6 +48,7 @@ INSTALLED_APPS = [
'ops.apps.OpsConfig'
,
'ops.apps.OpsConfig'
,
'audits.apps.AuditsConfig'
,
'audits.apps.AuditsConfig'
,
'common.apps.CommonConfig'
,
'common.apps.CommonConfig'
,
'rest_framework'
,
'bootstrapform'
,
'bootstrapform'
,
# 'django.contrib.admin',
# 'django.contrib.admin',
'django.contrib.auth'
,
'django.contrib.auth'
,
...
@@ -167,3 +168,11 @@ BOOTSTRAP_COLUMN_COUNT = 11
...
@@ -167,3 +168,11 @@ BOOTSTRAP_COLUMN_COUNT = 11
# Init data or generate fake data source for development
# Init data or generate fake data source for development
FIXTURE_DIRS
=
[
os
.
path
.
join
(
BASE_DIR
,
'fixtures'
),
]
FIXTURE_DIRS
=
[
os
.
path
.
join
(
BASE_DIR
,
'fixtures'
),
]
REST_FRAMEWORK
=
{
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
'DEFAULT_PERMISSION_CLASSES'
:
[
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
],
}
\ No newline at end of file
apps/jumpserver/urls.py
View file @
64582319
...
@@ -25,6 +25,10 @@ urlpatterns = [
...
@@ -25,6 +25,10 @@ urlpatterns = [
# url(r'^admin/', admin.site.urls),
# url(r'^admin/', admin.site.urls),
]
]
urlpatterns
+=
[
url
(
r'^api/users/'
,
include
(
'users.api_urls'
)),
]
if
settings
.
DEBUG
:
if
settings
.
DEBUG
:
urlpatterns
+=
static
(
settings
.
MEDIA_URL
,
document_root
=
settings
.
MEDIA_ROOT
)
urlpatterns
+=
static
(
settings
.
MEDIA_URL
,
document_root
=
settings
.
MEDIA_ROOT
)
apps/users/api.py
View file @
64582319
# ~*~ coding: utf-8 ~*~
# ~*~ coding: utf-8 ~*~
#
#
from
rest_framework
import
viewsets
from
.serializers
import
UserSerializer
from
.models
import
User
,
UserGroup
,
Role
class
UserViewSet
(
viewsets
.
ModelViewSet
):
queryset
=
User
.
objects
.
all
()
serializer_class
=
UserSerializer
apps/users/api_urls.py
0 → 100644
View file @
64582319
# -*- coding: utf-8 -*-
#
from
django.conf.urls
import
url
,
include
from
rest_framework
import
routers
from
.api
import
UserViewSet
router
=
routers
.
DefaultRouter
()
router
.
register
(
r'users'
,
UserViewSet
)
urlpatterns
=
[
url
(
r'v1/'
,
include
(
router
.
urls
)),
url
(
r'^api-auth/'
,
include
(
'rest_framework.urls'
,
namespace
=
'rest_framework'
))
]
apps/users/serializers.py
0 → 100644
View file @
64582319
# -*- coding: utf-8 -*-
#
from
rest_framework
import
serializers
from
.models
import
Role
,
User
,
UserGroup
class
UserSerializer
(
serializers
.
HyperlinkedModelSerializer
):
class
Meta
:
model
=
User
fields
=
'__all__'
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