Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
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
d9ff14e6
authored
May 22, 2018
by
Szabolcs Gelencser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Save role name instead of it's id
parent
d92716d6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
6 deletions
+26
-6
circle/dashboard/forms.py
+5
-5
circle/vm/migrations/0016_auto_20180522_1515.py
+20
-0
circle/vm/models/common.py
+1
-1
No files found.
circle/dashboard/forms.py
View file @
d9ff14e6
...
...
@@ -574,12 +574,12 @@ class LeaseForm(forms.ModelForm):
if
roles
:
self
.
fields
[
'roles'
]
.
choices
=
(
(
role
.
id
,
role
.
name
)
for
role
in
roles
(
role
.
name
,
role
.
name
)
for
role
in
roles
)
related_roles
=
self
.
instance
.
roles_permitted
.
all
()
self
.
fields
[
'roles'
]
.
initial
=
[
role
.
role_
id
for
role
in
related_roles
role
.
role_
name
for
role
in
related_roles
]
self
.
generate_fields
()
...
...
@@ -650,11 +650,11 @@ class LeaseForm(forms.ModelForm):
self
.
instance
.
suspend_interval
=
suspend_seconds
self
.
instance
.
roles_permitted
.
clear
()
for
role_
id
in
data
[
'roles'
]:
for
role_
name
in
data
[
'roles'
]:
try
:
self
.
instance
.
roles_permitted
.
add
(
Role
.
objects
.
get
(
role_
id
=
role_id
))
self
.
instance
.
roles_permitted
.
add
(
Role
.
objects
.
get
(
role_
name
=
role_name
))
except
Role
.
DoesNotExist
:
self
.
instance
.
roles_permitted
.
create
(
role_
id
=
role_id
)
self
.
instance
.
roles_permitted
.
create
(
role_
name
=
role_name
)
instance
=
super
(
LeaseForm
,
self
)
.
save
(
commit
=
False
)
if
commit
:
...
...
circle/vm/migrations/0016_auto_20180522_1515.py
0 → 100644
View file @
d9ff14e6
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2018-05-22 13:15
from
__future__
import
unicode_literals
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'vm'
,
'0015_auto_20180522_1429'
),
]
operations
=
[
migrations
.
RenameField
(
model_name
=
'role'
,
old_name
=
'role_id'
,
new_name
=
'role_name'
,
),
]
circle/vm/models/common.py
View file @
d9ff14e6
...
...
@@ -65,7 +65,7 @@ class NamedBaseResourceConfig(BaseResourceConfigModel, TimeStampedModel):
class
Role
(
Model
):
role_
id
=
CharField
(
blank
=
False
,
max_length
=
100
,
unique
=
True
)
role_
name
=
CharField
(
blank
=
False
,
max_length
=
100
,
unique
=
True
)
class
Meta
:
app_label
=
'vm'
...
...
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