Skip to content

Commit e64706f

Browse files
committed
Fix API key request form UI
Signed-off-by: Tushar Goel <[email protected]>
1 parent 469d20e commit e64706f

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

vulnerabilities/forms.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,22 @@ class Meta:
4848

4949
def __init__(self, *args, **kwargs):
5050
super(ApiUserCreationForm, self).__init__(*args, **kwargs)
51-
self.fields["email"].required = True
51+
email_field = self.fields["email"]
52+
first_name_field = self.fields["first_name"]
53+
last_name_field = self.fields["last_name"]
54+
email_field.required = True
55+
email_field.label = "Email"
56+
email_field.widget.attrs["class"] = "input"
57+
email_field.widget.attrs["style"] = "width: 50%"
58+
email_field.widget.attrs["placeholder"] = "e.g. [email protected]"
59+
first_name_field.label = "First Name"
60+
first_name_field.widget.attrs["class"] = "input"
61+
first_name_field.widget.attrs["style"] = "width: 50%"
62+
first_name_field.widget.attrs["placeholder"] = "e.g. Jon"
63+
last_name_field.label = "Last Name"
64+
last_name_field.widget.attrs["class"] = "input"
65+
last_name_field.widget.attrs["style"] = "width: 50%"
66+
last_name_field.widget.attrs["placeholder"] = "e.g. Doe"
5267

5368
def save(self, commit=True):
5469
return ApiUser.objects.create_api_user(

vulnerabilities/templates/api_user_creation_form.html

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,33 @@
1111
</div>
1212
</article>
1313
{% endfor %}
14-
{% block title %}
15-
VulnerableCode API key request
16-
{% endblock %}
14+
<div id="form-errors" class="message is-danger {% if not form.errors %}is-hidden{% endif %}">
15+
{% for field_name, errors in form.errors.items %}
16+
<div class="message-body">
17+
{{ errors }}
18+
</div>
19+
{% endfor %}
20+
</div>
21+
<h2 class="subtitle mb-0 pt-2 mb-2">
22+
<b>VulnerableCode API key request</b>
23+
</h2>
24+
25+
<section class="ml-2 mt-3 pr-4 pt-4 pl-4 pb-4 has-background-light has-border-radius">
26+
Please provide your <b>email address</b> and we will email you the <b>API token</b>.
27+
</section>
28+
1729
<br/>
1830
<form action = "" method = "post">
1931
{% csrf_token %}
20-
{{form|crispy }}
21-
<br/>
22-
<input class="button is-link" type="submit" value="Submit">
32+
{% for field in form %}
33+
<div class="field mt-2">
34+
<label class="label" for="{{ form.name.id_for_label }}">{{ field.label }}</label>
35+
<div class="control">
36+
{{ field }}
37+
</div>
38+
</div>
39+
{% endfor %}
40+
<input class="button is-link mt-5" type="submit" value="Request my API Key">
2341
</form>
2442
</section>
2543
{% endblock %}

0 commit comments

Comments
 (0)