Merge branch 'main' into about-page
This commit is contained in:
@ -223,7 +223,6 @@ def feed_page_data(user):
|
||||
|
||||
goal = models.AnnualGoal.objects.filter(user=user, year=timezone.now().year).first()
|
||||
return {
|
||||
"suggested_books": get_suggested_books(user),
|
||||
"goal": goal,
|
||||
"goal_form": forms.GoalForm(),
|
||||
}
|
||||
|
@ -113,13 +113,16 @@ class GetStartedUsers(View):
|
||||
.filter(
|
||||
similarity__gt=0.5,
|
||||
)
|
||||
.exclude(
|
||||
id=request.user.id,
|
||||
)
|
||||
.order_by("-similarity")[:5]
|
||||
)
|
||||
data = {"no_results": not user_results}
|
||||
|
||||
if user_results.count() < 5:
|
||||
user_results = list(user_results) + suggested_users.get_suggestions(
|
||||
request.user
|
||||
user_results = list(user_results) + list(
|
||||
suggested_users.get_suggestions(request.user)
|
||||
)
|
||||
|
||||
data["suggested_users"] = user_results
|
||||
|
@ -1,6 +1,7 @@
|
||||
""" boosts and favs """
|
||||
from django.db import IntegrityError
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.core.cache import cache
|
||||
from django.db import IntegrityError
|
||||
from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseNotFound
|
||||
from django.shortcuts import redirect
|
||||
from django.utils.decorators import method_decorator
|
||||
@ -17,6 +18,7 @@ class Favorite(View):
|
||||
|
||||
def post(self, request, status_id):
|
||||
"""create a like"""
|
||||
cache.delete(f"fav-{request.user.id}-{status_id}")
|
||||
status = models.Status.objects.get(id=status_id)
|
||||
try:
|
||||
models.Favorite.objects.create(status=status, user=request.user)
|
||||
@ -35,6 +37,7 @@ class Unfavorite(View):
|
||||
|
||||
def post(self, request, status_id):
|
||||
"""unlike a status"""
|
||||
cache.delete(f"fav-{request.user.id}-{status_id}")
|
||||
status = models.Status.objects.get(id=status_id)
|
||||
try:
|
||||
favorite = models.Favorite.objects.get(status=status, user=request.user)
|
||||
@ -54,6 +57,7 @@ class Boost(View):
|
||||
|
||||
def post(self, request, status_id):
|
||||
"""boost a status"""
|
||||
cache.delete(f"boost-{request.user.id}-{status_id}")
|
||||
status = models.Status.objects.get(id=status_id)
|
||||
# is it boostable?
|
||||
if not status.boostable:
|
||||
@ -81,6 +85,7 @@ class Unboost(View):
|
||||
|
||||
def post(self, request, status_id):
|
||||
"""boost a status"""
|
||||
cache.delete(f"boost-{request.user.id}-{status_id}")
|
||||
status = models.Status.objects.get(id=status_id)
|
||||
boost = models.Boost.objects.filter(
|
||||
boosted_status=status, user=request.user
|
||||
|
@ -1,5 +1,7 @@
|
||||
""" the good stuff! the books! """
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.core.cache import cache
|
||||
from django.core.cache.utils import make_template_fragment_key
|
||||
from django.db import transaction
|
||||
from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseNotFound
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
@ -44,6 +46,13 @@ class ReadingStatus(View):
|
||||
if not identifier:
|
||||
return HttpResponseBadRequest()
|
||||
|
||||
# invalidate the template cache
|
||||
cache_keys = [
|
||||
make_template_fragment_key("shelve_button", [request.user.id, book_id]),
|
||||
make_template_fragment_key("suggested_books", [request.user.id]),
|
||||
]
|
||||
cache.delete_many(cache_keys)
|
||||
|
||||
desired_shelf = get_object_or_404(
|
||||
models.Shelf, identifier=identifier, user=request.user
|
||||
)
|
||||
|
Reference in New Issue
Block a user