<s> from importlib import import_module <EOL> from django . conf import settings <EOL> from django . contrib . auth . models import UserManager <EOL> from django . db . models import CharField <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> MONGOENGINE_USER_DOCUMENT = getattr ( <EOL> settings , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def get_user_document ( ) : <EOL> """<STR_LIT>""" <EOL> name = MONGOENGINE_USER_DOCUMENT <EOL> dot = name . rindex ( '<STR_LIT:.>' ) <EOL> module = import_module ( name [ : dot ] ) <EOL> return getattr ( module , name [ dot + <NUM_LIT:1> : ] ) <EOL> class MongoUserManager ( UserManager ) : <EOL> """<STR_LIT>""" <EOL> def contribute_to_class ( self , model , name ) : <EOL> super ( MongoUserManager , self ) . contribute_to_class ( model , name ) <EOL> self . dj_model = self . model <EOL> self . model = get_user_document ( ) <EOL> self . dj_model . USERNAME_FIELD = self . model . USERNAME_FIELD <EOL> username = CharField ( _ ( '<STR_LIT:username>' ) , max_length = <NUM_LIT:30> , unique = True ) <EOL> username . contribute_to_class ( self . dj_model , self . dj_model . USERNAME_FIELD ) <EOL> self . dj_model . REQUIRED_FIELDS = self . model . REQUIRED_FIELDS <EOL> for name in self . dj_model . REQUIRED_FIELDS : <EOL> field = CharField ( _ ( name ) , max_length = <NUM_LIT:30> ) <EOL> field . contribute_to_class ( self . dj_model , name ) <EOL> def get ( self , * args , ** kwargs ) : <EOL> try : <EOL> return self . get_queryset ( ) . get ( * args , ** kwargs ) <EOL> except self . model . DoesNotExist : <EOL> raise self . dj_model . DoesNotExist <EOL> @ property <EOL> def db ( self ) : <EOL> raise NotImplementedError <EOL> def get_queryset ( self ) : <EOL> return self . model . objects </s>
