Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
RECIRCLE
/
portal
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
11
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a63c5cd1
authored
Apr 06, 2020
by
Chif Gergő
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update serializer and create view
parent
878edb70
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
12 deletions
+6
-12
recircle/template/serializers.py
+1
-11
recircle/template/views.py
+5
-1
No files found.
recircle/template/serializers.py
View file @
a63c5cd1
...
...
@@ -11,17 +11,7 @@ class InstanceFromTemplateSerializer(serializers.Serializer):
class
ImageTemplateModelSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
model
=
ImageTemplate
fields
=
(
"id"
,
"name"
,
"description"
,
"created_at"
,
"created_by"
,
"image"
,
"flavor"
,
"lease"
,
"type"
,
)
fields
=
"__all__"
read_only_fields
=
(
"created_at"
,
"created_by"
,
...
...
recircle/template/views.py
View file @
a63c5cd1
...
...
@@ -10,17 +10,21 @@ class ImageTemplateViewSet(ModelViewSet):
queryset
=
ImageTemplate
.
objects
.
all
()
def
create
(
self
,
request
):
# TODO: Check the permissions to create template and using the flavors and leases
serializer
=
ImageTemplateModelSerializer
(
data
=
request
.
data
)
serializer
.
is_valid
(
raise_exception
=
True
)
data
=
serializer
.
validated_data
new_template
=
ImageTemplate
.
create
(
name
=
data
[
"name"
],
description
=
data
[
"description"
],
access_protocol
=
data
[
"access"
],
system_type
=
data
[
"system"
],
distro
=
data
[
"distro"
],
created_by
=
request
.
user
,
image
=
data
[
"image"
],
lease
=
data
[
"lease"
],
flavor
=
data
[
"flavor"
],
type
=
"
U
"
type
=
"
IMAGE
"
)
serializer
=
ImageTemplateModelSerializer
(
instance
=
new_template
)
return
Response
(
serializer
.
data
)
...
...
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