Skip to content

Commit 65b07e1

Browse files
Report functionality (#1666)
1 parent 1eaa3d6 commit 65b07e1

File tree

4 files changed

+31
-8
lines changed

4 files changed

+31
-8
lines changed

website/forms.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,9 @@ class HuntForm (forms.Form):
2222
end_date = forms.DateTimeField(widget=forms.DateTimeInput(attrs={'class': 'col-sm-6', 'readonly' : True}),label='', required=False)
2323

2424
class CaptchaForm(forms.Form):
25-
captcha = CaptchaField()
25+
captcha = CaptchaField()
26+
27+
class QuickIssueForm(forms.Form):
28+
url = forms.CharField()
29+
label = forms.CharField()
30+
description = forms.CharField()

website/templates/_report_widget.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<div class="bug-container flex flex-col p-5 px-7 bg-[#FFC8C485] m-1 w-[100%] h-[300px] rounded-[2.5rem] border-[#FF545433] border-[3px]">
22

3-
<form class="h-full flex flex-col gap-[0.9rem]">
3+
<form class="h-full flex flex-col gap-[0.9rem]" action="" method="post">
44

5+
{% csrf_token %}
56

67
<div class="font-['Barlow_Semi_Condensed'] font-semibold text-[#b10909] text-5xl text-center mb-1">REPORT AN ISSUE</div>
78

8-
<input type="text" id="first_name" class="bg-white text-[#4C4C4C] placeholder:text-xl rounded-full block w-full p-[0.4rem] px-4 font-semibold outline-none" placeholder="Domain URL" required>
9+
<input type="text" id="first_name" name="url" class="bg-white text-[#4C4C4C] placeholder:text-xl rounded-full block w-full p-[0.4rem] px-4 font-semibold outline-none" placeholder="Domain URL" required>
910

10-
<select class="bg-white text-[#4C4C4C] text-2xl rounded-full block w-full p-2 px-3 font-semibold outline-none border-r-8 border-r-white cursor-pointer">
11+
<select class="bg-white text-[#4C4C4C] text-2xl rounded-full block w-full p-2 px-3 font-semibold outline-none border-r-8 border-r-white cursor-pointer" name="label">
1112
<option value="0" selected="selected">General</option>
1213
<option value="1">Number error</option>
1314
<option value="2">Functional</option>
@@ -21,10 +22,10 @@
2122

2223
<div>
2324
<label class="bg-trans text-[#303030] text-[1.4rem] rounded-full block w-full px-2 font-semibold outline-none m-0 mb-0 mt-[-2px]"> Attach Screenshots: </label>
24-
<input type="file" id="screenshot" class="bg-white text-[#4C4C4C] text-xl rounded-lg block w-full p-2 px-2 font-semibold outline-none" multiple required>
25+
<input type="file" id="screenshot" class="bg-white text-[#4C4C4C] text-xl rounded-lg block w-full p-2 px-2 font-semibold outline-none" multiple>
2526
</div>
2627

27-
<textarea type="text" id="first_name" class="bg-white text-[#4C4C4C] text-xl rounded-[1rem] w-full p-2 px-3 font-semibold outline-none h-full flex flex-col resize-none" placeholder="Description" required></textarea>
28+
<textarea type="text" id="first_name" class="bg-white text-[#4C4C4C] text-xl rounded-[1rem] w-full p-2 px-3 font-semibold outline-none h-full flex flex-col resize-none" placeholder="Description" name="description" required></textarea>
2829

2930
<div class="flex flex-row gap-[0.7rem]">
3031
<button id="expand" class="font-['Barlow'] font-bold text-[#b10909] text-3xl text-center bg-[#FF9090] p-2 rounded-full border border-1 border-[#CB3838] w-[4rem]"><i class="fa fa-angle-down" aria-hidden="true"></i></button>

website/templates/report.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ <h3 class="text-xl font-bold leading-none text-red-500">Latest Issues</h3>
180180
>
181181
<div class="mt-2">
182182
<select
183-
name="label"
183+
name="label" id="labelSelect"
184184
required data-intro="Categorize the bug." data-step="3"
185185
class="flex w-full placeholder:text-xl rounded-md border-0 py-4 px-3 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-inset"
186186
>
@@ -536,5 +536,15 @@ <h2 class="text-2xl font-semibold leading-7 text-gray-900">
536536
}
537537

538538

539+
document.addEventListener("DOMContentLoaded", function() {
540+
// Get the value from the URL parameter
541+
var labelParam = new URLSearchParams(window.location.search).get("label");
542+
543+
// Set the selected option based on the parameter
544+
if (labelParam !== null) {
545+
document.getElementById("labelSelect").value = labelParam;
546+
}
547+
});
548+
539549
</script>
540550
{% endblock %}

website/views.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
Company,
8080
IssueScreenshot
8181
)
82-
from .forms import FormInviteFriend, UserProfileForm, HuntForm, CaptchaForm
82+
from .forms import FormInviteFriend, UserProfileForm, HuntForm, CaptchaForm, QuickIssueForm
8383

8484
from decimal import Decimal
8585
from django.conf import settings
@@ -181,6 +181,13 @@ def index(request, template="index.html"):
181181

182182
#@cache_page(60 * 60 * 24)
183183
def newhome(request, template="new_home.html"):
184+
185+
if request.method == 'POST':
186+
form = QuickIssueForm(request.POST)
187+
if form.is_valid():
188+
query_string = urllib.parse.urlencode(form.cleaned_data)
189+
redirect_url = f'/report/?{query_string}'
190+
return HttpResponseRedirect(redirect_url)
184191

185192
try:
186193
if not EmailAddress.objects.get(email=request.user.email).verified:

0 commit comments

Comments
 (0)