def validate(self): password1 = self.processed_data['password1'] password2 = self.processed_data['password2'] if password1 != password2: raise form.ValidationError('password_match', {}) user = (request.user if request.user.is_authenticated else User.from_reset_token(self.processed_data['reset_token'])) if not user: raise form.ValidationError('invalid_token', {'value': ''}) self.processed_data['username'] = user.username
def validate(self, v): if not v: return config = request.app.config emergency_token_path = config.get('emergency.file') if not os.path.isfile(emergency_token_path): raise form.ValidationError('bad_token', {'value': ''}) with open(emergency_token_path, 'r') as f: emergency_token = f.read().strip() if not emergency_token: raise form.ValidationError('bad_token', {'value': ''}) if self.to_token(v.strip().lower()) != emergency_token: raise form.ValidationError('bad_token', {'value': ''})
def validate(self): active_storage_id = storage.get_consolidate_status() if active_storage_id: raise form.ValidationError('already_running', {}) # Perform preflight check storages = storage.get_content_storages() storage_id = self.processed_data['storage_id'] try: dest = storages.move_preflight(storage_id) except storage.NotFoundError: raise form.ValidationError('storage_not_found', {}) except storage.NoMoveTargetError: raise form.ValidationError('no_move_target', {}) except storage.NothingToMoveError: raise form.ValidationError('nothing_to_move', {}) except storage.CapacityError as err: params = dict(size=hsize(err.capacity)) raise form.ValidationError('not_enough_space', params) else: self.processed_data['storages'] = storages self.processed_data['dest'] = dest
def validate(self): if not has_tuner(): # Translators, error message shown when a tuner is not detected raise form.ValidationError('tuning_error', {}) lnb = self.processed_data['lnb'] frequency = self.processed_data['frequency'] symbolrate = self.processed_data['symbolrate'] delivery = self.processed_data['delivery'] modulation = self.processed_data['modulation'] polarization = self.processed_data['polarization'] settings = dict(frequency=freq_conv(frequency, lnb), symbolrate=symbolrate, delivery=delivery, tone=needs_tone(frequency, lnb), modulation=dict(consts.MODULATION)[modulation], voltage=consts.VOLTS[polarization]) ondd_client = request.app.supervisor.exts.ondd response = ondd_client.set_settings(**settings) if not response.startswith('2'): # Translators, error message shown when setting transponder # configuration is not successful raise form.ValidationError('tuning_error', {})
def validate(self): ondd.write_ondd_setup(self.processed_data) try: ondd.restart_demod() except ondd.DemodRestartError: raise form.ValidationError('tuning_error', {})
def postprocess_path(self, value): if not exts.fsal.exists(value): raise form.ValidationError('already_deleted', {}) return value
def validate(self): username = self.processed_data['username'] password = self.processed_data['password'] if not User.login(username, password): raise form.ValidationError('login_error', {})
def validate(self, v): if not v: return if self.USERNAME_RE.match(v.strip()) is None: raise form.ValidationError('bad_username', {'value': v})
def validate(self): password1 = self.processed_data['password1'] password2 = self.processed_data['password2'] if password1 != password2: raise form.ValidationError('registration_error', {})
def validate(self): password1 = self.processed_data['password1'] password2 = self.processed_data['password2'] if password1 != password2: raise form.ValidationError('password_match', {})