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
Show 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):
...
@@ -11,17 +11,7 @@ class InstanceFromTemplateSerializer(serializers.Serializer):
class
ImageTemplateModelSerializer
(
serializers
.
ModelSerializer
):
class
ImageTemplateModelSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
class
Meta
:
model
=
ImageTemplate
model
=
ImageTemplate
fields
=
(
fields
=
"__all__"
"id"
,
"name"
,
"description"
,
"created_at"
,
"created_by"
,
"image"
,
"flavor"
,
"lease"
,
"type"
,
)
read_only_fields
=
(
read_only_fields
=
(
"created_at"
,
"created_at"
,
"created_by"
,
"created_by"
,
...
...
recircle/template/views.py
View file @
a63c5cd1
...
@@ -10,17 +10,21 @@ class ImageTemplateViewSet(ModelViewSet):
...
@@ -10,17 +10,21 @@ class ImageTemplateViewSet(ModelViewSet):
queryset
=
ImageTemplate
.
objects
.
all
()
queryset
=
ImageTemplate
.
objects
.
all
()
def
create
(
self
,
request
):
def
create
(
self
,
request
):
# TODO: Check the permissions to create template and using the flavors and leases
serializer
=
ImageTemplateModelSerializer
(
data
=
request
.
data
)
serializer
=
ImageTemplateModelSerializer
(
data
=
request
.
data
)
serializer
.
is_valid
(
raise_exception
=
True
)
serializer
.
is_valid
(
raise_exception
=
True
)
data
=
serializer
.
validated_data
data
=
serializer
.
validated_data
new_template
=
ImageTemplate
.
create
(
new_template
=
ImageTemplate
.
create
(
name
=
data
[
"name"
],
name
=
data
[
"name"
],
description
=
data
[
"description"
],
description
=
data
[
"description"
],
access_protocol
=
data
[
"access"
],
system_type
=
data
[
"system"
],
distro
=
data
[
"distro"
],
created_by
=
request
.
user
,
created_by
=
request
.
user
,
image
=
data
[
"image"
],
image
=
data
[
"image"
],
lease
=
data
[
"lease"
],
lease
=
data
[
"lease"
],
flavor
=
data
[
"flavor"
],
flavor
=
data
[
"flavor"
],
type
=
"
U
"
type
=
"
IMAGE
"
)
)
serializer
=
ImageTemplateModelSerializer
(
instance
=
new_template
)
serializer
=
ImageTemplateModelSerializer
(
instance
=
new_template
)
return
Response
(
serializer
.
data
)
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