Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Solution' #889

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

Julia15031988
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Thank you for your hard work on this project! 😊 There are a few critical issues that need to be addressed before we can approve the pull request:

  1. Visit Counter Implementation: The num_visits variable is not being incremented correctly in the view. This is crucial for accurately reflecting the number of visits. Please ensure that the session variable is updated properly.

  2. Authentication: It's important to protect your views from unauthenticated users as per the task requirements. Please use Django's @login_required decorator to secure your views.

Once these issues are resolved, your code will be in great shape! Keep up the good work, and feel free to reach out if you need any help. 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

@@ -6,6 +6,9 @@

def index(request):
"""View function for the home page of the site."""
num_visits = request.session.get("num_visits", 0)
request.session["num_visits"] = num_visits + 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The num_visits variable should be incremented after retrieving it from the session. Ensure that the increment operation is correctly updating the session variable to reflect the number of visits accurately.

@@ -15,6 +18,7 @@
"num_drivers": num_drivers,
"num_cars": num_cars,
"num_manufacturers": num_manufacturers,
"num_visits": num_visits,
}

return render(request, "taxi/index.html", context=context)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to protect this view from unauthenticated users as per the task requirement: 'Protect all your views from unauthenticated users.' You can use Django's built-in decorators like @login_required to achieve this.

@@ -9,5 +9,6 @@ <h2>Dynamic content</h2>
<li><strong>Cars:</strong> {{ num_cars }}</li>
<li><strong>Drivers:</strong> {{ num_drivers }}</li>
<li><strong>Manufacturers:</strong> {{ num_manufacturers }}</li>
<li><strong>You have visited this page</strong>{{ num_visits }} times.</li>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the num_visits variable is correctly incremented in the view to reflect accurate visit counts. This will ensure that the displayed number of visits is up-to-date.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job on structuring your code and following Django conventions! 🎉 The minor issue with the num_visits variable in taxi/views.py is a small oversight. Make sure to update the session with the incremented value before passing it to the context to ensure the current request reflects the correct number of visits. Keep up the good work, and happy coding! 😊

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

Comment on lines +9 to +10
num_visits = request.session.get("num_visits", 0)
request.session["num_visits"] = num_visits + 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The num_visits variable is incremented after being retrieved from the session, but it is not updated in the session before being passed to the context. This means the incremented value will not be reflected in the current request's context. Consider updating the session with the incremented value before passing it to the context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants