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,6 +595,10 @@ class OrderConfirmationView(DetailView, FormView):
|
|||
# Check ssh public key and then proceed
|
||||
form = self.get_form()
|
||||
required = 'add_ssh' in self.request.POST
|
||||
|
||||
# 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():
|
||||
|
|
Loading…
Reference in a new issue