From 85cf39ba16043e07de20b4ace6ca561244049ee9 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 27 Mar 2012 10:07:24 +0530 Subject: [PATCH] Fix unable to clear username/password in Fetch news dialog --- src/calibre/gui2/dialogs/scheduler.py | 8 +++++--- src/calibre/web/feeds/recipes/collection.py | 8 ++++++++ src/calibre/web/feeds/recipes/model.py | 3 +++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/dialogs/scheduler.py b/src/calibre/gui2/dialogs/scheduler.py index d57d514d54..64e3c2e0a3 100644 --- a/src/calibre/gui2/dialogs/scheduler.py +++ b/src/calibre/gui2/dialogs/scheduler.py @@ -11,9 +11,9 @@ from datetime import timedelta import calendar, textwrap from collections import OrderedDict -from PyQt4.Qt import QDialog, Qt, QTime, QObject, QMenu, QHBoxLayout, \ - QAction, QIcon, QMutex, QTimer, pyqtSignal, QWidget, QGridLayout, \ - QCheckBox, QTimeEdit, QLabel, QLineEdit, QDoubleSpinBox +from PyQt4.Qt import (QDialog, Qt, QTime, QObject, QMenu, QHBoxLayout, + QAction, QIcon, QMutex, QTimer, pyqtSignal, QWidget, QGridLayout, + QCheckBox, QTimeEdit, QLabel, QLineEdit, QDoubleSpinBox) from calibre.gui2.dialogs.scheduler_ui import Ui_Dialog from calibre.gui2 import config as gconf, error_dialog @@ -317,6 +317,8 @@ class SchedulerDialog(QDialog, Ui_Dialog): return False if un or pw: self.recipe_model.set_account_info(urn, un, pw) + else: + self.recipe_model.clear_account_info(urn) if self.schedule.isChecked(): schedule_type, schedule = \ diff --git a/src/calibre/web/feeds/recipes/collection.py b/src/calibre/web/feeds/recipes/collection.py index 3a25485955..6ab5764302 100644 --- a/src/calibre/web/feeds/recipes/collection.py +++ b/src/calibre/web/feeds/recipes/collection.py @@ -437,6 +437,14 @@ class SchedulerConfig(object): if x.get('id', False) == urn: return x.get('username', ''), x.get('password', '') + def clear_account_info(self, urn): + with self.lock: + for x in self.iter_accounts(): + if x.get('id', False) == urn: + x.getparent().remove(x) + self.write_scheduler_file() + break + def get_customize_info(self, urn): keep_issues = 0 add_title_tag = True diff --git a/src/calibre/web/feeds/recipes/model.py b/src/calibre/web/feeds/recipes/model.py index 40d246b450..60b74585af 100644 --- a/src/calibre/web/feeds/recipes/model.py +++ b/src/calibre/web/feeds/recipes/model.py @@ -354,6 +354,9 @@ class RecipeModel(QAbstractItemModel, SearchQueryParser): def set_account_info(self, urn, un, pw): self.scheduler_config.set_account_info(urn, un, pw) + def clear_account_info(self, urn): + self.scheduler_config.clear_account_info(urn) + def get_account_info(self, urn): return self.scheduler_config.get_account_info(urn)