<commit_before>import string
from datetime import datetime
import random
import urllib.parse

from django.db import models
from django.core.urlresolvers import reverse
from django.contrib.auth.models import User

from django_countries.fields import CountryField
from django_fsm import FSMField, transition

from cfp import constants


def token(size):
    c = string.ascii_uppercase + string.digits
    return ''.join(random.SystemRandom().choice(c) for _ in range(size))


class Conference(models.Model):
    created = models.DateTimeField(auto_now_add=True)

    slug = models.CharField(max_length=100, db_index=True)
    legacy_slug = models.CharField(max_length=100, db_index=True, blank=True)
    name = models.CharField(max_length=200)

    venue_name = models.CharField(max_length=100, blank=True)
    venue_address = models.CharField(max_length=255, blank=True)
    city = models.CharField(max_length=100)
    country = CountryField(default='US')
    state = models.CharField(max_length=100, blank=True)

    tagline = models.CharField(max_length=255)
    description = models.TextField()
    programming_language = models.CharField(
        max_length=30, db_index=True, default='',
        choices=constants.PROGRAMMING_LANGUAGES, blank=True)

    twitter_handle = models.CharField(max_length=20, blank=True)
    twitter_hashtag = models.CharField(max_length=20, blank=True)

    start = models.DateField(db_index=True)
    end = models.DateField(db_index=True)

    maps_url = models.URLField(max_length=1000, blank=True)
    website_url = models.URLField(max_length=500)
    conduct_url = models.URLField(max_length=500, blank=True)
    lanyrd_url = models.URLField(max_length=500, blank=True)

    def website_domain(self):
        return urllib.parse.urlparse(self.website_url).netloc

    def __str__(self):
        return "{} {}".format(self.name, self.start.year)

    def date_range(self):
        if (self.end - self.start).days == 0:
            return self.start.strftime("%b %d, %Y")
        return "{} - {}".format(self.start.strftime("%b %d"),
                                self.start.strftime("%d, %Y"))

    def get_absolute_url(self):
        return reverse('call_read', args=[self.slug, self.start.year])

    class Meta:
        unique_together = ('slug', 'start')
        ordering = ['slug', 'start']


class Call(models.Model):
    conference = models.ForeignKey('Conference')
    created = models.DateTimeField(auto_now_add=True)
    description = models.TextField(blank=True)
    start = models.DateField(db_index=True)
    end = models.DateField(db_index=True)
    notify = models.DateField(blank=True)
    lanyrd_url = models.URLField(max_length=500, blank=True)
    application_url = models.URLField(max_length=1000, blank=True)
    tweet_id = models.BigIntegerField(db_index=True, default=0)
    state = FSMField(default='new', protected=True, db_index=True)

    # These fields are used for the submission form,
    # probably want to do something better here in the future
    needs_audience = models.BooleanField(default=False)

    # If true, we'll show the form on the website. Otherwise
    # just post a link to the talk
    hosted = models.BooleanField(default=False)

    def __str__(self):
        return "{} CFP".format(self.conference)

    def get_absolute_url(self):
        return reverse('call_read',
                       args=[self.conference.slug, self.conference.start.year])

    def is_open(self):
        return self.days_left() >= 0

    def days_left(self):
        return (self.end - datetime.utcnow().date()).days

    def iframe_url(self):
        if 'docs.google.com' in self.application_url:
            return self.application_url + "?embedded=true"
        return None

    @transition(field=state, source='new', target='spam')
    def quarantine(self):
        pass

    @transition(field=state, source='new', target='approved')
    def approve(self):
        pass

    @transition(field=state, source='*', target='rejected')
    def reject(self):
        pass


class Track(models.Model):
    conference = models.ForeignKey('Conference')
    name = models.CharField(max_length=100)

    def __str__(self):
        return self.name

<commit_msg>Embed typeform forms<commit_after>import string
from datetime import datetime
import random
import urllib.parse

from django.db import models
from django.core.urlresolvers import reverse
from django.contrib.auth.models import User

