from django.contrib import admin
from django.contrib.auth.models import User, UserManager
import datetime

            
class Ldt(User):
#    irigroups = models.ManyToManyField(IriGroup, blank=True)
    
    class Meta:
        verbose_name = 'iri user'
        verbose_name_plural = 'iri users'
    
    def __unicode__(self):
        return self.username
        

class LdtManager(UserManager):
    def create_user(self, username, email, password=None):
        "Creates and saves a User with the given username, e-mail and password."
        now = datetime.datetime.now()
        user = Ldt(None, username, '', '', email.strip().lower(), 'placeholder', False, True, False, now, now)
        if password:
            user.set_password(password)
        else:
            user.set_unusable_password()
        user.save()
        return user   

User.objects = LdtManager()
User.objects.contribute_to_class(User, "objects")

admin.site.register(Ldt)
