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

gcivil-nyu-org / team4-wed-spring25 / 262

19 Mar 2025 10:08PM UTC coverage: 95.238% (+5.5%) from 89.7%
262

push

travis-pro

web-flow
Merge pull request #154 from gcivil-nyu-org/develop

Develop

145 of 149 new or added lines in 10 files covered. (97.32%)

3 existing lines in 2 files now uncovered.

320 of 336 relevant lines covered (95.24%)

0.95 hits per line

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

85.48
/parks/views.py
1
from django.shortcuts import render, get_object_or_404, redirect
1✔
2
from django.http import HttpResponse  # noqa: F401  # Ignore "imported but unused"
1✔
3
from .models import DogRunNew, ParkImage
1✔
4

5
import folium
1✔
6
from folium.plugins import MarkerCluster
1✔
7

8
from .utilities import folium_cluster_styling
1✔
9

10
from django.contrib.auth import login
1✔
11
from .forms import RegisterForm
1✔
12

13

14
def register_view(request):
1✔
15
    if request.method == "POST":
1✔
16
        form = RegisterForm(request.POST)
1✔
17
        if form.is_valid():
1✔
18
            user = form.save()  # Save user
1✔
19
            login(request, user)  # Log in the user immediately
1✔
20
            request.session.save()  # Ensure session is updated
1✔
21
            return redirect("home")  # Redirect to homepage
1✔
22
    else:
23
        form = RegisterForm()
1✔
24

25
    return render(request, "parks/register.html", {"form": form})
1✔
26

27

28
def park_list(request):
1✔
29
    parks = DogRunNew.objects.all()  # Fetch all dog runs from the database
1✔
30
    return render(request, "parks/park_list.html", {"parks": parks})
1✔
31

32

33
def home_view(request):
1✔
34
    return render(request, "parks/home.html")
1✔
35

36

37
def map(request):
1✔
38

39
    NYC_LAT_AND_LONG = (40.730610, -73.935242)
1✔
40
    # Create map centered on NYC
41
    m = folium.Map(location=NYC_LAT_AND_LONG, zoom_start=11)
1✔
42

43
    icon_create_function = folium_cluster_styling("rgb(0, 128, 0)")
1✔
44

45
    marker_cluster = MarkerCluster(icon_create_function=icon_create_function).add_to(m)
1✔
46

47
    # Fetch all dog runs from the database
48
    parks = DogRunNew.objects.all()
1✔
49

50
    # Mark every park on the map
51
    for park in parks:
1✔
52
        park_name = park.name
×
53

UNCOV
54
        folium.Marker(
×
55
            location=(park.latitude, park.longitude),
56
            icon=folium.Icon(icon="dog", prefix="fa", color="green"),
57
            popup=folium.Popup(park_name, max_width=200),
58
        ).add_to(marker_cluster)
59

60
    # represent map as html
61
    context = {"map": m._repr_html_()}
1✔
62
    return render(request, "parks/map.html", context)
1✔
63

64

65
def park_and_map(request):
1✔
66
    # Get filter values from GET request
67
    filter_value = request.GET.get("filter", "")
1✔
68
    accessible_value = request.GET.get("accessible", "")
1✔
69

70
    # Fetch all dog runs from the database
71
    parks = DogRunNew.objects.all().order_by("id")
1✔
72

73
    if filter_value:
1✔
74
        parks = parks.filter(dogruns_type__icontains=filter_value)
×
75

76
    if accessible_value:
1✔
77
        parks = parks.filter(accessible=accessible_value)
×
78

79
    NYC_LAT_AND_LONG = (40.712775, -74.005973)
1✔
80

81
    # Create map centered on NYC
82
    # f = folium.Figure(height="100")
83
    m = folium.Map(location=NYC_LAT_AND_LONG, zoom_start=11)
1✔
84

85
    icon_create_function = folium_cluster_styling("rgba(0, 128, 0, 0.7)")
1✔
86
    marker_cluster = MarkerCluster(
1✔
87
        icon_create_function=icon_create_function,
88
        # maxClusterRadius=10,
89
    ).add_to(m)
90

91
    # Mark every park on the map
92
    for park in parks:
1✔
93
        park_name = park.name
×
94

NEW
95
        folium.Marker(
×
96
            location=(park.latitude, park.longitude),
97
            icon=folium.Icon(icon="dog", prefix="fa", color="green"),
98
            popup=folium.Popup(park_name, max_width=200),
99
        ).add_to(marker_cluster)
100

101
    m = m._repr_html_()
1✔
102
    m = m.replace(
1✔
103
        '<div style="width:100%;">'
104
        + '<div style="position:relative;width:100%;height:0;padding-bottom:60%;">',
105
        '<div style="width:100%; height:100vh;">'
106
        + '<div style="position:relative;width:100%;height:100%;>',
107
        1,
108
    )
109

110
    # Render map as HTML
111
    return render(request, "parks/combined_view.html", {"parks": parks, "map": m})
1✔
112

113

114
def park_detail(request, id):
1✔
115
    park = get_object_or_404(DogRunNew, id=id)  # Get the park by id
1✔
116
    images = ParkImage.objects.filter(park=park)
1✔
117

118
    if request.method == "POST" and request.FILES.get("images"):
1✔
NEW
119
        for image in request.FILES.getlist("images"):
×
NEW
120
            ParkImage.objects.create(park=park, image=image)
×
UNCOV
121
        return redirect("park_detail", id=park.id)
×
122
    return render(request, "parks/park_detail.html", {"park": park, "images": images})
1✔
123

124

125
def contact_view(request):
1✔
126
    return render(request, "parks/contact.html")
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

© 2026 Coveralls, Inc