# Path: actionlog/models.py
# class LogEntry(models.Model):
#     LOGGED_IN = 1
#     LOGGED_OUT = 2
#     ENROLLED = 3
#     UNENROLLED = 4
#     GIFT_SENT = 5
#     GIFT_RECEIVED = 6
#     PM_SANTA = 7
#     PM_GIFTEE = 8
#     BANNED = 9
#     UNBANNED = 10
# 
#     type = models.IntegerField() # action; shortint
#     user = models.ForeignKey(User, related_name="actions") # actor
#     target_user = models.ForeignKey(User, null=True, related_name="actions2")
#     target_season = models.ForeignKey(Season, null=True)
#     date = models.DateTimeField(default=timezone.now)
#     ip_address = models.CharField(max_length=45)
# 
#     class Meta:
#         db_table = "audit_log"
# 
# Path: clubadm/signals.py



from django.contrib.auth.signals import user_logged_in, user_logged_out
from django.dispatch import receiver
from actionlog.models import LogEntry
from clubadm.signals import member_enrolled, member_unenrolled, user_banned, user_unbanned, giftee_mailed, santa_mailed, gift_sent, gift_received



@receiver(user_logged_in, dispatch_uid="actionlog.log_user_login")
def log_user_login(sender, user, request, **kwargs):
    entry = LogEntry(type=LogEntry.LOGGED_IN, user=user,
                     ip_address=request.META["REMOTE_ADDR"])
    entry.save()


@receiver(user_logged_out, dispatch_uid="actionlog.log_user_logout")
def log_user_logout(sender, user, request, **kwargs):

# Path: actionlog/models.py
# class LogEntry(models.Model):
#     LOGGED_IN = 1
#     LOGGED_OUT = 2
#     ENROLLED = 3
#     UNENROLLED = 4
#     GIFT_SENT = 5
#     GIFT_RECEIVED = 6
#     PM_SANTA = 7
#     PM_GIFTEE = 8
#     BANNED = 9
#     UNBANNED = 10
# 
#     type = models.IntegerField() # action; shortint
#     user = models.ForeignKey(User, related_name="actions") # actor
#     target_user = models.ForeignKey(User, null=True, related_name="actions2")
#     target_season = models.ForeignKey(Season, null=True)
#     date = models.DateTimeField(default=timezone.now)
#     ip_address = models.CharField(max_length=45)
# 
#     class Meta:
#         db_table = "audit_log"
# 
# Path: clubadm/signals.py



# Path: actionlog/signals.py
from django.contrib.auth.signals import user_logged_in, user_logged_out
from django.dispatch import receiver
from actionlog.models import LogEntry
from clubadm.signals import member_enrolled, member_unenrolled, user_banned, user_unbanned, giftee_mailed, santa_mailed, gift_sent, gift_received




@receiver(user_logged_in, dispatch_uid="actionlog.log_user_login")
def log_user_login(sender, user, request, **kwargs):
    entry = LogEntry(type=LogEntry.LOGGED_IN, user=user,
                     ip_address=request.META["REMOTE_ADDR"])
    entry.save()


@receiver(user_logged_out, dispatch_uid="actionlog.log_user_logout")
def log_user_logout(sender, user, request, **kwargs):

    entry = LogEntry(type=LogEntry.LOGGED_OUT, user=user,