<commit_before>from rest_framework import throttling


class EquipmentCreateThrottle(throttling.UserRateThrottle):
    rate = '10/day'

    def allow_request(self, request, view):
        if request.method != "POST" or request.user.is_superuser:
                return True

        return super().allow_request(request, view)
<commit_msg>(equipment/api) Do not throttle paying users<commit_after>from rest_framework import throttling

from astrobin_apps_premium.services.premium_service import PremiumService
from astrobin_apps_premium.templatetags.astrobin_apps_premium_tags import is_free


class EquipmentCreateThrottle(throttling.UserRateThrottle):
    rate = '10/day'

    def allow_request(self, request, view):
        if request.method != "POST":
            return True

        if request.user.is_superuser:
            return True

        valid_subscription = PremiumService(request.user).get_valid_usersubscription()
        if not is_free(valid_subscription):
            return True

        return super().allow_request(request, view)

{'fraction_non_alphanumeric': 0.0741444866920152, 'fraction_numerical': 0.0038022813688212928, 'mean_word_length': 3.65929203539823, 'pattern_counts': {'":': 1, '<': 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': '5011943', 'n_tokens_mistral': 314, 'n_tokens_neox': 297, 'n_words': 66}