def get_id_of_slug(slug: str) -> Issue: """ Returns the uid of the issue with given slug :param slug: slug :return: uid """ return get_enabled_issues_as_query().filter_by(slug=slug).first()
def get_issue_based_on_header(request): """ :param request: :return: """ # logger('IssueHelper', 'get_issue_based_on_header', 'no saved issue found') ui_locales = get_language_from_header(request) db_issues = get_enabled_issues_as_query() db_lang = DBDiscussionSession.query(Language).filter_by( ui_locales=ui_locales).first() db_issue = db_issues.filter_by(lang_uid=db_lang.uid).first() if not db_issue: db_issue = db_issues.first() return db_issue.uid
def test_get_enabled_issues_as_query(self): query_len = get_enabled_issues_as_query().count() res_len = DBDiscussionSession.query(Issue).filter_by(is_disabled=False).count() self.assertEqual(res_len, query_len)