Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
JoinTheCity
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
Rafal
JoinTheCity
Commits
b90f77ff
Commit
b90f77ff
authored
Jan 17, 2016
by
Rafal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Checkit
parent
0e7a7291
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
urls.py
JoinTheCityREST/JoinTheCityREST/urls.py
+1
-1
views.py
JoinTheCityREST/app/API/views.py
+7
-7
No files found.
JoinTheCityREST/JoinTheCityREST/urls.py
View file @
b90f77ff
...
@@ -35,7 +35,7 @@ router.register(r'tag_discussion', tag_views.TagDiscussionViewSet, base_name="ta
...
@@ -35,7 +35,7 @@ router.register(r'tag_discussion', tag_views.TagDiscussionViewSet, base_name="ta
urlpatterns
=
[
urlpatterns
=
[
url
(
r'^api/api/(\d+)/(\w+)(|\/)$'
,
api_views
.
APIViewSet
.
test
),
#
url(r'^api/api/(\d+)/(\w+)(|\/)$', api_views.APIViewSet.test),
url
(
r'^api/'
,
include
(
router
.
urls
)),
url
(
r'^api/'
,
include
(
router
.
urls
)),
url
(
r'^api-auth/'
,
include
(
'rest_framework.urls'
,
url
(
r'^api-auth/'
,
include
(
'rest_framework.urls'
,
namespace
=
'rest_framework'
)),
namespace
=
'rest_framework'
)),
...
...
JoinTheCityREST/app/API/views.py
View file @
b90f77ff
...
@@ -18,20 +18,16 @@ class APIViewSet(viewsets.ModelViewSet):
...
@@ -18,20 +18,16 @@ class APIViewSet(viewsets.ModelViewSet):
permission_classes
=
(
permissions
.
IsAuthenticatedOrReadOnly
,)
permission_classes
=
(
permissions
.
IsAuthenticatedOrReadOnly
,)
@
staticmethod
@
detail_route
()
def
add
(
request
,
pk
=
None
):
def
add
(
self
,
request
,
pk
=
None
):
api
=
get_object_or_404
(
APIViewSet
.
queryset
,
pk
=
pk
)
api
=
get_object_or_404
(
APIViewSet
.
queryset
,
pk
=
pk
)
user
=
request
.
user
user
=
request
.
user
print
request
.
user
.
id
user_api
=
UserAPI
(
user
=
user
,
api
=
api
)
user_api
=
UserAPI
(
user
=
user
,
api
=
api
)
user_api
.
save
()
user_api
.
save
()
return
Response
(
status
=
rest_framework
.
status
.
HTTP_200_OK
)
return
Response
(
status
=
rest_framework
.
status
.
HTTP_200_OK
)
@
staticmethod
@
staticmethod
def
test
(
request
,
id
,
function
,
slash
):
def
test
(
request
,
id
,
function
):
if
function
==
'add'
:
APIViewSet
.
add
(
request
,
id
)
return
HttpResponse
(
status
=
rest_framework
.
status
.
HTTP_200_OK
)
try
:
try
:
object
=
API
.
objects
.
get
(
pk
=
id
)
object
=
API
.
objects
.
get
(
pk
=
id
)
except
Exception
as
e
:
except
Exception
as
e
:
...
@@ -40,6 +36,7 @@ class APIViewSet(viewsets.ModelViewSet):
...
@@ -40,6 +36,7 @@ class APIViewSet(viewsets.ModelViewSet):
name
=
"lib.api.{0}"
.
format
(
object
.
source
.
strip
())
name
=
"lib.api.{0}"
.
format
(
object
.
source
.
strip
())
mod
=
__import__
(
name
,
fromlist
=
[
'API'
])
mod
=
__import__
(
name
,
fromlist
=
[
'API'
])
api
=
mod
.
API
(
request
)
api
=
mod
.
API
(
request
)
return
HttpResponse
(
api
.
execute
(
function
),
content_type
=
"application/json"
)
return
HttpResponse
(
api
.
execute
(
function
),
content_type
=
"application/json"
)
def
get_queryset
(
self
):
def
get_queryset
(
self
):
...
@@ -49,6 +46,9 @@ class APIViewSet(viewsets.ModelViewSet):
...
@@ -49,6 +46,9 @@ class APIViewSet(viewsets.ModelViewSet):
user_api
=
UserAPI
.
objects
.
all
()
user_api
=
UserAPI
.
objects
.
all
()
user_api
=
[
api
.
api
for
api
in
user_api
]
user_api
=
[
api
.
api
for
api
in
user_api
]
queryset
=
[
api
for
api
in
queryset
if
api
not
in
user_api
]
queryset
=
[
api
for
api
in
queryset
if
api
not
in
user_api
]
method
=
self
.
request
.
query_params
.
get
(
'method'
,
None
)
if
method
:
return
APIViewSet
.
test
(
self
.
request
,
self
.
kwargs
[
'pk'
],
method
)
return
queryset
return
queryset
class
APITypeViewSet
(
viewsets
.
ModelViewSet
):
class
APITypeViewSet
(
viewsets
.
ModelViewSet
):
...
...
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