Make public_key form params mandatory only if existing keys do not exist
This commit is contained in:
parent
0cf5e541cc
commit
9ee1b7c124
1 changed files with 6 additions and 2 deletions
|
@ -595,8 +595,12 @@ class OrderConfirmationView(DetailView, FormView):
|
||||||
# Check ssh public key and then proceed
|
# Check ssh public key and then proceed
|
||||||
form = self.get_form()
|
form = self.get_form()
|
||||||
required = 'add_ssh' in self.request.POST
|
required = 'add_ssh' in self.request.POST
|
||||||
form.fields['name'].required = required
|
|
||||||
form.fields['public_key'].required = required
|
# SSH key is required only if the user doesn't have an existing
|
||||||
|
# key
|
||||||
|
if len(get_all_public_keys(self.request.user)) == 0:
|
||||||
|
form.fields['name'].required = required
|
||||||
|
form.fields['public_key'].required = required
|
||||||
if not form.is_valid():
|
if not form.is_valid():
|
||||||
response = {
|
response = {
|
||||||
'status': False,
|
'status': False,
|
||||||
|
|
Loading…
Reference in a new issue