Skip to content

Commit

Permalink
Refactor DashboardView to filter applications by parsed date without …
Browse files Browse the repository at this point in the history
…ordering
  • Loading branch information
QA2A committed Aug 15, 2024
1 parent dd667f1 commit de7472c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
22 changes: 12 additions & 10 deletions website/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,13 @@
<td>
{% if not application.resume_views %}
{% if application.company.email %}
<a href="#"
hx-post="/api/bounced_email/"
hx-trigger="click"
hx-target="this"
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
onclick="handleBounceReport(this, event, '{{ application.company.email|urlencode }}')"
title="Report Email Bounce">🚫</a>
<a href="#"
hx-post="/api/bounced_email/"
hx-trigger="click"
hx-target="this"
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
onclick="handleBounceReport(this, event, '{{ application.company.email|urlencode }}')"
title="Report Email Bounce">🚫</a>
{% endif %}
{% endif %}
</td>
Expand Down Expand Up @@ -439,17 +439,19 @@
</br>
<script>
function handleBounceReport(element, event, email) {
console.log("Email:", email); // Debugging: check if email is defined
let reason = prompt('Please provide a reason for reporting this email as bounced:');
if (reason) {
console.log("Reason:", reason); // Debugging: check if reason is defined

if (email && reason) {
element.setAttribute('hx-params', `email=${email}&reason=${encodeURIComponent(reason)}`);
} else {
alert("Email or reason is undefined or empty."); // Provide feedback if undefined
event.preventDefault(); // Prevents the form from submitting if no reason is provided
}
}




function copyLink(icon) {
icon.style.color = "yellow";
}
Expand Down
3 changes: 2 additions & 1 deletion website/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,8 @@ def get_queryset(self):
parsed_date = datetime.strptime(selected_date, "%Y-%m-%d")
if is_naive(parsed_date):
parsed_date = make_aware(parsed_date)
applications = applications.filter(date_applied__date=parsed_date.date()).order_by("-created")
applications = applications.filter(date_applied__date=parsed_date.date())
sort_by = "-date_applied"
except ValueError:
pass

Expand Down

0 comments on commit de7472c

Please sign in to comment.