'Validate password format before saving'

def save(self, *args, **kwargs):

    if (self.password.split('$', 1)[0] == 'sha1'):
        pass
    elif ((len(self.password.split('$', 2)) == 3) and (self.password.split('$', 2)[1] == 'p5k2')):
        pass
    elif (self.password is not None):
        raise ValidationError(_('Unknown    password    format.'))
    else:
        raise ValidationError(_('Call    set_password    before    saving    the    user.'))
    if (self.group and self.facility and (self.group.facility != self.facility)):
        raise ValidationError(_('Facility    group    must    be    in    the    same    facility    as    the    user.'))
    super(FacilityUser, self).save(*args, **kwargs)
    CachedPassword.invalidate_cached_password(user=self)
