From e0246062b8ad043a0ab7724d0061989cb8e846b5 Mon Sep 17 00:00:00 2001 From: Manan-Arora31 Date: Sun, 22 Oct 2023 18:34:36 +0530 Subject: [PATCH 1/8] Implemented_Top_Places_Section --- home/views.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/home/views.py b/home/views.py index 8c0382d7..e99361e3 100644 --- a/home/views.py +++ b/home/views.py @@ -9,7 +9,7 @@ import requests def homepage(request): - all_places = PlacesDetails.objects.all() + all_places = get_top_places() if request.user.is_authenticated: d = request.user profile_pic = VisitorDetails.objects.get(user_id=d).profile_picture @@ -166,4 +166,21 @@ def get_weather_data(latitude,longitude): 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) + choices = { + "VERY POOR": 1, + "POOR": 2, + "MEDIOCRE": 3, + "GOOD": 4, + "EXCELLENT": 5 + } + places.sort(key=lambda x: (choices[x.safety]+choices[x.sanitization]+choices[x.security]+choices[x.overall_fun]), reverse=True) + places = places[:6] + for p in places: + top_places.append(p.place) + return top_places From 1f5f4ece27aa11692ff529a58f9227ecac30b27d Mon Sep 17 00:00:00 2001 From: Manan-Arora31 Date: Sun, 22 Oct 2023 19:45:45 +0530 Subject: [PATCH 2/8] Implemented All Places Backend --- Places/urls.py | 1 + Places/views.py | 9 ++++++++- templates/Places/all_places.html | 0 templates/index.html | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 templates/Places/all_places.html diff --git a/Places/urls.py b/Places/urls.py index f63f0d53..7464515b 100755 --- a/Places/urls.py +++ b/Places/urls.py @@ -5,4 +5,5 @@ path('save-complaints',views.Save_Complaints, name='report_complaint'), path('rate_and_review//',views.Rate_Review,name='rate_review'), path('save_review//',views.Review,name='save_review'), + path('all_places',views.all_places, name="all_places"), ] diff --git a/Places/views.py b/Places/views.py index 2b7180bc..585b0214 100755 --- a/Places/views.py +++ b/Places/views.py @@ -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('/') \ No newline at end of file + return redirect('/') + +def all_places(request): + places = PlacesDetails.objects.all() + context = { + "places" : places + } + return render(request, "Places/all_places.html", context) \ No newline at end of file diff --git a/templates/Places/all_places.html b/templates/Places/all_places.html new file mode 100644 index 00000000..e69de29b diff --git a/templates/index.html b/templates/index.html index 6aefdea8..504a42b1 100644 --- a/templates/index.html +++ b/templates/index.html @@ -239,7 +239,7 @@

Rating And Review

-

Places

+

Top Places

Varanasi a city of Ghosts and Temples !

From 23a4f965fd256aaff3a6c24d42138db7cf9f1ee0 Mon Sep 17 00:00:00 2001 From: Manan-Arora31 Date: Sun, 22 Oct 2023 23:48:11 +0530 Subject: [PATCH 3/8] Added frontend in all places page --- templates/Places/all_places.html | 47 ++++++++++++++++++++++++++++++++ templates/navbar.html | 2 +- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/templates/Places/all_places.html b/templates/Places/all_places.html index e69de29b..9a721569 100644 --- a/templates/Places/all_places.html +++ b/templates/Places/all_places.html @@ -0,0 +1,47 @@ +{% load static %} + + + + + + + + + + + + + All Places + + + + {% 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 %} + +
+
+
+ {% for p in places %} +
+ +

{{ post.address }}

+
+
{{ post.city }}
+ {% if post.picture %} + image + {% endif %} +
+
+
+
+ {% endfor %} +
+
+
+ + \ No newline at end of file diff --git a/templates/navbar.html b/templates/navbar.html index 44c97b34..ab020335 100644 --- a/templates/navbar.html +++ b/templates/navbar.html @@ -13,7 +13,7 @@
{% if top_places %}
-

Top places

+

Top places

    {% for i,p in top_places.items %} From 6e22a0b08909f111a6396e3a97c9235f6746a984 Mon Sep 17 00:00:00 2001 From: Manan-Arora31 Date: Mon, 23 Oct 2023 17:29:12 +0530 Subject: [PATCH 4/8] Implemented frontend --- Places/urls.py | 2 +- home/views.py | 10 ++-------- templates/Places/all_places.html | 13 ++++++------- templates/navbar.html | 4 ++-- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/Places/urls.py b/Places/urls.py index 7464515b..6155ac7a 100755 --- a/Places/urls.py +++ b/Places/urls.py @@ -5,5 +5,5 @@ path('save-complaints',views.Save_Complaints, name='report_complaint'), path('rate_and_review//',views.Rate_Review,name='rate_review'), path('save_review//',views.Review,name='save_review'), - path('all_places',views.all_places, name="all_places"), + path('',views.all_places, name="all_places"), ] diff --git a/home/views.py b/home/views.py index e99361e3..b2e86cc8 100644 --- a/home/views.py +++ b/home/views.py @@ -172,14 +172,8 @@ def get_top_places(): ratings = RatingReview.objects.all() for r in ratings: places.append(r) - choices = { - "VERY POOR": 1, - "POOR": 2, - "MEDIOCRE": 3, - "GOOD": 4, - "EXCELLENT": 5 - } - places.sort(key=lambda x: (choices[x.safety]+choices[x.sanitization]+choices[x.security]+choices[x.overall_fun]), reverse=True) + + 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) diff --git a/templates/Places/all_places.html b/templates/Places/all_places.html index 9a721569..40195205 100644 --- a/templates/Places/all_places.html +++ b/templates/Places/all_places.html @@ -26,16 +26,15 @@
