Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report functionality #1666

Merged
merged 10 commits into from
Jan 7, 2024
7 changes: 6 additions & 1 deletion website/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ class HuntForm (forms.Form):
end_date = forms.DateTimeField(widget=forms.DateTimeInput(attrs={'class': 'col-sm-6', 'readonly' : True}),label='', required=False)

class CaptchaForm(forms.Form):
captcha = CaptchaField()
captcha = CaptchaField()

class QuickIssueForm(forms.Form):
url = forms.CharField()
label = forms.CharField()
description = forms.CharField()
11 changes: 6 additions & 5 deletions website/templates/_report_widget.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<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]">

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

{% csrf_token %}

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

<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>
<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>

<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">
<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">
<option value="0" selected="selected">General</option>
<option value="1">Number error</option>
<option value="2">Functional</option>
Expand All @@ -21,10 +22,10 @@

<div>
<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>
<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>
<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>
</div>

<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>
<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>

<div class="flex flex-row gap-[0.7rem]">
<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>
Expand Down
12 changes: 11 additions & 1 deletion website/templates/report.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ <h3 class="text-xl font-bold leading-none text-red-500">Latest Issues</h3>
>
<div class="mt-2">
<select
name="label"
name="label" id="labelSelect"
required data-intro="Categorize the bug." data-step="3"
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"
>
Expand Down Expand Up @@ -536,5 +536,15 @@ <h2 class="text-2xl font-semibold leading-7 text-gray-900">
}


document.addEventListener("DOMContentLoaded", function() {
// Get the value from the URL parameter
var labelParam = new URLSearchParams(window.location.search).get("label");

// Set the selected option based on the parameter
if (labelParam !== null) {
document.getElementById("labelSelect").value = labelParam;
}
});

</script>
{% endblock %}
9 changes: 8 additions & 1 deletion website/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
Company,
IssueScreenshot
)
from .forms import FormInviteFriend, UserProfileForm, HuntForm, CaptchaForm
from .forms import FormInviteFriend, UserProfileForm, HuntForm, CaptchaForm, QuickIssueForm

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

#@cache_page(60 * 60 * 24)
def newhome(request, template="new_home.html"):

if request.method == 'POST':
form = QuickIssueForm(request.POST)
if form.is_valid():
query_string = urllib.parse.urlencode(form.cleaned_data)
redirect_url = f'/report/?{query_string}'
return HttpResponseRedirect(redirect_url)

try:
if not EmailAddress.objects.get(email=request.user.email).verified:
Expand Down
Loading