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

(townsquare) fix/show only mainnet bounty activities in prod #7584

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
26 changes: 23 additions & 3 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,16 @@ def has_funds(self):
return self.filter(idx_status__in=Bounty.FUNDED_STATUSES)


class BountyManager(models.Manager):
"""Enables changing the default queryset function for bounties."""

def get_queryset(self):
if settings.ENV == 'prod':
return super().get_queryset().filter(network='mainnet')
else:
return super().get_queryset()


"""Fields that bonties table should index together."""
def get_bounty_index_together():
import copy
Expand Down Expand Up @@ -393,8 +403,8 @@ class Bounty(SuperModel):
default=False, help_text=_('This bounty will be part of the hypercharged bounties')
)
hyper_next_publication = models.DateTimeField(null=True, blank=True)
# Bounty QuerySet Manager
objects = BountyQuerySet.as_manager()
# Bounty Manager from QuerySet
objects = BountyManager.from_queryset(BountyQuerySet)()

class Meta:
"""Define metadata associated with Bounty."""
Expand Down Expand Up @@ -2207,6 +2217,16 @@ def related_to(self, profile):
return posts


class ActivityManager(models.Manager):
"""Enables changing the default queryset function for Activities."""

def get_queryset(self):
if settings.ENV == 'prod':
return super().get_queryset().filter(Q(bounty=None) | Q(bounty='') | Q(bounty__network='mainnet'))
chibie marked this conversation as resolved.
Show resolved Hide resolved
else:
return super().get_queryset()


class Activity(SuperModel):
"""Represent Start work/Stop work event.

Expand Down Expand Up @@ -2356,7 +2376,7 @@ class Activity(SuperModel):
cached_view_props = JSONField(default=dict, blank=True)

# Activity QuerySet Manager
objects = ActivityQuerySet.as_manager()
objects = ActivityManager.from_queryset(ActivityQuerySet)()

def __str__(self):
"""Define the string representation of an interested profile."""
Expand Down
2 changes: 2 additions & 0 deletions app/townsquare/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,8 @@ def town_square(request):
tab = request.GET.get('tab', request.COOKIES.get('tab', 'connect'))
try:
pinned = PinnedPost.objects.get(what=tab)
if settings.ENV == 'prod' and pinned.activity.bounty and pinned.activity.bounty != 'mainnet':
pinned = None
except PinnedPost.DoesNotExist:
pinned = None
title, desc, page_seo_text_insert, avatar_url, is_direct_link, admin_link = get_param_metadata(request, tab)
Expand Down