<commit_before>
from django.contrib.auth.models import User
from django.db import models
from apps.lan.models import LAN
from django.db.models import Q
import datetime


class Layout(models.Model):
    title = models.CharField('title', max_length=50)
    description = models.CharField('desc', max_length=250)
    number_of_seats = models.IntegerField('number of seats')
    template = models.TextField('SVG layout for seating', null=True, blank=True)

    def __unicode__(self):
        return self.title


class Seating(models.Model):
    lan = models.ForeignKey(LAN)
    title = models.CharField('title', max_length=50)
    desc = models.CharField('desc', max_length=250)
    number_of_seats = models.IntegerField('number of seats')
    closing_date = models.DateTimeField("closing date")
    layout = models.ForeignKey(Layout, null=True, blank=True)

    def save(self, *args, **kwargs):
        if not self.pk:
            super(Seating, self).save(*args, **kwargs)
            self.populate_seats()
        else:
            super(Seating, self).save(*args, **kwargs)

    def get_user_registered(self):
        return map(lambda x: getattr(x, 'user'), Seat.objects.filter(~Q(user=None), Q(seating=self)))

    def get_total_seats(self):
        return Seat.objects.filter(Q(seating=self))

    def get_number_of_seats(self):
        return Seat.objects.filter(Q(seating=self)).count()

    def is_open(self):
        return datetime.datetime.now() < self.closing_date

    def get_free_seats(self):
        return Seat.objects.filter(Q(user=None), Q(seating=self)).count()

    def __unicode__(self):
        return self.title

    @models.permalink<commit_msg>Added order by on seatings<commit_after>
from django.contrib.auth.models import User
from django.db import models
from apps.lan.models import LAN
from django.db.models import Q
import datetime


class Layout(models.Model):
    title = models.CharField('title', max_length=50)
    description = models.CharField('desc', max_length=250)
    number_of_seats = models.IntegerField('number of seats')
    template = models.TextField('SVG layout for seating', null=True, blank=True)

    def __unicode__(self):
        return self.title


class Seating(models.Model):
    lan = models.ForeignKey(LAN)
    title = models.CharField('title', max_length=50)
    desc = models.CharField('desc', max_length=250)
    number_of_seats = models.IntegerField('number of seats')
    closing_date = models.DateTimeField("closing date")
    layout = models.ForeignKey(Layout, null=True, blank=True)

    def save(self, *args, **kwargs):
        if not self.pk:
            super(Seating, self).save(*args, **kwargs)
            self.populate_seats()
        else:
            super(Seating, self).save(*args, **kwargs)

    def get_user_registered(self):
        return map(lambda x: getattr(x, 'user'), Seat.objects.filter(~Q(user=None), Q(seating=self)))

    def get_total_seats(self):
        return Seat.objects.filter(Q(seating=self)).order_by('placement')

    def get_number_of_seats(self):
        return Seat.objects.filter(Q(seating=self)).count()

    def is_open(self):
        return datetime.datetime.now() < self.closing_date

    def get_free_seats(self):
        return Seat.objects.filter(Q(user=None), Q(seating=self)).count()

    def __unicode__(self):
        return self.title

    @models.permalink
{'fraction_non_alphanumeric': 0.12488875704538713, 'fraction_numerical': 0.0059329575793533075, 'mean_word_length': 3.683333333333333, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5486604', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1033, 'n_words': 223}