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
b176c9c8
Commit
b176c9c8
authored
Jan 16, 2016
by
Rafal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add api filter
parent
a16e3ac6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
views.py
JoinTheCityREST/app/API/views.py
+11
-0
No files found.
JoinTheCityREST/app/API/views.py
View file @
b176c9c8
...
...
@@ -5,6 +5,7 @@ import rest_framework
from
rest_framework.response
import
Response
from
app.API.models
import
API
,
APIType
from
app.API.serializers
import
APISerializer
,
APITypeSerializer
from
app.User.models
import
UserAPI
class
APIViewSet
(
viewsets
.
ModelViewSet
):
...
...
@@ -27,6 +28,16 @@ class APIViewSet(viewsets.ModelViewSet):
api
=
mod
.
API
(
request
)
return
HttpResponse
(
api
.
execute
(
function
),
content_type
=
"application/json"
)
def
get_queryset
(
self
):
queryset
=
API
.
objects
.
all
()
username
=
self
.
request
.
query_params
.
get
(
'only_new'
,
None
)
if
username
is
not
None
:
user_api
=
UserAPI
.
objects
.
all
()
user_api
=
[
api
.
api
for
api
in
user_api
]
queryset
=
[
api
for
api
in
queryset
if
api
not
in
user_api
]
return
queryset
class
APITypeViewSet
(
viewsets
.
ModelViewSet
):
"""
API for articles
...
...
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