<commit_before># -*- coding: utf-8 -*-

from django.db import models
from osf_models.models.base import BaseModel, ObjectIDMixin
from osf_models.utils.datetime_aware_jsonfield import DateTimeAwareJSONField

from website.conferences.exceptions import ConferenceError

DEFAULT_FIELD_NAMES = {
    'submission1': 'poster',
    'submission2': 'talk',
    'submission1_plural': 'posters',
    'submission2_plural': 'talks',
    'meeting_title_type': 'Posters & Talks',
    'add_submission': 'poster or talk',
    'mail_subject': 'Presentation title',
    'mail_message_body': 'Presentation abstract (if any)',
    'mail_attachment': 'Your presentation file (e.g., PowerPoint, PDF, etc.)',
    'homepage_link_text': 'Conference homepage',
}

class ConferenceManager(models.Manager):
    def get_by_endpoint(self, endpoint, active=True):
        try:
            if active:
                return self.get_queryset().get(endpoint__iexact=endpoint, active=True)
            else:
                return self.get_queryset().get(endpoint__iexact=endpoint)
        except Conference.DoesNotExist:
            raise ConferenceError('Endpoint {} not found'.format(endpoint))


class Conference(BaseModel):
    #: Determines the email address for submission and the OSF url
    # Example: If endpoint is spsp2014, then submission email will be
    # <EMAIL> or <EMAIL> and the OSF url will
    # be osf.io/view/spsp2014
    endpoint = models.CharField(max_length=255, unique=True, db_index=True)
    #: Full name, e.g. "SPSP 2014"
    name = models.CharField(max_length=255)
    info_url = models.URLField(blank=True)
    logo_url = models.URLField(blank=True)
    location = models.CharField(max_length=2048, blank=True)
    start_date = models.DateTimeField(blank=True, null=True)
    end_date = models.DateTimeField(blank=True, null=True)
    active = models.BooleanField()
    admins = models.ManyToManyField('OSFUser')
    #: Whether to make submitted projects public
    public_projects = models.BooleanField(default=True)
    poster = models.BooleanField(default=True)
    talk = models.BooleanField(default=True)
    # field_names are used to customize the text on the conference page, the categories
    # of submissions, and the email adress to send material to.
    field_names = DateTimeAwareJSONField(default=DEFAULT_FIELD_NAMES)

    # Cached number of submissions
    num_submissions = models.IntegerField(default=0)

    objects = ConferenceManager()

    def __repr__(self):
        return (
            '<Conference(endpoint={self.endpoint!r}, active={self.active})>'.format(self=self)
        )

    @classmethod
    def get_by_endpoint(cls, endpoint, active):
        return cls.objects.get_by_endpoint(endpoint, active)


class MailRecord(ObjectIDMixin, BaseModel):
    data = DateTimeAwareJSONField()
    nodes_created = models.ManyToManyField('Node')
    users_created = models.ManyToManyField('OSFUser')<commit_msg>Change default value to callable<commit_after># -*- coding: utf-8 -*-

from django.db import models
from osf_models.models.base import BaseModel, ObjectIDMixin
from osf_models.utils.datetime_aware_jsonfield import DateTimeAwareJSONField

from website.conferences.exceptions import ConferenceError

# leaving this at module scope for any existing imports.
DEFAULT_FIELD_NAMES = {
    'submission1': 'poster',
    'submission2': 'talk',
    'submission1_plural': 'posters',
    'submission2_plural': 'talks',
    'meeting_title_type': 'Posters & Talks',
    'add_submission': 'poster or talk',
    'mail_subject': 'Presentation title',
    'mail_message_body': 'Presentation abstract (if any)',
    'mail_attachment': 'Your presentation file (e.g., PowerPoint, PDF, etc.)',
    'homepage_link_text': 'Conference homepage',
}

def get_default_field_names():
    return DEFAULT_FIELD_NAMES


class ConferenceManager(models.Manager):
    def get_by_endpoint(self, endpoint, active=True):
        try:
            if active:
                return self.get_queryset().get(endpoint__iexact=endpoint, active=True)
            else:
                return self.get_queryset().get(endpoint__iexact=endpoint)
        except Conference.DoesNotExist:
            raise ConferenceError('Endpoint {} not found'.format(endpoint))


class Conference(BaseModel):
    #: Determines the email address for submission and the OSF url
    # Example: If endpoint is spsp2014, then submission email will be
    # <EMAIL> or <EMAIL> and the OSF url will
    # be osf.io/view/spsp2014
    endpoint = models.CharField(max_length=255, unique=True, db_index=True)
    #: Full name, e.g. "SPSP 2014"
    name = models.CharField(max_length=255)
    info_url = models.URLField(blank=True)
    logo_url = models.URLField(blank=True)
    location = models.CharField(max_length=2048, blank=True)
    start_date = models.DateTimeField(blank=True, null=True)
    end_date = models.DateTimeField(blank=True, null=True)
    active = models.BooleanField()
    admins = models.ManyToManyField('OSFUser')
    #: Whether to make submitted projects public
    public_projects = models.BooleanField(default=True)
    poster = models.BooleanField(default=True)
    talk = models.BooleanField(default=True)
    # field_names are used to customize the text on the conference page, the categories
    # of submissions, and the email adress to send material to.
    field_names = DateTimeAwareJSONField(default=get_default_field_names)

    # Cached number of submissions
    num_submissions = models.IntegerField(default=0)

    objects = ConferenceManager()

    def __repr__(self):
        return (
            '<Conference(endpoint={self.endpoint!r}, active={self.active})>'.format(self=self)
        )

    @classmethod
    def get_by_endpoint(cls, endpoint, active):
        return cls.objects.get_by_endpoint(endpoint, active)


class MailRecord(ObjectIDMixin, BaseModel):
    data = DateTimeAwareJSONField()
    nodes_created = models.ManyToManyField('Node')
    users_created = models.ManyToManyField('OSFUser')
{'fraction_non_alphanumeric': 0.10193526860193527, 'fraction_numerical': 0.009342676009342675, 'mean_word_length': 4.03781512605042, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6622866', 'n_tokens_mistral': 1826, 'n_tokens_neox': 1766, 'n_words': 422}