Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
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
4d416e40
authored
Nov 11, 2017
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common, dashboard, network, request: make Form and ModelForm backward compatible
parent
330ddc77
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
29 deletions
+59
-29
circle/common/forms.py
+28
-0
circle/dashboard/forms.py
+27
-27
circle/network/forms.py
+2
-1
circle/request/forms.py
+2
-1
No files found.
circle/common/forms.py
0 → 100644
View file @
4d416e40
# Copyright 2017 Budapest University of Technology and Economics (BME IK)
#
# This file is part of CIRCLE Cloud.
#
# CIRCLE is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# CIRCLE is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from
django
import
forms
class
Form
(
forms
.
Form
):
""" Backward compatible Form """
use_required_attribute
=
False
class
ModelForm
(
forms
.
ModelForm
):
""" Backward compatible ModelForm """
use_required_attribute
=
False
circle/dashboard/forms.py
View file @
4d416e40
...
@@ -22,7 +22,6 @@ from urlparse import urlparse
...
@@ -22,7 +22,6 @@ from urlparse import urlparse
import
pyotp
import
pyotp
from
django.forms
import
ModelForm
from
django.contrib.auth.forms
import
(
from
django.contrib.auth.forms
import
(
AuthenticationForm
,
PasswordResetForm
,
SetPasswordForm
,
AuthenticationForm
,
PasswordResetForm
,
SetPasswordForm
,
PasswordChangeForm
,
PasswordChangeForm
,
...
@@ -65,6 +64,7 @@ from django.utils.translation import string_concat
...
@@ -65,6 +64,7 @@ from django.utils.translation import string_concat
from
.validators
import
domain_validator
from
.validators
import
domain_validator
from
dashboard.models
import
ConnectCommand
,
create_profile
from
dashboard.models
import
ConnectCommand
,
create_profile
from
common.forms
import
Form
,
ModelForm
LANGUAGES_WITH_CODE
=
((
l
[
0
],
string_concat
(
l
[
1
],
" ("
,
l
[
0
],
")"
))
LANGUAGES_WITH_CODE
=
((
l
[
0
],
string_concat
(
l
[
1
],
" ("
,
l
[
0
],
")"
))
...
@@ -87,7 +87,7 @@ class NoFormTagMixin(object):
...
@@ -87,7 +87,7 @@ class NoFormTagMixin(object):
return
helper
return
helper
class
OperationForm
(
NoFormTagMixin
,
forms
.
Form
):
class
OperationForm
(
NoFormTagMixin
,
Form
):
pass
pass
...
@@ -108,7 +108,7 @@ class VmSaveForm(OperationForm):
...
@@ -108,7 +108,7 @@ class VmSaveForm(OperationForm):
"for updating a template."
))
"for updating a template."
))
class
VmCustomizeForm
(
forms
.
Form
):
class
VmCustomizeForm
(
Form
):
name
=
forms
.
CharField
(
widget
=
forms
.
TextInput
(
attrs
=
{
name
=
forms
.
CharField
(
widget
=
forms
.
TextInput
(
attrs
=
{
'class'
:
"form-control"
,
'class'
:
"form-control"
,
'style'
:
"max-width: 350px"
,
'style'
:
"max-width: 350px"
,
...
@@ -213,7 +213,7 @@ class VmCustomizeForm(forms.Form):
...
@@ -213,7 +213,7 @@ class VmCustomizeForm(forms.Form):
del
self
.
cleaned_data
[
name
]
del
self
.
cleaned_data
[
name
]
class
GroupCreateForm
(
NoFormTagMixin
,
forms
.
ModelForm
):
class
GroupCreateForm
(
NoFormTagMixin
,
ModelForm
):
description
=
forms
.
CharField
(
label
=
_
(
"Description"
),
required
=
False
,
description
=
forms
.
CharField
(
label
=
_
(
"Description"
),
required
=
False
,
widget
=
forms
.
Textarea
(
attrs
=
{
'rows'
:
3
}))
widget
=
forms
.
Textarea
(
attrs
=
{
'rows'
:
3
}))
...
@@ -261,7 +261,7 @@ class GroupCreateForm(NoFormTagMixin, forms.ModelForm):
...
@@ -261,7 +261,7 @@ class GroupCreateForm(NoFormTagMixin, forms.ModelForm):
fields
=
(
'name'
,
)
fields
=
(
'name'
,
)
class
GroupProfileUpdateForm
(
NoFormTagMixin
,
forms
.
ModelForm
):
class
GroupProfileUpdateForm
(
NoFormTagMixin
,
ModelForm
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
new_groups
=
kwargs
.
pop
(
'new_groups'
,
None
)
new_groups
=
kwargs
.
pop
(
'new_groups'
,
None
)
...
@@ -296,7 +296,7 @@ class GroupProfileUpdateForm(NoFormTagMixin, forms.ModelForm):
...
@@ -296,7 +296,7 @@ class GroupProfileUpdateForm(NoFormTagMixin, forms.ModelForm):
fields
=
(
'description'
,
'org_id'
)
fields
=
(
'description'
,
'org_id'
)
class
HostForm
(
NoFormTagMixin
,
forms
.
ModelForm
):
class
HostForm
(
NoFormTagMixin
,
ModelForm
):
def
setowner
(
self
,
user
):
def
setowner
(
self
,
user
):
self
.
instance
.
owner
=
user
self
.
instance
.
owner
=
user
...
@@ -369,7 +369,7 @@ class HostForm(NoFormTagMixin, forms.ModelForm):
...
@@ -369,7 +369,7 @@ class HostForm(NoFormTagMixin, forms.ModelForm):
fields
=
[
'hostname'
,
'vlan'
,
'mac'
,
'ipv4'
,
]
fields
=
[
'hostname'
,
'vlan'
,
'mac'
,
'ipv4'
,
]
class
NodeForm
(
forms
.
ModelForm
):
class
NodeForm
(
ModelForm
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
NodeForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
NodeForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
...
@@ -459,7 +459,7 @@ class NodeForm(forms.ModelForm):
...
@@ -459,7 +459,7 @@ class NodeForm(forms.ModelForm):
fields
=
[
'name'
,
'priority'
,
'enabled'
,
]
fields
=
[
'name'
,
'priority'
,
'enabled'
,
]
class
TemplateForm
(
forms
.
ModelForm
):
class
TemplateForm
(
ModelForm
):
networks
=
forms
.
ModelMultipleChoiceField
(
networks
=
forms
.
ModelMultipleChoiceField
(
queryset
=
None
,
required
=
False
,
label
=
_
(
"Networks"
))
queryset
=
None
,
required
=
False
,
label
=
_
(
"Networks"
))
...
@@ -610,7 +610,7 @@ class TemplateForm(forms.ModelForm):
...
@@ -610,7 +610,7 @@ class TemplateForm(forms.ModelForm):
}
}
class
LeaseForm
(
forms
.
ModelForm
):
class
LeaseForm
(
ModelForm
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
LeaseForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
LeaseForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
...
@@ -765,7 +765,7 @@ class VmRenewForm(OperationForm):
...
@@ -765,7 +765,7 @@ class VmRenewForm(OperationForm):
self
.
fields
[
'save'
]
.
widget
=
HiddenInput
()
self
.
fields
[
'save'
]
.
widget
=
HiddenInput
()
class
VmMigrateForm
(
forms
.
Form
):
class
VmMigrateForm
(
Form
):
live_migration
=
forms
.
BooleanField
(
live_migration
=
forms
.
BooleanField
(
required
=
False
,
initial
=
True
,
label
=
_
(
"Live migration"
),
required
=
False
,
initial
=
True
,
label
=
_
(
"Live migration"
),
help_text
=
_
(
help_text
=
_
(
...
@@ -1191,7 +1191,7 @@ class WorkingBaseInput(BaseInput):
...
@@ -1191,7 +1191,7 @@ class WorkingBaseInput(BaseInput):
super
(
WorkingBaseInput
,
self
)
.
__init__
(
name
,
value
,
**
kwargs
)
super
(
WorkingBaseInput
,
self
)
.
__init__
(
name
,
value
,
**
kwargs
)
class
TraitForm
(
forms
.
ModelForm
):
class
TraitForm
(
ModelForm
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
TraitForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
TraitForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
...
@@ -1216,7 +1216,7 @@ class TraitForm(forms.ModelForm):
...
@@ -1216,7 +1216,7 @@ class TraitForm(forms.ModelForm):
fields
=
[
'name'
]
fields
=
[
'name'
]
class
MyProfileForm
(
forms
.
ModelForm
):
class
MyProfileForm
(
ModelForm
):
preferred_language
=
forms
.
ChoiceField
(
preferred_language
=
forms
.
ChoiceField
(
LANGUAGES_WITH_CODE
,
LANGUAGES_WITH_CODE
,
label
=
_
(
"Preferred language"
),
label
=
_
(
"Preferred language"
),
...
@@ -1238,7 +1238,7 @@ class MyProfileForm(forms.ModelForm):
...
@@ -1238,7 +1238,7 @@ class MyProfileForm(forms.ModelForm):
return
value
return
value
class
UnsubscribeForm
(
forms
.
ModelForm
):
class
UnsubscribeForm
(
ModelForm
):
class
Meta
:
class
Meta
:
fields
=
(
'email_notifications'
,
)
fields
=
(
'email_notifications'
,
)
...
@@ -1295,7 +1295,7 @@ class UserCreationForm(OrgUserCreationForm):
...
@@ -1295,7 +1295,7 @@ class UserCreationForm(OrgUserCreationForm):
return
user
return
user
class
UserEditForm
(
forms
.
ModelForm
):
class
UserEditForm
(
ModelForm
):
instance_limit
=
forms
.
IntegerField
(
instance_limit
=
forms
.
IntegerField
(
label
=
_
(
'Instance limit'
),
label
=
_
(
'Instance limit'
),
min_value
=
0
,
widget
=
NumberInput
)
min_value
=
0
,
widget
=
NumberInput
)
...
@@ -1332,7 +1332,7 @@ class UserEditForm(forms.ModelForm):
...
@@ -1332,7 +1332,7 @@ class UserEditForm(forms.ModelForm):
return
helper
return
helper
class
AclUserOrGroupAddForm
(
forms
.
Form
):
class
AclUserOrGroupAddForm
(
Form
):
name
=
forms
.
CharField
(
name
=
forms
.
CharField
(
widget
=
autocomplete
.
ListSelect2
(
widget
=
autocomplete
.
ListSelect2
(
url
=
'autocomplete.acl.user-group'
,
url
=
'autocomplete.acl.user-group'
,
...
@@ -1341,7 +1341,7 @@ class AclUserOrGroupAddForm(forms.Form):
...
@@ -1341,7 +1341,7 @@ class AclUserOrGroupAddForm(forms.Form):
'data-placeholder'
:
_
(
"Name of group or user"
)}))
'data-placeholder'
:
_
(
"Name of group or user"
)}))
class
TransferOwnershipForm
(
forms
.
Form
):
class
TransferOwnershipForm
(
Form
):
name
=
forms
.
CharField
(
name
=
forms
.
CharField
(
widget
=
autocomplete
.
ListSelect2
(
widget
=
autocomplete
.
ListSelect2
(
url
=
'autocomplete.acl.user'
,
url
=
'autocomplete.acl.user'
,
...
@@ -1351,7 +1351,7 @@ class TransferOwnershipForm(forms.Form):
...
@@ -1351,7 +1351,7 @@ class TransferOwnershipForm(forms.Form):
label
=
_
(
"E-mail address or identifier of user"
))
label
=
_
(
"E-mail address or identifier of user"
))
class
AddGroupMemberForm
(
forms
.
Form
):
class
AddGroupMemberForm
(
Form
):
new_member
=
forms
.
CharField
(
new_member
=
forms
.
CharField
(
widget
=
autocomplete
.
ListSelect2
(
widget
=
autocomplete
.
ListSelect2
(
url
=
'autocomplete.acl.user'
,
url
=
'autocomplete.acl.user'
,
...
@@ -1361,7 +1361,7 @@ class AddGroupMemberForm(forms.Form):
...
@@ -1361,7 +1361,7 @@ class AddGroupMemberForm(forms.Form):
label
=
_
(
"E-mail address or identifier of user"
))
label
=
_
(
"E-mail address or identifier of user"
))
class
UserKeyForm
(
forms
.
ModelForm
):
class
UserKeyForm
(
ModelForm
):
name
=
forms
.
CharField
(
required
=
True
,
label
=
_
(
'Name'
))
name
=
forms
.
CharField
(
required
=
True
,
label
=
_
(
'Name'
))
key
=
forms
.
CharField
(
key
=
forms
.
CharField
(
label
=
_
(
'Key'
),
required
=
True
,
label
=
_
(
'Key'
),
required
=
True
,
...
@@ -1388,7 +1388,7 @@ class UserKeyForm(forms.ModelForm):
...
@@ -1388,7 +1388,7 @@ class UserKeyForm(forms.ModelForm):
return
super
(
UserKeyForm
,
self
)
.
clean
()
return
super
(
UserKeyForm
,
self
)
.
clean
()
class
ConnectCommandForm
(
forms
.
ModelForm
):
class
ConnectCommandForm
(
ModelForm
):
class
Meta
:
class
Meta
:
fields
=
(
'name'
,
'access_method'
,
'template'
)
fields
=
(
'name'
,
'access_method'
,
'template'
)
model
=
ConnectCommand
model
=
ConnectCommand
...
@@ -1404,7 +1404,7 @@ class ConnectCommandForm(forms.ModelForm):
...
@@ -1404,7 +1404,7 @@ class ConnectCommandForm(forms.ModelForm):
return
super
(
ConnectCommandForm
,
self
)
.
clean
()
return
super
(
ConnectCommandForm
,
self
)
.
clean
()
class
TraitsForm
(
forms
.
ModelForm
):
class
TraitsForm
(
ModelForm
):
class
Meta
:
class
Meta
:
model
=
Instance
model
=
Instance
...
@@ -1421,7 +1421,7 @@ class TraitsForm(forms.ModelForm):
...
@@ -1421,7 +1421,7 @@ class TraitsForm(forms.ModelForm):
return
helper
return
helper
class
RawDataForm
(
forms
.
ModelForm
):
class
RawDataForm
(
ModelForm
):
raw_data
=
forms
.
CharField
(
validators
=
[
domain_validator
],
raw_data
=
forms
.
CharField
(
validators
=
[
domain_validator
],
widget
=
forms
.
Textarea
(
attrs
=
{
'rows'
:
5
}),
widget
=
forms
.
Textarea
(
attrs
=
{
'rows'
:
5
}),
required
=
False
)
required
=
False
)
...
@@ -1442,7 +1442,7 @@ class RawDataForm(forms.ModelForm):
...
@@ -1442,7 +1442,7 @@ class RawDataForm(forms.ModelForm):
return
helper
return
helper
class
GroupPermissionForm
(
forms
.
ModelForm
):
class
GroupPermissionForm
(
ModelForm
):
permissions
=
forms
.
ModelMultipleChoiceField
(
permissions
=
forms
.
ModelMultipleChoiceField
(
queryset
=
None
,
queryset
=
None
,
widget
=
FilteredSelectMultiple
(
_
(
"permissions"
),
is_stacked
=
False
)
widget
=
FilteredSelectMultiple
(
_
(
"permissions"
),
is_stacked
=
False
)
...
@@ -1504,7 +1504,7 @@ class GroupPermissionForm(forms.ModelForm):
...
@@ -1504,7 +1504,7 @@ class GroupPermissionForm(forms.ModelForm):
return
helper
return
helper
class
VmResourcesForm
(
forms
.
ModelForm
):
class
VmResourcesForm
(
ModelForm
):
num_cores
=
forms
.
IntegerField
(
widget
=
forms
.
NumberInput
(
attrs
=
{
num_cores
=
forms
.
IntegerField
(
widget
=
forms
.
NumberInput
(
attrs
=
{
'class'
:
"form-control input-tags cpu-count-input"
,
'class'
:
"form-control input-tags cpu-count-input"
,
'min'
:
1
,
'min'
:
1
,
...
@@ -1549,7 +1549,7 @@ vm_search_choices = (
...
@@ -1549,7 +1549,7 @@ vm_search_choices = (
)
)
class
VmListSearchForm
(
forms
.
Form
):
class
VmListSearchForm
(
Form
):
use_required_attribute
=
False
use_required_attribute
=
False
s
=
forms
.
CharField
(
widget
=
forms
.
TextInput
(
attrs
=
{
s
=
forms
.
CharField
(
widget
=
forms
.
TextInput
(
attrs
=
{
...
@@ -1575,7 +1575,7 @@ class VmListSearchForm(forms.Form):
...
@@ -1575,7 +1575,7 @@ class VmListSearchForm(forms.Form):
self
.
data
=
data
self
.
data
=
data
class
TemplateListSearchForm
(
forms
.
Form
):
class
TemplateListSearchForm
(
Form
):
use_required_attribute
=
False
use_required_attribute
=
False
s
=
forms
.
CharField
(
widget
=
forms
.
TextInput
(
attrs
=
{
s
=
forms
.
CharField
(
widget
=
forms
.
TextInput
(
attrs
=
{
...
@@ -1596,7 +1596,7 @@ class TemplateListSearchForm(forms.Form):
...
@@ -1596,7 +1596,7 @@ class TemplateListSearchForm(forms.Form):
self
.
data
=
data
self
.
data
=
data
class
UserListSearchForm
(
forms
.
Form
):
class
UserListSearchForm
(
Form
):
use_required_attribute
=
False
use_required_attribute
=
False
s
=
forms
.
CharField
(
widget
=
forms
.
TextInput
(
attrs
=
{
s
=
forms
.
CharField
(
widget
=
forms
.
TextInput
(
attrs
=
{
...
@@ -1678,7 +1678,7 @@ class TwoFactorForm(ModelForm):
...
@@ -1678,7 +1678,7 @@ class TwoFactorForm(ModelForm):
fields
=
[
"two_factor_secret"
,
]
fields
=
[
"two_factor_secret"
,
]
class
TwoFactorConfirmationForm
(
forms
.
Form
):
class
TwoFactorConfirmationForm
(
Form
):
confirmation_code
=
forms
.
CharField
(
confirmation_code
=
forms
.
CharField
(
label
=
_
(
'Two-factor authentication passcode'
),
label
=
_
(
'Two-factor authentication passcode'
),
help_text
=
_
(
"Get the code from your authenticator."
),
help_text
=
_
(
"Get the code from your authenticator."
),
...
...
circle/network/forms.py
View file @
4d416e40
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License along
# You should have received a copy of the GNU General Public License along
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from
django.forms
import
ModelForm
,
widgets
from
django.forms
import
widgets
from
django.core.urlresolvers
import
reverse_lazy
from
django.core.urlresolvers
import
reverse_lazy
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
...
@@ -27,6 +27,7 @@ from firewall.models import (
...
@@ -27,6 +27,7 @@ from firewall.models import (
Host
,
Vlan
,
Domain
,
Group
,
Record
,
BlacklistItem
,
Rule
,
VlanGroup
,
Host
,
Vlan
,
Domain
,
Group
,
Record
,
BlacklistItem
,
Rule
,
VlanGroup
,
SwitchPort
,
Firewall
SwitchPort
,
Firewall
)
)
from
common.forms
import
ModelForm
class
LinkButton
(
BaseInput
):
class
LinkButton
(
BaseInput
):
...
...
circle/request/forms.py
View file @
4d416e40
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License along
# You should have received a copy of the GNU General Public License along
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from
django.forms
import
(
from
django.forms
import
(
Model
Form
,
ModelChoiceField
,
ChoiceField
,
Form
,
CharField
,
RadioSelect
,
Model
ChoiceField
,
ChoiceField
,
CharField
,
RadioSelect
,
Textarea
,
ValidationError
Textarea
,
ValidationError
)
)
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
...
@@ -30,6 +30,7 @@ from request.models import (
...
@@ -30,6 +30,7 @@ from request.models import (
LeaseType
,
TemplateAccessType
,
TemplateAccessAction
,
LeaseType
,
TemplateAccessType
,
TemplateAccessAction
,
)
)
from
dashboard.forms
import
VmResourcesForm
from
dashboard.forms
import
VmResourcesForm
from
common.forms
import
Form
,
ModelForm
class
LeaseTypeForm
(
ModelForm
):
class
LeaseTypeForm
(
ModelForm
):
...
...
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