Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
MGML.eu
prius
Commits
0996c5d4
Commit
0996c5d4
authored
Jun 11, 2020
by
cermak
Browse files
Cherry pick from develop - add ids to rest api
parent
a7650bf9
Changes
1
Show whitespace changes
Inline
Side-by-side
app/rest.py
View file @
0996c5d4
...
...
@@ -19,18 +19,21 @@ class ProposalSerializer(serializers.ModelSerializer):
fields
=
(
'proposal'
,
'title'
,
'users'
,
'localcontacts'
)
def
get_users
(
self
,
obj
):
userlist
=
[{
'name'
:
obj
.
proposer
.
contact
.
name
,
userlist
=
[{
'id'
:
obj
.
proposer
.
contact
.
pk
,
'name'
:
obj
.
proposer
.
contact
.
name
,
'email'
:
obj
.
proposer
.
contact
.
email
,
'affiliation'
:
str
(
obj
.
proposer
.
contact
.
affiliation
),
}]
for
u
in
obj
.
coproposers
.
all
():
userlist
.
append
({
'id'
:
u
.
pk
,
'name'
:
u
.
name
,
'email'
:
u
.
email
,
'affiliation'
:
str
(
u
.
affiliation
),
})
if
obj
.
supervisor
:
userlist
.
append
({
'id'
:
obj
.
supervisor
.
pk
,
'name'
:
obj
.
supervisor
.
name
,
'email'
:
obj
.
supervisor
.
email
,
'affiliation'
:
str
(
obj
.
supervisor
.
affiliation
),
...
...
@@ -41,6 +44,7 @@ class ProposalSerializer(serializers.ModelSerializer):
lclist
=
[]
for
u
in
obj
.
local_contacts
.
all
():
lclist
.
append
({
'id'
:
u
.
pk
,
'name'
:
u
.
name
,
'email'
:
u
.
email
,
'affiliation'
:
str
(
u
.
affiliation
),
...
...
@@ -49,7 +53,7 @@ class ProposalSerializer(serializers.ModelSerializer):
# API views:
class
MyProposalList
(
generics
.
List
Create
APIView
):
class
MyProposalList
(
generics
.
ListAPIView
):
permission_classes
=
[
permissions
.
IsAuthenticated
]
def
get
(
self
,
request
):
...
...
@@ -60,5 +64,4 @@ class MyProposalList(generics.ListCreateAPIView):
serializer
=
ProposalSerializer
(
proposals
,
many
=
True
)
return
Response
(
serializer
.
data
)
#queryset = User.objects.all()
#serializer_class = UserSerializer
\ No newline at end of file
queryset
=
Proposals
.
objects
.
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