Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
3b4b53ee
authored
Jan 02, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: create lease
parent
699d1f07
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
8 deletions
+47
-8
circle/dashboard/forms.py
+8
-4
circle/dashboard/templates/dashboard/lease-create.html
+23
-0
circle/dashboard/templates/dashboard/lease-edit.html
+2
-2
circle/dashboard/urls.py
+3
-1
circle/dashboard/views.py
+11
-1
No files found.
circle/dashboard/forms.py
View file @
3b4b53ee
...
...
@@ -446,9 +446,13 @@ class LeaseForm(forms.ModelForm):
intervals
=
[
"hours"
,
"days"
,
"weeks"
,
"months"
]
methods
=
[
"suspend"
,
"delete"
]
# feels redundant but these lines are so long
s
=
(
self
.
instance
.
suspend_interval
.
total_seconds
()
if
self
.
instance
.
pk
else
0
)
d
=
(
self
.
instance
.
delete_interval
.
total_seconds
()
if
self
.
instance
.
pk
else
0
)
seconds
=
{
'suspend'
:
s
elf
.
instance
.
suspend_interval
.
total_seconds
()
,
'delete'
:
self
.
instance
.
delete_interval
.
total_seconds
()
'suspend'
:
s
,
'delete'
:
d
}
initial
=
{
'suspend'
:
self
.
get_intervals
(
int
(
seconds
[
'suspend'
])),
...
...
@@ -487,8 +491,8 @@ class LeaseForm(forms.ModelForm):
helper
=
FormHelper
()
helper
.
layout
=
Layout
(
Field
(
'name'
),
Field
(
"suspend_interval_seconds"
,
type
=
"hidden"
),
Field
(
"delete_interval_seconds"
,
type
=
"hidden"
),
Field
(
"suspend_interval_seconds"
,
type
=
"hidden"
,
value
=
"0"
),
Field
(
"delete_interval_seconds"
,
type
=
"hidden"
,
value
=
"0"
),
Div
(
Div
(
HTML
(
_
(
"Suspend in"
)),
...
...
circle/dashboard/templates/dashboard/lease-create.html
0 → 100644
View file @
3b4b53ee
{% extends "dashboard/base.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block content %}
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<a
class=
"pull-right btn btn-default btn-xs"
href=
"{% url "
dashboard
.
views
.
template-list
"
%}"
>
{% trans "Back" %}
</a>
<h3
class=
"no-margin"
><i
class=
"icon-desktop"
></i>
{% trans "Create lease" %}
</h3>
</div>
<div
class=
"panel-body"
>
{% with form=form %}
{% include "display-form-errors.html" %}
{% endwith %}
{% crispy form %}
</div>
</div>
</div>
</div>
{% endblock %}
circle/dashboard/templates/dashboard/lease-edit.html
View file @
3b4b53ee
...
...
@@ -7,8 +7,8 @@
<div
class=
"col-md-12"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<a
class=
"pull-right btn btn-default btn-xs"
href=
"{% url "
dashboard
.
views
.
template-list
"
%}"
>
Back
</a>
<h3
class=
"no-margin"
><i
class=
"icon-desktop"
></i>
Edit lease
</h3>
<a
class=
"pull-right btn btn-default btn-xs"
href=
"{% url "
dashboard
.
views
.
template-list
"
%}"
>
{% trans "Back" %}
</a>
<h3
class=
"no-margin"
><i
class=
"icon-desktop"
></i>
{% trans "Edit lease" %}
</h3>
</div>
<div
class=
"panel-body"
>
{% with form=form %}
...
...
circle/dashboard/urls.py
View file @
3b4b53ee
...
...
@@ -5,7 +5,7 @@ from .views import (
IndexView
,
VmDetailView
,
VmList
,
VmCreate
,
TemplateDetail
,
AclUpdateView
,
VmDelete
,
VmMassDelete
,
vm_activity
,
NodeList
,
NodeDetailView
,
PortDelete
,
TransferOwnershipView
,
TransferOwnershipConfirmView
,
NodeDelete
,
TemplateList
,
LeaseDetail
,
NodeCreate
,
TemplateList
,
LeaseDetail
,
NodeCreate
,
LeaseCreate
,
TemplateCreate
,
)
urlpatterns
=
patterns
(
...
...
@@ -13,6 +13,8 @@ urlpatterns = patterns(
url
(
r'^$'
,
IndexView
.
as_view
(),
name
=
"dashboard.index"
),
url
(
r'^lease/(?P<pk>\d+)/$'
,
LeaseDetail
.
as_view
(),
name
=
"dashboard.views.lease-detail"
),
url
(
r'^lease/create/$'
,
LeaseCreate
.
as_view
(),
name
=
"dashboard.views.lease-create"
),
url
(
r'^template/(?P<pk>\d+)/$'
,
TemplateDetail
.
as_view
(),
name
=
'dashboard.views.template-detail'
),
url
(
r"^template/list/$"
,
TemplateList
.
as_view
(),
...
...
circle/dashboard/views.py
View file @
3b4b53ee
...
...
@@ -15,7 +15,7 @@ from django.shortcuts import redirect, render
from
django.views.decorators.http
import
require_POST
from
django.views.generic.detail
import
SingleObjectMixin
from
django.views.generic
import
(
TemplateView
,
DetailView
,
View
,
DeleteView
,
UpdateView
)
UpdateView
,
CreateView
)
from
django.contrib
import
messages
from
django.utils.translation
import
ugettext
as
_
...
...
@@ -737,6 +737,16 @@ class VmMassDelete(View):
return
redirect
(
next
if
next
else
reverse_lazy
(
'dashboard.index'
))
class
LeaseCreate
(
SuccessMessageMixin
,
CreateView
):
model
=
Lease
form_class
=
LeaseForm
template_name
=
"dashboard/lease-create.html"
success_message
=
_
(
"Successfully created a new lease!"
)
def
get_success_url
(
self
):
return
reverse_lazy
(
"dashboard.views.template-list"
)
class
LeaseDetail
(
SuccessMessageMixin
,
UpdateView
):
model
=
Lease
form_class
=
LeaseForm
...
...
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