<commit_before># Python
import urllib

# Django
from django.conf import settings
from django.db.models import Q
from django.template import Library, Node

# Third party
from subscription.models import Subscription, UserSubscription

# This app
from astrobin_apps_premium.utils import premium_get_valid_usersubscription

register = Library()


@register.inclusion_tag('astrobin_apps_premium/inclusion_tags/premium_badge.html')
def premium_badge(user, size = 'large'):
    return {
        'user': user,
        'size': size,
    }


@register.filter
def is_premium(user):
    userSubscription = premium_get_valid_usersubscription(user)
    if userSubscription:
        return 'AstroBin Premium' in userSubscription.subscription.name
    return False


@register.filter
def is_lite(user):
    userSubscription = premium_get_valid_usersubscription(user)
    if userSubscription:
        return 'AstroBin Lite' in userSubscription.subscription.name
    return False


@register.filter
def is_free(user):
    return not (is_lite(user) or is_premium(user))
<commit_msg>(premium) is_lite/premium tags always return false for anon user<commit_after># Python
import urllib

# Django
from django.conf import settings
from django.db.models import Q
from django.template import Library, Node

# Third party
from subscription.models import Subscription, UserSubscription

# This app
from astrobin_apps_premium.utils import premium_get_valid_usersubscription

register = Library()


@register.inclusion_tag('astrobin_apps_premium/inclusion_tags/premium_badge.html')
def premium_badge(user, size = 'large'):
    return {
        'user': user,
        'size': size,
    }


@register.filter
def is_premium(user):
    if user.is_authenticated():
        userSubscription = premium_get_valid_usersubscription(user)
        if userSubscription:
            return 'AstroBin Premium' in userSubscription.subscription.name
    return False


@register.filter
def is_lite(user):
    if user.is_authenticated():
        userSubscription = premium_get_valid_usersubscription(user)
        if userSubscription:
            return 'AstroBin Lite' in userSubscription.subscription.name
    return False


@register.filter
def is_free(user):
    return not (is_lite(user) or is_premium(user))

{'fraction_non_alphanumeric': 0.07637969094922738, 'fraction_numerical': 0.0, 'mean_word_length': 4.421052631578948, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '257128', 'n_tokens_mistral': 690, 'n_tokens_neox': 672, 'n_words': 170}