Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
Commit
3122ce02
authored
May 26, 2015
by
Bach Dániel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue-409' into 'master'
Additional form checks for request
✅
Closes #409 See merge request !333
parents
18e18dfa
2f5e9999
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletions
+22
-1
circle/dashboard/templates/display-form-errors.html
+3
-0
circle/request/forms.py
+19
-1
No files found.
circle/dashboard/templates/display-form-errors.html
View file @
3122ce02
...
...
@@ -5,5 +5,8 @@
<div><strong>
{{ field.label }}
</strong>
: {{ field.errors|striptags }}
</div>
{% endif %}
{% endfor %}
{% for error in form.non_field_errors %}
<div>
{{ error|striptags }}
</div>
{% endfor %}
</div>
{% endif %}
circle/request/forms.py
View file @
3122ce02
...
...
@@ -16,7 +16,7 @@
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from
django.forms
import
(
ModelForm
,
ModelChoiceField
,
ChoiceField
,
Form
,
CharField
,
RadioSelect
,
Textarea
,
Textarea
,
ValidationError
)
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.template
import
RequestContext
...
...
@@ -70,6 +70,14 @@ class InitialFromFileMixin(object):
RequestContext
(
request
,
{}),
)
def
clean
(
self
):
cleaned_data
=
super
(
InitialFromFileMixin
,
self
)
.
clean
()
if
cleaned_data
[
'message'
]
.
strip
()
==
self
.
initial
[
'message'
]
.
strip
():
raise
ValidationError
(
_
(
"Fill in the message."
),
code
=
"invalid"
)
return
cleaned_data
class
TemplateRequestForm
(
InitialFromFileMixin
,
Form
):
template
=
ModelChoiceField
(
TemplateAccessType
.
objects
.
all
(),
...
...
@@ -92,3 +100,13 @@ class ResourceRequestForm(InitialFromFileMixin, VmResourcesForm):
message
=
CharField
(
widget
=
Textarea
)
initial_template
=
"request/initials/resources.html"
def
clean
(
self
):
cleaned_data
=
super
(
ResourceRequestForm
,
self
)
.
clean
()
inst
=
self
.
instance
if
(
cleaned_data
[
'ram_size'
]
==
inst
.
ram_size
and
cleaned_data
[
'num_cores'
]
==
inst
.
num_cores
and
int
(
cleaned_data
[
'priority'
])
==
inst
.
priority
):
raise
ValidationError
(
_
(
"You haven't changed any of the resources."
),
code
=
"invalid"
)
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