Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Places/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
path('save-complaints',views.Save_Complaints, name='report_complaint'),
path('rate_and_review/<int:pk>/',views.Rate_Review,name='rate_review'),
path('save_review/<int:pk>/',views.Review,name='save_review'),
path('',views.all_places, name="all_places"),
]
9 changes: 8 additions & 1 deletion Places/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,11 @@ def Review(request,pk):
place = PlacesDetails.objects.get(pk=pk)
rating_review = RatingReview.objects.create(safety=safety,sanitization=sanitization,security=security,overall_fun=overallfun,place=place,user=user,review=desc)
rating_review.save()
return redirect('/')
return redirect('/')

def all_places(request):
places = PlacesDetails.objects.all()
context = {
"places" : places
}
return render(request, "Places/all_places.html", context)
17 changes: 15 additions & 2 deletions home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from blog.models import Post

def homepage(request):
all_places = PlacesDetails.objects.all()
all_places = get_top_places()
top_posts = get_top_posts()
if request.user.is_authenticated:
d = request.user
Expand Down Expand Up @@ -169,6 +169,19 @@ def get_weather_data(latitude,longitude):
weather_info['precipitation in mm']=city_weather['current']['precip_mm']
weather_info['last updated time']=city_weather['current']['last_updated']
return weather_info

def get_top_places():
top_places = []
places = []
ratings = RatingReview.objects.all()
for r in ratings:
places.append(r)

places.sort(key=lambda x: (int(x.safety) + int(x.sanitization) + int(x.security)), reverse=True)
places = places[:6]
for p in places:
top_places.append(p.place)
return top_places

def get_ratio(x):
if x.dislikes == 0:
Expand All @@ -182,4 +195,4 @@ def get_top_posts():
top_posts.append(post)
top_posts.sort(key=lambda x: get_ratio(x), reverse=True)
top_posts = top_posts[:6]
return top_posts
return top_posts
46 changes: 46 additions & 0 deletions templates/Places/all_places.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{% load static %}
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<link rel="stylesheet" type="text/css" href="{% static 'blog/main.css' %}">

<title>All Places</title>

</head>
<body>
{% include "../navbar.html" with is_search=0 is_home=0 is_navbar_responsive=1 is_home_nav=1 is_services=0 is_places=0 is_team=0 is_contributors=0 is_report=1 %}

<main role="main" class="container d-flex flex-row justify-content-center gap-3">
<div class="row w-100">
<div class="col-md-8">
{% for p in places %}
<div class="media-body card" style="background-image: linear-gradient(rgba(255,255,255), rgba(255,200,0,0.2));">
<div class="article-metadata card-header">
<div style="font-family:sans-serif; font-weight:bold;">
{{ p.name }}
</div>
</div>
<h2 class="card-title">{{ p.address }}</h2>
<div class="card-text">
<div class="article-content" style="text-align:right; width: 43rem; font-style: italic;">{{ p.city }}</div>
{% if p.picture %}
<img class="rounded mx-auto d-block" src="{{ p.picture.url }}" alt="image" style="height: 258px; width:668px; object-fit: scale-down;">
{% endif %}
</div>
</div>
<br>
<br>
{% endfor %}
</div>
</div>
</main>
</body>
</html>
2 changes: 1 addition & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ <h4 class="my-3">Rating And Review</h4>
</div>
<div id="all-content">
<div class="text-center">
<h2 class="section-heading text-uppercase">Places</h2>
<h2 class="section-heading text-uppercase">Top Places</h2>
<h3 class="section-subheading text-muted">Varanasi a city of Ghosts and Temples !</h3>
</div>
<div class="row">
Expand Down
2 changes: 1 addition & 1 deletion templates/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ <h4 class="item-intro text-muted" style="padding:10px;">No places to show</h4>
{% endif %}

{% if is_places %}
<li class="nav-item"><a class="nav-link" onclick="allPlaces()" href="{% url 'home' %}#places">Places</a></li>
<li class="nav-item"><a class="nav-link" onclick="allPlaces()" href="{% url 'all_places' %}">Places</a></li>
{% endif %}

{% if is_team %}
Expand Down