-

{{ post.address }}

+

{{ p.address }}

-
{{ post.city }}
- {% if post.picture %} - image +
{{ p.city }}
+ {% if p.picture %} + image {% endif %} -
+


diff --git a/templates/navbar.html b/templates/navbar.html index ab020335..5e22f891 100644 --- a/templates/navbar.html +++ b/templates/navbar.html @@ -13,7 +13,7 @@
{% if top_places %}
-

Top places

+

Top places

    {% for i,p in top_places.items %} @@ -83,7 +83,7 @@

    No places to show

    {% endif %} {% if is_places %} - + {% endif %} {% if is_team %} From 2af555923a9fba2434151652b73abc5b1dcdc0e6 Mon Sep 17 00:00:00 2001 From: Manan-Arora31 Date: Tue, 24 Oct 2023 00:22:04 +0530 Subject: [PATCH 5/8] Corrected the changes --- home/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/home/views.py b/home/views.py index 32434ef8..e8700374 100644 --- a/home/views.py +++ b/home/views.py @@ -181,7 +181,11 @@ def get_top_places(): places = places[:6] for p in places: top_places.append(p.place) - return top_places + all_places = PlacesDetails.objects.all() + for p in all_places: + top_places.append(p) + res = [i for n, i in enumerate(top_places) if i not in top_places[:n]] + return res def get_ratio(x): if x.dislikes == 0: From 57bc6254c0e4a818a295ed77b6f0a73b870a4645 Mon Sep 17 00:00:00 2001 From: Manan-Arora31 Date: Tue, 24 Oct 2023 00:59:15 +0530 Subject: [PATCH 6/8] Updated frontend --- templates/Places/all_places.html | 292 ++++++++++++++++++++++++++++++- 1 file changed, 290 insertions(+), 2 deletions(-) diff --git a/templates/Places/all_places.html b/templates/Places/all_places.html index 40195205..4b59e97c 100644 --- a/templates/Places/all_places.html +++ b/templates/Places/all_places.html @@ -1,4 +1,5 @@ {% load static %} +{% load index %} @@ -24,8 +25,141 @@ {% for p in places %}
    + + + + + + + - \ No newline at end of file + + \ No newline at end of file From 1ff0bdd4cdabf4674ccff10cfa456d5e9f85df48 Mon Sep 17 00:00:00 2001 From: Manan-Arora31 Date: Tue, 24 Oct 2023 23:26:31 +0530 Subject: [PATCH 7/8] Corrected the modal --- templates/Places/all_places.html | 96 +++++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/templates/Places/all_places.html b/templates/Places/all_places.html index 4b59e97c..ab5fe0f2 100644 --- a/templates/Places/all_places.html +++ b/templates/Places/all_places.html @@ -12,9 +12,103 @@ integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> + All Places - {% 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 %} From 4d12bec99efd9e1a457c0bdd7072abed7742e0dc Mon Sep 17 00:00:00 2001 From: Manan-Arora31 Date: Fri, 27 Oct 2023 00:45:37 +0530 Subject: [PATCH 8/8] Corrected cards frontend --- home/views.py | 4 +- templates/Places/all_places.html | 591 +++++++++++++++++-------------- 2 files changed, 335 insertions(+), 260 deletions(-) diff --git a/home/views.py b/home/views.py index e8700374..e444ad82 100644 --- a/home/views.py +++ b/home/views.py @@ -22,8 +22,8 @@ def homepage(request): all_reviews.append(reviews) latitude = places.position.latitude longitude = places.position.longitude - #weather_info=get_weather_data(latitude,longitude) - #places.weather_info=weather_info #adding weather info to place object + weather_info=get_weather_data(latitude,longitude) + places.weather_info=weather_info #adding weather info to place object for reviews_qs in all_reviews: rating = 0 count = 0 diff --git a/templates/Places/all_places.html b/templates/Places/all_places.html index ab5fe0f2..bd27bf5f 100644 --- a/templates/Places/all_places.html +++ b/templates/Places/all_places.html @@ -1,126 +1,214 @@ {% load static %} {% load index %} - + + + + + + + + Home + {% include "../scripts.html" with is_index=1 is_profile=0 is_register=0 is_complaints=0 is_rating_review=0 is_edit_profile=0 %} + + - - All Places - - - {% 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 %} - -
    -
    -
    - {% for p in places %} -
    - -

    {{ p.address }}

    -
    -
    {{ p.city }}
    - {% if p.picture %} - image - {% endif %} -
    -
    -
    - {% endfor %} -
    -
    -
    + + @@ -297,132 +372,132 @@

    {{ p.address }}

    - + \ No newline at end of file