<commit_before>from django.db import models
from django.contrib.auth import authenticate
from django.contrib.sites.models import Site
from django.utils import simplejson

import allauth.app_settings
from allauth.utils import get_login_redirect_url

import providers
from fields import JSONField


class SocialAppManager(models.Manager):
    def get_current(self, provider):
        site = Site.objects.get_current()
        return self.get(sites__id=site.id,
                        provider=provider)


class SocialApp(models.Model):
    objects = SocialAppManager()

    provider = models.CharField(max_length=30, 
                                choices=providers.registry.as_choices())
    name = models.CharField(max_length=40)
    key = models.CharField(max_length=100,
                           help_text='App ID, or consumer key')
    secret = models.CharField(max_length=100,
                              help_text='API secret, or consumer secret')
    # Most apps can be used across multiple domains, therefore we use
    # a ManyToManyField. Note that Facebook requires an app per domain
    # (unless the domains share a common base name).
    sites = models.ManyToManyField(Site)

    def __unicode__(self):
        return self.name

class SocialAccount(models.Model):
    user = models.ForeignKey(allauth.app_settings.USER_MODEL)<commit_msg>Allow apps without site<commit_after>from django.db import models
from django.contrib.auth import authenticate
from django.contrib.sites.models import Site
from django.utils import simplejson

import allauth.app_settings
from allauth.utils import get_login_redirect_url

import providers
from fields import JSONField


class SocialAppManager(models.Manager):
    def get_current(self, provider):
        site = Site.objects.get_current()
        return self.get(sites__id=site.id,
                        provider=provider)


class SocialApp(models.Model):
    objects = SocialAppManager()

    provider = models.CharField(max_length=30, 
                                choices=providers.registry.as_choices())
    name = models.CharField(max_length=40)
    key = models.CharField(max_length=100,
                           help_text='App ID, or consumer key')
    secret = models.CharField(max_length=100,
                              help_text='API secret, or consumer secret')
    # Most apps can be used across multiple domains, therefore we use
    # a ManyToManyField. Note that Facebook requires an app per domain
    # (unless the domains share a common base name).
    # blank=True allows for disabling apps without removing them
    sites = models.ManyToManyField(Site, blank=True)

    def __unicode__(self):
        return self.name

class SocialAccount(models.Model):
    user = models.ForeignKey(allauth.app_settings.USER_MODEL)
{'fraction_non_alphanumeric': 0.073545162441985, 'fraction_numerical': 0.007140307033202428, 'mean_word_length': 3.0845481049562684, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3689344', 'n_tokens_mistral': 768, 'n_tokens_neox': 731, 'n_words': 211}