from django_countries.fields import CountryField
from django_fsm import FSMField, transition

from cfp import constants


def token(size):
    c = string.ascii_uppercase + string.digits
    return ''.join(random.SystemRandom().choice(c) for _ in range(size))


class Conference(models.Model):
    created = models.DateTimeField(auto_now_add=True)

    slug = models.CharField(max_length=100, db_index=True)
    legacy_slug = models.CharField(max_length=100, db_index=True, blank=True)
    name = models.CharField(max_length=200)

    venue_name = models.CharField(max_length=100, blank=True)
    venue_address = models.CharField(max_length=255, blank=True)
    city = models.CharField(max_length=100)
    country = CountryField(default='US')
    state = models.CharField(max_length=100, blank=True)

    tagline = models.CharField(max_length=255)
    description = models.TextField()
    programming_language = models.CharField(
        max_length=30, db_index=True, default='',
        choices=constants.PROGRAMMING_LANGUAGES, blank=True)

    twitter_handle = models.CharField(max_length=20, blank=True)
    twitter_hashtag = models.CharField(max_length=20, blank=True)

    start = models.DateField(db_index=True)
    end = models.DateField(db_index=True)

    maps_url = models.URLField(max_length=1000, blank=True)
    website_url = models.URLField(max_length=500)
    conduct_url = models.URLField(max_length=500, blank=True)
    lanyrd_url = models.URLField(max_length=500, blank=True)

    def website_domain(self):
        return urllib.parse.urlparse(self.website_url).netloc

    def __str__(self):
        return "{} {}".format(self.name, self.start.year)

    def date_range(self):
        if (self.end - self.start).days == 0:
            return self.start.strftime("%b %d, %Y")
        return "{} - {}".format(self.start.strftime("%b %d"),
                                self.start.strftime("%d, %Y"))

    def get_absolute_url(self):
        return reverse('call_read', args=[self.slug, self.start.year])

    class Meta:
        unique_together = ('slug', 'start')
        ordering = ['slug', 'start']


class Call(models.Model):
    conference = models.ForeignKey('Conference')
    created = models.DateTimeField(auto_now_add=True)
    description = models.TextField(blank=True)
    start = models.DateField(db_index=True)
    end = models.DateField(db_index=True)
    notify = models.DateField(blank=True)
    lanyrd_url = models.URLField(max_length=500, blank=True)
    application_url = models.URLField(max_length=1000, blank=True)
    tweet_id = models.BigIntegerField(db_index=True, default=0)
    state = FSMField(default='new', protected=True, db_index=True)

    # These fields are used for the submission form,
    # probably want to do something better here in the future
    needs_audience = models.BooleanField(default=False)

    # If true, we'll show the form on the website. Otherwise
    # just post a link to the talk
    hosted = models.BooleanField(default=False)

    def __str__(self):
        return "{} CFP".format(self.conference)

    def get_absolute_url(self):
        return reverse('call_read',
                       args=[self.conference.slug, self.conference.start.year])

    def is_open(self):
        return self.days_left() >= 0

    def days_left(self):
        return (self.end - datetime.utcnow().date()).days

    def iframe_url(self):
        if 'docs.google.com' in self.application_url:
            return self.application_url + "?embedded=true"
        if 'typeform.com' in self.application_url:
            return self.application_url
        return None

    @transition(field=state, source='new', target='spam')
    def quarantine(self):
        pass

    @transition(field=state, source='new', target='approved')
    def approve(self):
        pass

    @transition(field=state, source='*', target='rejected')
    def reject(self):
        pass


class Track(models.Model):
    conference = models.ForeignKey('Conference')
    name = models.CharField(max_length=100)

    def __str__(self):
        return self.name


{'fraction_non_alphanumeric': 0.11553784860557768, 'fraction_numerical': 0.013123974689477385, 'mean_word_length': 3.6486928104575163, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2915697', 'n_tokens_mistral': 2753, 'n_tokens_neox': 2612, 'n_words': 540}