Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nk20
Manage
Activity
Members
Labels
Plan
Issues
32
Issue boards
Milestones
Wiki
Code
Merge requests
5
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BDE
nk20
Commits
f54e2ed1
Commit
f54e2ed1
authored
5 years ago
by
ynerant
Browse files
Options
Downloads
Patches
Plain Diff
Aliases were missing
parent
d22350fa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!8
API & autocomplétion
Pipeline
#7709
passed with stage
in 2 minutes and 57 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
apps/api/note/serializers.py
+12
-1
12 additions, 1 deletion
apps/api/note/serializers.py
apps/api/note/urls.py
+3
-2
3 additions, 2 deletions
apps/api/note/urls.py
apps/api/note/views.py
+12
-2
12 additions, 2 deletions
apps/api/note/views.py
apps/api/urls.py
+4
-2
4 additions, 2 deletions
apps/api/urls.py
with
31 additions
and
7 deletions
apps/api/note/serializers.py
+
12
−
1
View file @
f54e2ed1
...
...
@@ -2,7 +2,7 @@
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from
note.models.notes
import
Note
,
NoteClub
,
NoteSpecial
,
NoteUser
from
note.models.notes
import
Note
,
NoteClub
,
NoteSpecial
,
NoteUser
,
Alias
from
note.models.transactions
import
TransactionTemplate
,
Transaction
,
MembershipTransaction
from
rest_framework
import
serializers
from
rest_polymorphic.serializers
import
PolymorphicSerializer
...
...
@@ -50,6 +50,17 @@ class NoteUserSerializer(serializers.ModelSerializer):
model
=
NoteUser
fields
=
'
__all__
'
class
AliasSerializer
(
serializers
.
ModelSerializer
):
"""
REST API Serializer for Aliases.
The djangorestframework plugin will analyse the model `Alias` and parse all fields in the API.
"""
class
Meta
:
model
=
Alias
fields
=
'
__all__
'
class
NotePolymorphicSerializer
(
PolymorphicSerializer
):
model_serializer_mapping
=
{
Note
:
NoteSerializer
,
...
...
This diff is collapsed.
Click to expand it.
apps/api/note/urls.py
+
3
−
2
View file @
f54e2ed1
...
...
@@ -2,7 +2,7 @@
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from
.views
import
NoteViewSet
,
NotePolymorphicViewSet
,
NoteClubViewSet
,
NoteUserViewSet
,
NoteSpecialViewSet
,
\
from
.views
import
NoteViewSet
,
NotePolymorphicViewSet
,
NoteClubViewSet
,
NoteUserViewSet
,
NoteSpecialViewSet
,
AliasViewSet
,
\
TransactionViewSet
,
TransactionTemplateViewSet
,
MembershipTransactionViewSet
...
...
@@ -10,7 +10,8 @@ def register_note_urls(router, path):
"""
Configure router for Note REST API.
"""
router
.
register
(
path
+
''
,
NotePolymorphicViewSet
)
router
.
register
(
path
+
'
/note
'
,
NotePolymorphicViewSet
)
router
.
register
(
path
+
'
/alias
'
,
AliasViewSet
)
router
.
register
(
path
+
'
/transaction/transaction
'
,
TransactionViewSet
)
router
.
register
(
path
+
'
/transaction/template
'
,
TransactionTemplateViewSet
)
...
...
This diff is collapsed.
Click to expand it.
apps/api/note/views.py
+
12
−
2
View file @
f54e2ed1
...
...
@@ -2,9 +2,9 @@
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from
note.models.notes
import
Note
,
NoteClub
,
NoteSpecial
,
NoteUser
from
note.models.notes
import
Note
,
NoteClub
,
NoteSpecial
,
NoteUser
,
Alias
from
note.models.transactions
import
TransactionTemplate
,
Transaction
,
MembershipTransaction
from
.serializers
import
NoteSerializer
,
NotePolymorphicSerializer
,
NoteClubSerializer
,
NoteSpecialSerializer
,
NoteUserSerializer
,
\
from
.serializers
import
NoteSerializer
,
NotePolymorphicSerializer
,
NoteClubSerializer
,
NoteSpecialSerializer
,
NoteUserSerializer
,
AliasSerializer
,
\
TransactionTemplateSerializer
,
TransactionSerializer
,
MembershipTransactionSerializer
from
rest_framework
import
viewsets
...
...
@@ -59,6 +59,16 @@ class NotePolymorphicViewSet(viewsets.ModelViewSet):
serializer_class
=
NotePolymorphicSerializer
class
AliasViewSet
(
viewsets
.
ModelViewSet
):
"""
REST API View set.
The djangorestframework plugin will get all `Alias` objects, serialize it to JSON with the given serializer,
then render it on /api/aliases/
"""
queryset
=
Alias
.
objects
.
all
()
serializer_class
=
AliasSerializer
class
TransactionTemplateViewSet
(
viewsets
.
ModelViewSet
):
"""
REST API View set.
...
...
This diff is collapsed.
Click to expand it.
apps/api/urls.py
+
4
−
2
View file @
f54e2ed1
...
...
@@ -5,6 +5,8 @@
from
django.conf.urls
import
url
,
include
from
django.contrib.auth.models
import
User
from
rest_framework
import
routers
,
serializers
,
viewsets
from
note.models
import
Alias
from
.activity.urls
import
register_activity_urls
from
.members.urls
import
register_members_urls
from
.note.urls
import
register_note_urls
...
...
@@ -16,7 +18,7 @@ class UserSerializer(serializers.ModelSerializer):
"""
class
Meta
:
model
=
User
fields
=
(
'
username
'
,
'
first_name
'
,
'
last_name
'
,
'
email
'
,
'
is_staff
'
,)
fields
=
'
__all__
'
class
UserViewSet
(
viewsets
.
ModelViewSet
):
"""
...
...
@@ -29,7 +31,7 @@ class UserViewSet(viewsets.ModelViewSet):
# Routers provide an easy way of automatically determining the URL conf.
router
=
routers
.
DefaultRouter
()
router
.
register
(
r
'
user
s
'
,
UserViewSet
)
router
.
register
(
'
user
'
,
UserViewSet
)
# Routers for members app
register_members_urls
(
router
,
r
'
members
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment