<commit_before>from django.db import models
from django.conf import settings

from audit_log import registration


class LastUserField(models.ForeignKey):
    """
    A field that keeps the last user that saved an instance
    of a model. None will be the value for AnonymousUser.
    """
    
    def __init__(self, to = getattr(settings, 'AUTH_USER_MODEL', 'auth.User'), null = True, editable = False,  **kwargs):
        super(LastUserField, self).__init__(to = to, null = null, editable = editable, **kwargs)
    
    def contribute_to_class(self, cls, name):
        super(LastUserField, self).contribute_to_class(cls, name)
        registry = registration.FieldRegistry(self.__class__)
        registry.add_field(cls, self)

class LastSessionKeyField(models.CharField):
    """
    A field that keeps a reference to the last session key that was used to access the model.
    """
    
    def __init__(self, max_length  = 40, null = True, editable = False,  **kwargs):
        super(LastSessionKeyField, self).__init__(max_length = 40, null = null, editable = editable, **kwargs)
    
    def contribute_to_class(self, cls, name):
        super(LastSessionKeyField, self).contribute_to_class(cls, name)
        registry = registration.FieldRegistry(self.__class__)
        registry.add_field(cls, self)

class CreatingUserField(LastUserField):
    """
    A field that keeps track of the user that created a model instance.
    This will only be set once upon an INSERT in the database.
    """
    #dont actually need to do anything, everything is handled by the parent class
    #the different logic goes in the middleware
    pass

class CreatingSessionKeyField(LastSessionKeyField):
    """
    A field that keeps track of the last session key with which a model instance was created.
    This will only be set once upon an INSERT in the database.
    """
    #dont actually need to do anything, everything is handled by the parent class
    #the different logic goes in the middleware
    pass


#South stuff:

rules = [((LastUserField, CreatingUserField),
    [],    <commit_msg>Remove spaces around argument value assignment<commit_after>from django.db import models
from django.conf import settings

from audit_log import registration


class LastUserField(models.ForeignKey):
    """
    A field that keeps the last user that saved an instance
    of a model. None will be the value for AnonymousUser.
    """
    
    def __init__(self, to=getattr(settings, 'AUTH_USER_MODEL', 'auth.User'), null=True, editable=False,  **kwargs):
        super(LastUserField, self).__init__(to=to, null=null, editable=editable, **kwargs)
    
    def contribute_to_class(self, cls, name):
        super(LastUserField, self).contribute_to_class(cls, name)
        registry = registration.FieldRegistry(self.__class__)
        registry.add_field(cls, self)

class LastSessionKeyField(models.CharField):
    """
    A field that keeps a reference to the last session key that was used to access the model.
    """
    
    def __init__(self, max_length =40, null=True, editable=False,  **kwargs):
        super(LastSessionKeyField, self).__init__(max_length=40, null=null, editable=editable, **kwargs)
    
    def contribute_to_class(self, cls, name):
        super(LastSessionKeyField, self).contribute_to_class(cls, name)
        registry = registration.FieldRegistry(self.__class__)
        registry.add_field(cls, self)

class CreatingUserField(LastUserField):
    """
    A field that keeps track of the user that created a model instance.
    This will only be set once upon an INSERT in the database.
    """
    #dont actually need to do anything, everything is handled by the parent class
    #the different logic goes in the middleware
    pass

class CreatingSessionKeyField(LastSessionKeyField):
    """
    A field that keeps track of the last session key with which a model instance was created.
    This will only be set once upon an INSERT in the database.
    """
    #dont actually need to do anything, everything is handled by the parent class
    #the different logic goes in the middleware
    pass


#South stuff:

rules = [((LastUserField, CreatingUserField),
    [],    
{'fraction_non_alphanumeric': 0.0816034359341446, 'fraction_numerical': 0.00190885230255309, 'mean_word_length': 3.576419213973799, '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': '5664073', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1146, 'n_words': 430}