<s> from django . contrib . auth import models as auth_models <EOL> from django . db import models <EOL> from django . db . models . signals import pre_save , post_save <EOL> from django . dispatch import receiver <EOL> class LowerCaseCharField ( models . CharField ) : <EOL> """<STR_LIT>""" <EOL> def pre_save ( self , model_instance , add ) : <EOL> """<STR_LIT>""" <EOL> current_value = getattr ( model_instance , self . attname ) <EOL> setattr ( model_instance , self . attname , current_value . lower ( ) ) <EOL> return getattr ( model_instance , self . attname ) <EOL> class Machine ( models . Model ) : <EOL> hostname = LowerCaseCharField ( max_length = <NUM_LIT:64> , unique = True ) <EOL> ip = models . IPAddressField ( unique = True ) <EOL> idc = LowerCaseCharField ( max_length = <NUM_LIT:8> ) <EOL> rack = LowerCaseCharField ( max_length = <NUM_LIT:8> ) <EOL> cores = models . IntegerField ( ) <EOL> ram = models . IntegerField ( <EOL> help_text = '<STR_LIT>' ) <EOL> disks = models . IntegerField ( <EOL> help_text = '<STR_LIT>' ) <EOL> disk_capacity = models . IntegerField ( <EOL> help_text = '<STR_LIT>' ) <EOL> ssds = models . IntegerField ( default = <NUM_LIT:0> , <EOL> help_text = '<STR_LIT>' ) <EOL> ssd_capacity = models . IntegerField ( default = <NUM_LIT:0> , <EOL> help_text = '<STR_LIT>' ) <EOL> create_time = models . DateTimeField ( auto_now_add = True ) <EOL> update_time = models . DateTimeField ( auto_now = True ) <EOL> @ receiver ( pre_save , sender = auth_models . User ) <EOL> def auth_user_pre_save ( sender , instance = None , ** kwargs ) : <EOL> instance . is_staff = True </s>
