<commit_before>import string
import random
from django.db import models
from django.utils import timezone
from django.conf import settings
from django.core.exceptions import ValidationError

from django.utils.translation import ugettext_lazy as _

from events.models import Event
from events.models import Session
from events.models import Gate
from events.models import SeatLayout
from tickets.models import BaseExtraData
from tickets.models import TicketSeatHold
from tickets.utils import get_seats_by_str

from tickets.utils import generate_pdf
from tickets.utils import generate_thermal

from django.db.models.signals import post_delete
from django.dispatch import receiver


class InvitationType(models.Model):
    name = models.CharField(_('name'), max_length=200)
    is_pass = models.BooleanField(_('is pass'), default=False)
    one_time_for_session = models.BooleanField(_('one time for session'),
        default=False, help_text=_('This is used for passes that will be '
                                   'only valid one time for each session. '
                                   'Invitations always have only one use. '
                                   'So this is ignored in invitations.'))

    event = models.ForeignKey(Event, related_name='invitation_types',
                              verbose_name=_('event'))
    sessions = models.ManyToManyField(Session, related_name='invitation_types',
                                      blank=True,
                                      verbose_name=_('sessions'))

    gates = models.ManyToManyField(Gate, blank=True,
                                   verbose_name=_('gates'))

    start = models.DateTimeField(_('start date'), null=True, blank=True)
    end = models.DateTimeField(_('end date'), null=True, blank=True)

    template = models.ForeignKey("events.TicketTemplate", blank=True, null=True, verbose_name=_('template'))
    thermal_template = models.ForeignKey("events.ThermalTicketTemplate", blank=True, null=True, verbose_name=_('thermal template'))

    class Meta:
        verbose_name = _('invitation type')
        verbose_name_plural = _('invitation types')

    def __str__(self):
        return self.name


class Invitation(models.Model, BaseExtraData):
    type = models.ForeignKey(InvitationType, related_name='invitations',
                             verbose_name=_('invitation type'))

    generator = models.ForeignKey('InvitationGenerator', related_name='invitations',
                                  null=True, blank=True, verbose_name=_('generator'))

    order = models.CharField(_('order'), max_length=200, unique=True)
    created = models.DateTimeField(_('created at'), auto_now_add=True)
    extra_data = models.TextField(_('extra data'), blank=True, null=True)
    is_pass = models.BooleanField(_('is pass'), default=False)<commit_msg>Ordering inv types by event name<commit_after>import string
import random
from django.db import models
from django.utils import timezone
from django.conf import settings
from django.core.exceptions import ValidationError

from django.utils.translation import ugettext_lazy as _

from events.models import Event
from events.models import Session
from events.models import Gate
from events.models import SeatLayout
from tickets.models import BaseExtraData
from tickets.models import TicketSeatHold
from tickets.utils import get_seats_by_str

from tickets.utils import generate_pdf
from tickets.utils import generate_thermal

from django.db.models.signals import post_delete
from django.dispatch import receiver


class InvitationType(models.Model):
    name = models.CharField(_('name'), max_length=200)
    is_pass = models.BooleanField(_('is pass'), default=False)
    one_time_for_session = models.BooleanField(_('one time for session'),
        default=False, help_text=_('This is used for passes that will be '
                                   'only valid one time for each session. '
                                   'Invitations always have only one use. '
                                   'So this is ignored in invitations.'))

    event = models.ForeignKey(Event, related_name='invitation_types',
                              verbose_name=_('event'))
    sessions = models.ManyToManyField(Session, related_name='invitation_types',
                                      blank=True,
                                      verbose_name=_('sessions'))

    gates = models.ManyToManyField(Gate, blank=True,
                                   verbose_name=_('gates'))

    start = models.DateTimeField(_('start date'), null=True, blank=True)
    end = models.DateTimeField(_('end date'), null=True, blank=True)

    template = models.ForeignKey("events.TicketTemplate", blank=True, null=True, verbose_name=_('template'))
    thermal_template = models.ForeignKey("events.ThermalTicketTemplate", blank=True, null=True, verbose_name=_('thermal template'))

    class Meta:
        verbose_name = _('invitation type')
        verbose_name_plural = _('invitation types')
        ordering = ['-event__name']

    def __str__(self):
        return self.name


class Invitation(models.Model, BaseExtraData):
    type = models.ForeignKey(InvitationType, related_name='invitations',
                             verbose_name=_('invitation type'))

    generator = models.ForeignKey('InvitationGenerator', related_name='invitations',
                                  null=True, blank=True, verbose_name=_('generator'))

    order = models.CharField(_('order'), max_length=200, unique=True)
    created = models.DateTimeField(_('created at'), auto_now_add=True)
    extra_data = models.TextField(_('extra data'), blank=True, null=True)
    is_pass = models.BooleanField(_('is pass'), default=False)
{'fraction_non_alphanumeric': 0.0952048823016565, 'fraction_numerical': 0.002092414995640802, 'mean_word_length': 3.150506512301013, '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': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '325025', 'n_tokens_mistral': 1519, 'n_tokens_neox': 1467, 'n_words': 382}