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
6608d8a8
authored
May 23, 2018
by
Szabolcs Gelencser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix lease creation page
parent
7f6dd7de
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
22 deletions
+52
-22
circle/dashboard/forms.py
+6
-1
circle/dashboard/templates/dashboard/lease-create.html
+38
-1
circle/dashboard/templates/dashboard/lease-edit.html
+0
-18
circle/dashboard/views/template.py
+6
-0
circle/openstack_api/keystone.py
+2
-2
No files found.
circle/dashboard/forms.py
View file @
6608d8a8
...
@@ -577,6 +577,7 @@ class LeaseForm(forms.ModelForm):
...
@@ -577,6 +577,7 @@ class LeaseForm(forms.ModelForm):
(
role
.
name
,
role
.
name
)
for
role
in
roles
(
role
.
name
,
role
.
name
)
for
role
in
roles
)
)
if
self
.
instance
.
id
:
related_roles
=
self
.
instance
.
roles_permitted
.
all
()
related_roles
=
self
.
instance
.
roles_permitted
.
all
()
self
.
fields
[
'roles'
]
.
initial
=
[
self
.
fields
[
'roles'
]
.
initial
=
[
role
.
role_name
for
role
in
related_roles
role
.
role_name
for
role
in
related_roles
...
@@ -649,6 +650,10 @@ class LeaseForm(forms.ModelForm):
...
@@ -649,6 +650,10 @@ class LeaseForm(forms.ModelForm):
self
.
instance
.
delete_interval
=
delete_seconds
self
.
instance
.
delete_interval
=
delete_seconds
self
.
instance
.
suspend_interval
=
suspend_seconds
self
.
instance
.
suspend_interval
=
suspend_seconds
instance
=
super
(
LeaseForm
,
self
)
.
save
(
commit
=
False
)
if
commit
:
instance
.
save
()
self
.
instance
.
roles_permitted
.
clear
()
self
.
instance
.
roles_permitted
.
clear
()
for
role_name
in
data
[
'roles'
]:
for
role_name
in
data
[
'roles'
]:
try
:
try
:
...
@@ -656,9 +661,9 @@ class LeaseForm(forms.ModelForm):
...
@@ -656,9 +661,9 @@ class LeaseForm(forms.ModelForm):
except
Role
.
DoesNotExist
:
except
Role
.
DoesNotExist
:
self
.
instance
.
roles_permitted
.
create
(
role_name
=
role_name
)
self
.
instance
.
roles_permitted
.
create
(
role_name
=
role_name
)
instance
=
super
(
LeaseForm
,
self
)
.
save
(
commit
=
False
)
if
commit
:
if
commit
:
instance
.
save
()
instance
.
save
()
return
instance
return
instance
class
Meta
:
class
Meta
:
...
...
circle/dashboard/templates/dashboard/lease-create.html
View file @
6608d8a8
...
@@ -17,7 +17,44 @@
...
@@ -17,7 +17,44 @@
{% with form=form %}
{% with form=form %}
{% include "display-form-errors.html" %}
{% include "display-form-errors.html" %}
{% endwith %}
{% endwith %}
{% crispy form %}
<form
method=
"post"
>
{% csrf_token %}
<div
class=
"row container-fluid"
>
<div
class=
"col-md-7"
>
{{ form.name|as_crispy_field }}
<label>
Suspend in
</label>
<div
class=
"input-group interval-input"
>
{{ form.suspend_hours }}
<div
class=
"input-group-addon"
>
hours
</div>
{{ form.suspend_days }}
<div
class=
"input-group-addon"
>
days
</div>
{{ form.suspend_weeks }}
<div
class=
"input-group-addon"
>
weeks
</div>
{{ form.suspend_months }}
<div
class=
"input-group-addon"
>
months
</div>
</div>
<label>
Delete in
</label>
<div
class=
"input-group interval-input"
>
{{ form.delete_hours }}
<div
class=
"input-group-addon"
>
hours
</div>
{{ form.delete_days }}
<div
class=
"input-group-addon"
>
days
</div>
{{ form.delete_weeks }}
<div
class=
"input-group-addon"
>
weeks
</div>
{{ form.delete_months }}
<div
class=
"input-group-addon"
>
months
</div>
</div>
</div>
<div
class=
"col-md-5"
>
{{ form.roles }}
</div>
<div
class=
"form-group"
>
<div
class=
"controls "
>
<input
type=
"submit"
name=
"submit"
value=
"Create lease"
class=
"btn btn-primary"
id=
"submit-id-submit"
>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
circle/dashboard/templates/dashboard/lease-edit.html
View file @
6608d8a8
...
@@ -56,22 +56,4 @@
...
@@ -56,22 +56,4 @@
</form>
</form>
</div>
</div>
</div>
</div>
{#
<div
class=
"col-md-5"
>
#}
{#
<div
class=
"panel panel-default"
>
#}
{#
<div
class=
"panel-heading"
>
#}
{#
<h4
class=
"no-margin"
><i
class=
"icon-group"
></i>
{% trans "Manage access" %}
</h4>
#}
{#
</div>
#}
{#
<div
class=
"panel-body"
>
#}
{#
<form
action=
"{% url "
dashboard
.
views
.
lease-acl
"
pk=
object.pk
%}"
method=
"post"
>
#}
{# {% csrf_token %}#}
{##}
{#
<div
class=
"pull-right"
style=
"margin-top: 1em"
>
#}
{#
<button
type=
"submit"
class=
"btn btn-success"
>
{% trans "Save" %}
</button>
#}
{#
</div>
#}
{#
</form>
#}
{#
</div>
#}
{#
</div>
#}
{#
</div>
#}
{% endblock %}
{% endblock %}
circle/dashboard/views/template.py
View file @
6608d8a8
...
@@ -416,6 +416,12 @@ class LeaseCreate(LoginRequiredMixin, PolicyMixin,
...
@@ -416,6 +416,12 @@ class LeaseCreate(LoginRequiredMixin, PolicyMixin,
def
get_success_url
(
self
):
def
get_success_url
(
self
):
return
reverse_lazy
(
"dashboard.views.template-list"
)
return
reverse_lazy
(
"dashboard.views.template-list"
)
def
get_form_kwargs
(
self
):
from
openstack_api
import
keystone
kwargs
=
super
(
LeaseCreate
,
self
)
.
get_form_kwargs
()
kwargs
[
'roles'
]
=
keystone
.
role_list
(
self
.
request
)
return
kwargs
class
LeaseDetail
(
LoginRequiredMixin
,
PolicyMixin
,
class
LeaseDetail
(
LoginRequiredMixin
,
PolicyMixin
,
SuccessMessageMixin
,
UpdateView
):
SuccessMessageMixin
,
UpdateView
):
...
...
circle/openstack_api/keystone.py
View file @
6608d8a8
...
@@ -713,7 +713,7 @@ def role_delete(request, role_id):
...
@@ -713,7 +713,7 @@ def role_delete(request, role_id):
def
role_list
(
request
,
filters
=
None
):
def
role_list
(
request
,
filters
=
None
):
"""Returns a global list of available roles."""
"""Returns a global list of available roles."""
manager
=
keystoneclient
(
request
)
.
roles
manager
=
keystoneclient
(
request
)
.
roles
#TODO: was admin API call
roles
=
[]
roles
=
[]
kwargs
=
{}
kwargs
=
{}
if
filters
is
not
None
:
if
filters
is
not
None
:
...
@@ -733,7 +733,7 @@ def role_list(request, filters=None):
...
@@ -733,7 +733,7 @@ def role_list(request, filters=None):
def
roles_for_user
(
request
,
user
,
project
=
None
,
domain
=
None
):
def
roles_for_user
(
request
,
user
,
project
=
None
,
domain
=
None
):
"""Returns a list of user roles scoped to a project or domain."""
"""Returns a list of user roles scoped to a project or domain."""
manager
=
keystoneclient
(
request
)
.
roles
manager
=
keystoneclient
(
request
)
.
roles
#TODO: was admin API call
if
VERSIONS
.
active
<
3
:
if
VERSIONS
.
active
<
3
:
return
manager
.
roles_for_user
(
user
,
project
)
return
manager
.
roles_for_user
(
user
,
project
)
else
:
else
:
...
...
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