<commit_before>from django.db import models
from django.utils.translation import ugettext_lazy as _


class PaymentMethodManager(models.Manager):
    def get_query_set(self):
        qs = super(PaymentMethodManager, self).get_query_set()
        return qs.filter(is_enabled=True)


class PaymentMethod(models.Model):
    TYPE_BUYSAFE = 0
    TYPE_WEBATM = 1
    TYPE_24PAY = 2
    TYPE_PAYCODE = 3
    TYPE_CHOICES = (
        (TYPE_BUYSAFE, _('BuySafe')),
        (TYPE_WEBATM, _('Web ATM')),
        (TYPE_24PAY, _('24Pay')),
        (TYPE_PAYCODE, _('PayCode'))
    )
    name = models.CharField(max_length=100, verbose_name=_('name'))
    payment_type = models.IntegerField(choices=TYPE_CHOICES)
    content = models.TextField(blank=True, verbose_name=_('content'))
    store_id = models.CharField(
        max_length=11, verbose_name=_('SunTech store ID'),
        help_text=_(
            'Should be exactly 10 characters, starting with a capitalized '
            'alphabet.'
        )
    )
    password = models.CharField(
        max_length=20, verbose_name=_('SunTech password'),
        help_text=_(
            'This should usually be the transaction password, which is an '
            'alphanumeric string with length between 8 to 20.'
        )
    )
    is_enabled = models.BooleanField(default=False, verbose_name=_('enabled'))

    enabled = PaymentMethodManager()

    class Meta:
        verbose_name = _('Payment method')
        verbose_name_plural = _('Payment methods')
        ordering = ['-is_enabled', 'payment_type', '-id']

    def save(self, *args, **kwargs):
        super(PaymentMethod, self).save(*args, **kwargs)
        if self.enabled is True:
            (PaymentMethod.objects.exclude(id=self.id)
                          .filter(payment_type=self.payment_type, enabled=True)
                          .update(enabled=False))

    def __unicode__(self):
        return self.name<commit_msg>Add objects to PaymentMethod<commit_after>from django.db import models
from django.utils.translation import ugettext_lazy as _


class PaymentMethodManager(models.Manager):
    def get_query_set(self):
        qs = super(PaymentMethodManager, self).get_query_set()
        return qs.filter(is_enabled=True)


class PaymentMethod(models.Model):
    TYPE_BUYSAFE = 0
    TYPE_WEBATM = 1
    TYPE_24PAY = 2
    TYPE_PAYCODE = 3
    TYPE_CHOICES = (
        (TYPE_BUYSAFE, _('BuySafe')),
        (TYPE_WEBATM, _('Web ATM')),
        (TYPE_24PAY, _('24Pay')),
        (TYPE_PAYCODE, _('PayCode'))
    )
    name = models.CharField(max_length=100, verbose_name=_('name'))
    payment_type = models.IntegerField(choices=TYPE_CHOICES)
    content = models.TextField(blank=True, verbose_name=_('content'))
    store_id = models.CharField(
        max_length=11, verbose_name=_('SunTech store ID'),
        help_text=_(
            'Should be exactly 10 characters, starting with a capitalized '
            'alphabet.'
        )
    )
    password = models.CharField(
        max_length=20, verbose_name=_('SunTech password'),
        help_text=_(
            'This should usually be the transaction password, which is an '
            'alphanumeric string with length between 8 to 20.'
        )
    )
    is_enabled = models.BooleanField(default=False, verbose_name=_('enabled'))

    enabled = PaymentMethodManager()
    objects = models.Manager()

    class Meta:
        verbose_name = _('Payment method')
        verbose_name_plural = _('Payment methods')
        ordering = ['-is_enabled', 'payment_type', '-id']

    def save(self, *args, **kwargs):
        super(PaymentMethod, self).save(*args, **kwargs)
        if self.enabled is True:
            (PaymentMethod.objects.exclude(id=self.id)
                          .filter(payment_type=self.payment_type, enabled=True)
                          .update(enabled=False))

    def __unicode__(self):
        return self.name
{'fraction_non_alphanumeric': 0.11162314388120839, 'fraction_numerical': 0.011264720942140297, 'mean_word_length': 2.7639691714836223, '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': '6390768', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1166, 'n_words': 250}