def delete(name='', clear_all=False, batch=False): """ :param name: :type name: unicode :param clear_all: :type clear_all: bool :param batch: :type batch: bool :return: """ # action delete # just delete subscribed bangumi or clear all the subscribed bangumi result = {} logger.debug('delete {}'.format(name)) if clear_all: if Followed.delete_followed(batch=batch): result['status'] = "warning" result['message'] = 'all subscriptions have been deleted' else: print_error('user canceled') elif name: try: followed = Followed.get(bangumi_name=name) followed.status = STATUS_DELETED followed.save() result['status'] = 'warning' result['message'] = 'Bangumi {} has been deleted'.format(name) except Followed.DoesNotExist: result['status'] = 'error' result['message'] = 'Bangumi %s does not exist' % name else: result['status'] = 'warning' result['message'] = 'Nothing has been done.' logger.debug(result) return result
def delete(name="", clear_all=False, batch=False): """ :param name: :type name: unicode :param clear_all: :type clear_all: bool :param batch: :type batch: bool :return: """ # action delete # just delete subscribed bangumi or clear all the subscribed bangumi result = {} logger.debug("delete {}".format(name)) if clear_all: if Followed.delete_followed(batch=batch): result["status"] = "warning" result["message"] = "all subscriptions have been deleted" else: print_error("user canceled") elif name: try: followed = Followed.get(bangumi_name=name) followed.status = STATUS_DELETED followed.save() result["status"] = "warning" result["message"] = "Bangumi {} has been deleted".format(name) except Followed.DoesNotExist: result["status"] = "error" result["message"] = "Bangumi %s does not exist" % name else: result["status"] = "warning" result["message"] = "Nothing has been done." logger.debug(result) return result
def delete(name='', clear_all=False, batch=False): """ :param name: :type name: unicode :param clear_all: :type clear_all: bool :param batch: :type batch: bool :return: """ # action delete # just delete subscribed bangumi or clear all the subscribed bangumi result = {} logger.debug('delete {}'.format(name)) if clear_all: if Followed.delete_followed(batch=batch): result['status'] = "warning" result['message'] = 'all subscriptions have been deleted' else: print_error('user canceled') elif name: try: followed = Followed.get(bangumi_name=name) followed.status = STATUS_DELETED followed.save() result['status'] = 'warning' result['message'] = 'Bangumi {} has been deleted'.format(name) except Followed.DoesNotExist: result['status'] = 'error' result['message'] = 'Bangumi %s does not exist' % name else: result['status'] = 'warning' result['message'] = 'Nothing has been done.' logger.debug(result) return result
def delete(name: str = "", clear_all: bool = False, batch: bool = False) -> ControllerResult: """ :param name: :param clear_all: :param batch: """ # action delete # just delete subscribed bangumi or clear all the subscribed bangumi result = {} logger.debug("delete %s", name) if clear_all: if Followed.delete_followed(batch=batch): result["status"] = "warning" result["message"] = "all subscriptions have been deleted" else: print_error("user canceled") elif name: try: followed = Followed.get(bangumi_name=name) followed.status = STATUS_DELETED followed.save() result["status"] = "warning" result["message"] = f"Bangumi {name} has been deleted" except Followed.DoesNotExist: result["status"] = "error" result["message"] = f"Bangumi {name} does not exist" else: result["status"] = "warning" result["message"] = "Nothing has been done." logger.debug(result) return result