<commit_before>from django.contrib.contenttypes import generic
from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.utils.translation import ugettext, ugettext_lazy as _
from django.contrib.auth.models import User

reservation_statuses = (("ATTENDING", _("Attending")),
                        ("NOT ATTENDING", _("Not Attending")),
                        ("UNSURE", _("Unsure")),)

class Reservation(models.Model):
    '''
    The reservation status of a user for an event.
    '''
    event = generic.GenericForeignKey('event_content_type', 'event_object_id')
    event_content_type = models.ForeignKey(ContentType)
    event_object_id = models.IntegerField()
    user = models.ForeignKey(User)
    status = models.CharField(_("reservation status"),
                              choices=reservation_statuses, default=None,
                              null=True, blank=True, max_length=20)

    class Meta:
        verbose_name = _('reservation')
        verbose_name_plural = _('reservations')

    def __unicode__(self):
        return "%s reservation for %s" % (self.event, self.user)<commit_msg>Modified the data model to be simpler and more in line with django_attendance.<commit_after>from django.db import models
from django.utils.translation import ugettext, ugettext_lazy as _
from django.contrib.auth.models import User
from django.contrib import admin

from schedule.models import Occurrence

class EventReservations(models.Model):
    """
    Reservation settings for an occurrence.
    """
    occurrence = models.OneToOneField(Occurrence)
    reservation_limit = models.IntegerField(default=0) # 0 is no limit
    reservations = models.ManyToManyField(User)


    class Meta:
        verbose_name = _('reservation setting')
        verbose_name_plural = _('reservation settings')

    def __unicode__(self):
        return "reservation settings for %s" % self.occurrence

    def user_reserved(self, user):
        """
        Determine whether a user has confirmed yes for this occurrence.
        """
        count = self.reservations.filter(user=user).count()
        if count > 0:
            return True
        else:
            return False

    def can_rsvp(self):
        """
        Can another user RSVP yes or are we at our reservation_limit?
        """
        if self.reservation_limit <= 0:
            return True

        count = self.reservations.count()
        if count >= self.reservation_limit:
            return False

        return True

admin.site.register(EventRegistration)
{'fraction_non_alphanumeric': 0.08913974309069676, 'fraction_numerical': 0.0023355391202802647, 'mean_word_length': 2.8415545590433484, 'pattern_counts': {'":': 0, '<': 4, '<?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': '5498927', 'n_tokens_mistral': 715, 'n_tokens_neox': 685, 'n_words': 191}