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

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

18 Mar 2025 12:24AM UTC coverage: 92.278% (+2.3%) from 89.96%
201

push

travis-pro

web-flow
Merge pull request #145 from gcivil-nyu-org/ian_dev

Change codebase to use new table in DB

32 of 34 new or added lines in 4 files covered. (94.12%)

1 existing line in 1 file now uncovered.

239 of 259 relevant lines covered (92.28%)

0.92 hits per line

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

75.93
/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
1✔
4
import os
1✔
5

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

9
from .utilities import folium_cluster_styling
1✔
10

11

12
def park_list(request):
1✔
13
    parks = DogRunNew.objects.all()  # Fetch all dog runs from the database
1✔
14
    return render(request, "parks/park_list.html", {"parks": parks})
1✔
15

16

17
def home_view(request):
1✔
18
    return render(request, "parks/home.html")
1✔
19

20

21
def map(request):
1✔
22

23
    NYC_LAT_AND_LONG = (40.730610, -73.935242)
1✔
24
    # Create map centered on NYC
25
    m = folium.Map(location=NYC_LAT_AND_LONG, zoom_start=11)
1✔
26

27
    icon_create_function = folium_cluster_styling("rgb(0, 128, 0)")
1✔
28

29
    marker_cluster = MarkerCluster(icon_create_function=icon_create_function).add_to(m)
1✔
30

31
    # Fetch all dog runs from the database
32
    parks = DogRunNew.objects.all()
1✔
33

34
    # Mark every park on the map
35
    for park in parks:
1✔
36
        park_name = park.name
×
37

UNCOV
38
        folium.Marker(
×
39
            location=(park.latitude, park.longitude),
40
            icon=folium.Icon(icon="dog", prefix="fa", color="green"),
41
            popup=folium.Popup(park_name, max_width=200),
42
        ).add_to(marker_cluster)
43

44
    # represent map as html
45
    context = {"map": m._repr_html_()}
1✔
46
    return render(request, "parks/map.html", context)
1✔
47

48

49
def park_and_map(request):
1✔
50
    # Get filter values from GET request
51
    filter_value = request.GET.get("filter", "")
1✔
52
    accessible_value = request.GET.get("accessible", "")
1✔
53

54
    # Apply filters based on the selected values
55
    parks = DogRunNew.objects.all().order_by("id")
1✔
56
    if filter_value:
1✔
57
        parks = parks.filter(dogruns_type__icontains=filter_value)
×
58

59
    if accessible_value:
1✔
60
        parks = parks.filter(accessible=accessible_value)
×
61

62
    NYC_LAT_AND_LONG = (40.712775, -74.005973)
1✔
63

64
    # Create map centered on NYC
65
    # f = folium.Figure(height="100")
66
    m = folium.Map(location=NYC_LAT_AND_LONG, zoom_start=11)
1✔
67

68
    icon_create_function = folium_cluster_styling("rgb(0, 128, 0)")
1✔
69
    marker_cluster = MarkerCluster(icon_create_function=icon_create_function).add_to(m)
1✔
70

71
    # Mark every park on the map
72
    for park in parks:
1✔
73
        park_name = park.name
×
74

NEW
75
        folium.Marker(
×
76
            location=(park.latitude, park.longitude),
77
            icon=folium.Icon(icon="dog", prefix="fa", color="green"),
78
            popup=folium.Popup(park_name, max_width=200),
79
        ).add_to(marker_cluster)
80

81
    m = m._repr_html_()
1✔
82
    m = m.replace(
1✔
83
        '<div style="width:100%;">'
84
        + '<div style="position:relative;width:100%;height:0;padding-bottom:60%;">',
85
        '<div style="width:100%; height:100%;">'
86
        + '<div style="position:relative;width:100%;height:100%;>',
87
        1,
88
    )
89

90
    # Render map as HTML
91
    return render(request, "parks/combined_view.html", {"parks": parks, "map": m})
1✔
92

93

94
def park_detail(request, id):
1✔
95
    park = get_object_or_404(DogRunNew, id=id)  # Get the park by id
1✔
96

97
    if request.method == "POST" and request.FILES.get("image"):
1✔
98

99
        if park.image:
×
100
            if os.path.exists(park.image.path):
×
101
                os.remove(park.image.path)  # Delete the existing image file
×
102
                print(f"Deleted old image: {park.image.name}")
×
103
        park.image = request.FILES["image"]
×
104
        park.save()
×
105
        return redirect("park_detail", id=park.id)
×
106

107
    return render(request, "parks/park_detail.html", {"park": park})
1✔
108

109

110
def contact_view(request):
1✔
111
    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