• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

gcivil-nyu-org / wed-fall24-team4 / #627816045

06 Nov 2024 02:07AM UTC coverage: 86.893%. First build
#627816045

Pull #132

travis-ci

Pull Request #132: Added Reporting functionality

165 of 175 new or added lines in 10 files covered. (94.29%)

716 of 824 relevant lines covered (86.89%)

0.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.45
/reporting/views.py
1
from django.shortcuts import render, redirect
1✔
2
from .forms import ReportForm
1✔
3
from .models import Report
1✔
4
from django.contrib.auth.decorators import login_required
1✔
5
from django.utils import timezone
1✔
6
from datetime import timedelta
1✔
7

8

9
@login_required
1✔
10
def reporting_form(request):
1✔
11
    if request.method == "POST":
1✔
12
        current_time = timezone.now()
1✔
13
        form = ReportForm(request.POST)
1✔
14
        if form.is_valid():
1✔
15
            station = form.cleaned_data["station"]
1✔
16
            infrastructure = form.cleaned_data["infrastructure"]
1✔
17
            status = form.cleaned_data["status"]
1✔
18

19
            # avoid spam by the same user
20
            latest_report_by_sender = (
1✔
21
                Report.objects.filter(sender=request.user)
22
                .order_by("-timestamp")
23
                .first()
24
            )
25
            if (
1✔
26
                latest_report_by_sender
27
                and current_time - latest_report_by_sender.timestamp
28
                <= timedelta(minutes=20)
29
            ):
NEW
30
                return redirect("maps:map_view")
×
31

32
            Report.objects.create(
1✔
33
                sender=request.user,
34
                station=station,
35
                infrastructure=infrastructure,
36
                status=status,
37
            )
38
            return redirect("maps:map_view")
1✔
39
    else:
40
        form = ReportForm()
1✔
41

42
    return render(request, "reporting/reporting_form.html", {"form": form})
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc