<commit_before>from django.db import models
from django.db.models.signals import pre_delete
from django.dispatch import receiver
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist
from hackfsu_com.util import acl
from api.models import Hackathon
from django.contrib import admin
from hackfsu_com.admin import hackfsu_admin


class AttendeeStatusManager(models.Manager):
    @staticmethod
    def get_or_create(user: User, hackathon: Hackathon):
        """ Gets current attendee status for user/hackathon combo. If non exists one is created properly """
        try:
            attendee_status = AttendeeStatus.objects.get(user=user, hackathon=hackathon)
        except ObjectDoesNotExist:
            attendee_status = AttendeeStatus.objects.create(user=user, hackathon=hackathon)
            acl.add_user_to_group(user, acl.group_attendee)
        return attendee_status


class AttendeeStatus(models.Model):
    objects = AttendeeStatusManager()

    created = models.DateTimeField(auto_now_add=True)
    user = models.OneToOneField(to=User, on_delete=models.CASCADE)
    hackathon = models.ForeignKey(to=Hackathon, on_delete=models.CASCADE)
    comments = models.CharField(max_length=1000, default='')
    rsvp_email_sent = models.BooleanField(default=False)
    rsvp_email_sent_timestamp = models.DateTimeField(null=True)
    rsvp_confirmed = models.BooleanField(default=False)
    rsvp_confirmed_timestamp = models.DateTimeField(null=True)
    checked_in = models.BooleanField(default=False)
    checked_in_timestamp = models.DateTimeField(null=True)

    def __str__(self):
        return '[{} {}\'s Attendee Status]'.format(self.user.first_name, self.user.last_name)


@receiver(pre_delete, sender=AttendeeStatus)
def on_pre_delete(**kwargs):
    """ Update base user class's groups """
    instance = kwargs['instance']
    if instance.hackathon == Hackathon.objects.current():
        acl.remove_user_from_group(instance.user, acl.group_attendee)

<commit_msg>Attendee Status model admin updated to allow blank nullable fields<commit_after>from django.db import models
from django.db.models.signals import pre_delete
from django.dispatch import receiver
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist
from hackfsu_com.util import acl
from api.models import Hackathon
from django.contrib import admin
from hackfsu_com.admin import hackfsu_admin


class AttendeeStatusManager(models.Manager):
    @staticmethod
    def get_or_create(user: User, hackathon: Hackathon):
        """ Gets current attendee status for user/hackathon combo. If non exists one is created properly """
        try:
            attendee_status = AttendeeStatus.objects.get(user=user, hackathon=hackathon)
        except ObjectDoesNotExist:
            attendee_status = AttendeeStatus.objects.create(user=user, hackathon=hackathon)
            acl.add_user_to_group(user, acl.group_attendee)
        return attendee_status


class AttendeeStatus(models.Model):
    objects = AttendeeStatusManager()

    created = models.DateTimeField(auto_now_add=True)
    user = models.OneToOneField(to=User, on_delete=models.CASCADE)
    hackathon = models.ForeignKey(to=Hackathon, on_delete=models.CASCADE)
    comments = models.CharField(max_length=1000, default='', blank=True)
    rsvp_email_sent = models.BooleanField(default=False)
    rsvp_email_sent_timestamp = models.DateTimeField(null=True, blank=True)
    rsvp_confirmed = models.BooleanField(default=False)
    rsvp_confirmed_timestamp = models.DateTimeField(null=True, blank=True)
    checked_in = models.BooleanField(default=False)
    checked_in_timestamp = models.DateTimeField(null=True, blank=True)

    def __str__(self):
        return '[{} {}\'s Attendee Status]'.format(self.user.first_name, self.user.last_name)


@receiver(pre_delete, sender=AttendeeStatus)
def on_pre_delete(**kwargs):
    """ Update base user class's groups """
    instance = kwargs['instance']
    if instance.hackathon == Hackathon.objects.current():
        acl.remove_user_from_group(instance.user, acl.group_attendee)


{'fraction_non_alphanumeric': 0.09040367416001933, 'fraction_numerical': 0.0019337684312303602, 'mean_word_length': 4.795518207282913, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4013063', 'n_tokens_mistral': 1279, 'n_tokens_neox': 1237, 'n_words': 255}