From ff3da4bc700b363cfdb023fa2f176ce7c4bdd4c4 Mon Sep 17 00:00:00 2001 From: "@codingsh" Date: Fri, 1 May 2020 11:16:40 -0300 Subject: [PATCH] change: class name pin to PinnedPost #6450 --- app/townsquare/admin.py | 6 +++--- app/townsquare/models.py | 4 ++-- app/townsquare/views.py | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/townsquare/admin.py b/app/townsquare/admin.py index cc53ba5ea4b..dc6bb51021a 100644 --- a/app/townsquare/admin.py +++ b/app/townsquare/admin.py @@ -3,7 +3,7 @@ from django.utils.html import format_html from .models import ( - Announcement, Comment, Flag, Like, Pin, MatchRanking, MatchRound, Offer, OfferAction, SquelchProfile, SuggestedAction, + Announcement, Comment, Flag, Like, PinnedPost, MatchRanking, MatchRound, Offer, OfferAction, SquelchProfile, SuggestedAction, ) @@ -30,7 +30,7 @@ class MatchRankingAdmin(admin.ModelAdmin): list_display = ['created_on', '__str__'] raw_id_fields = ['profile', 'round'] -class PinAdmin(admin.ModelAdmin): +class PinnedAdmin(admin.ModelAdmin): list_display = ['created_on', '__str__'] raw_id_fields = ['user', 'activity'] fields = ['hash_what'] @@ -156,7 +156,7 @@ class AnnounceAdmin(admin.ModelAdmin): admin.site.register(Comment, GenericAdmin) admin.site.register(Like, GenericAdmin) admin.site.register(Flag, GenericAdmin) -admin.site.register(Pin, PinAdmin) +admin.site.register(PinnedPost, PinnedAdmin) admin.site.register(MatchRound, ActuallyGenericAdmin) admin.site.register(MatchRanking, MatchRankingAdmin) admin.site.register(Announcement, AnnounceAdmin) diff --git a/app/townsquare/models.py b/app/townsquare/models.py index 909e6adee6f..39ec3999b60 100644 --- a/app/townsquare/models.py +++ b/app/townsquare/models.py @@ -383,8 +383,8 @@ def __str__(self): return f"Favorite {self.activity.activity_type}:{self.activity_id} by {self.user}" -class Pin(SuperModel): - """Model for each Pinned.""" +class PinnedPost(SuperModel): + """Model for each Pinned Post.""" user = models.ForeignKey('dashboard.Profile', on_delete=models.CASCADE, related_name='pins') diff --git a/app/townsquare/views.py b/app/townsquare/views.py index b3466e37927..006c461a43a 100644 --- a/app/townsquare/views.py +++ b/app/townsquare/views.py @@ -21,7 +21,7 @@ from retail.views import get_specific_activities from .models import ( - Announcement, Comment, Favorite, Flag, Like, Pin, MatchRanking, MatchRound, Offer, OfferAction, SuggestedAction, + Announcement, Comment, Favorite, Flag, Like, PinnedPost, MatchRanking, MatchRound, Offer, OfferAction, SuggestedAction, ) from .tasks import increment_offer_view_counts from .utils import is_user_townsquare_enabled @@ -542,22 +542,22 @@ def api(request, activity_id): elif request.POST['direction'] == 'unfavorite': Favorite.objects.filter(user=request.user, activity=activity).delete() - # Pin request + # PinnedPost request elif request.POST.get('method') == 'pin': hash = hashlib.sha256() hash.update(str(time.time())) hash_what = hash.hexdigest() if request.POST['direction'] == 'pin': - already_pins = Pin.objects.filter(activity=activity, user=request.user, hash_what=hash_what).exists() + already_pins = PinnedPost.objects.filter(activity=activity, user=request.user, hash_what=hash_what).exists() if not already_pins: - Pin.objects.create(activity=activity, user=request.user, hash_what=hash_what) + PinnedPost.objects.create(activity=activity, user=request.user, hash_what=hash_what) else: - Pin.objects.filter(activity=activity, user=request.user, hash_what=hash_what).delete() - Pin.objects.create(activity=activity, user=request.user, hash_what=hash_what) + PinnedPost.objects.filter(activity=activity, user=request.user, hash_what=hash_what).delete() + PinnedPost.objects.create(activity=activity, user=request.user, hash_what=hash_what) elif request.POST['direction'] == 'unpin': - Pin.objects.filter(activity=activity, user=request.user, hash_what=hash_what).delete() + PinnedPost.objects.filter(activity=activity, user=request.user, hash_what=hash_what).delete() # flag request elif request.POST.get('method') == 'flag':