# Path: placard/logging/models.py
# class LogEntry(models.Model):
#     action_time = models.DateTimeField(auto_now=True)
#     user = models.ForeignKey(User, related_name="ldap_logs")
#     object_dn = models.CharField(max_length=50)
#     object_pk = models.CharField(max_length=40)
#     object_type = models.CharField(max_length=20)
#     object_repr = models.CharField(max_length=200)
#     action = models.CharField(max_length=1)
#     change_message = models.TextField()
# 
#     objects = LogEntryManager()
# 
#     class Meta:
#         verbose_name = 'log entry'
#         verbose_name_plural = 'log entries'
#         ordering = ('-action_time',)
# 
#     def is_addition(self):
#         return self.action == 'A'
# 
#     def is_change(self):
#         return self.action == 'C'
# 
#     def is_deletion(self):
#         return self.action == 'D'
# 
#     def is_task(self):
#         return self.action == 'T'


import placard.signals
from placard.logging.models import LogEntry
    log(user, group, "A", u"Added group")


def group_edit(sender, user, data, **kwargs):
    group = sender
    for key, value in data.iteritems():
        old_value = getattr(group, key)
        if old_value != value:
            log(user, group, "C", u"Changed '%s' from '%s' to '%s'" % (key, old_value, value))


def group_add_member(sender, user, account, **kwargs):
    group = sender
    log(user, account, "C", u"Added to group '%s'" % group)
    log(user, group, "C", u"Added '%s' to group" % account)


def group_remove_member(sender, user, account, **kwargs):
    group = sender
    log(user, account, "C", u"Removed from group '%s'" % group)
    log(user, group, "C", u"Removed '%s' from group" % account)


def group_delete(sender, user, **kwargs):
    group = sender
    log(user, group, "D", u"Deleted group")


def group_rename(sender, user, old_dn, old_pk, **kwargs):
    group = sender

# Path: placard/logging/models.py
# class LogEntry(models.Model):
#     action_time = models.DateTimeField(auto_now=True)
#     user = models.ForeignKey(User, related_name="ldap_logs")
#     object_dn = models.CharField(max_length=50)
#     object_pk = models.CharField(max_length=40)
#     object_type = models.CharField(max_length=20)
#     object_repr = models.CharField(max_length=200)
#     action = models.CharField(max_length=1)
#     change_message = models.TextField()
# 
#     objects = LogEntryManager()
# 
#     class Meta:
#         verbose_name = 'log entry'
#         verbose_name_plural = 'log entries'
#         ordering = ('-action_time',)
# 
#     def is_addition(self):
#         return self.action == 'A'
# 
#     def is_change(self):
#         return self.action == 'C'
# 
#     def is_deletion(self):
#         return self.action == 'D'
# 
#     def is_task(self):
#         return self.action == 'T'


# Path: placard/logging/signals.py
import placard.signals
from placard.logging.models import LogEntry

    log(user, group, "A", u"Added group")


def group_edit(sender, user, data, **kwargs):
    group = sender
    for key, value in data.iteritems():
        old_value = getattr(group, key)
        if old_value != value:
            log(user, group, "C", u"Changed '%s' from '%s' to '%s'" % (key, old_value, value))


def group_add_member(sender, user, account, **kwargs):
    group = sender
    log(user, account, "C", u"Added to group '%s'" % group)
    log(user, group, "C", u"Added '%s' to group" % account)


def group_remove_member(sender, user, account, **kwargs):
    group = sender
    log(user, account, "C", u"Removed from group '%s'" % group)
    log(user, group, "C", u"Removed '%s' from group" % account)


def group_delete(sender, user, **kwargs):
    group = sender
    log(user, group, "D", u"Deleted group")


def group_rename(sender, user, old_dn, old_pk, **kwargs):
    group = sender

    LogEntry.objects.filter(object_dn=old_dn).update(object_dn=group.dn, object_pk=group.pk)