diff --git a/reader/views.py b/reader/views.py index d88759188d..d57db0657a 100644 --- a/reader/views.py +++ b/reader/views.py @@ -333,7 +333,6 @@ def catchall(request, tref, sheet=None): def reader_redirect(uref): # Redirect to standard URLs url = "/" + uref - print("url>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", url) response = redirect(iri_to_uri(url), permanent=True) params = request.GET.urlencode() response['Location'] += "?%s" % params if params else "" @@ -1557,69 +1556,29 @@ def _get_text(oref, versionEn=versionEn, versionHe=versionHe, commentary=comment return text - text_ref = Ref(tref) - text_title = text_ref.index.get_title("en") - if request.user.is_authenticated: - user_group_text_list = library.get_text_permission_group(request.user.email) - for user_text in user_group_text_list: - if text_title == user_text['title']: - if not multiple or abs(multiple) == 1: - text = _get_text(oref, versionEn=versionEn, versionHe=versionHe, commentary=commentary, context=context, - pad=pad, - alts=alts, wrapLinks=wrapLinks, layer_name=layer_name) - return jsonResponse(text, cb) - else: - # Return list of many sections - assert multiple != 0 - direction = "next" if multiple > 0 else "prev" - target_count = abs(multiple) - - current = 0 - texts = [] - - while current < target_count: - text = _get_text(oref, versionEn=versionEn, versionHe=versionHe, commentary=commentary, context=context, - pad=pad, - alts=alts, wrapLinks=wrapLinks, layer_name=layer_name) - texts += [text] - if not text[direction]: - break - oref = Ref(text[direction]) - current += 1 - return jsonResponse(texts, cb) + if not multiple or abs(multiple) == 1: + text = _get_text(oref, versionEn=versionEn, versionHe=versionHe, commentary=commentary, context=context, + pad=pad, + alts=alts, wrapLinks=wrapLinks, layer_name=layer_name) + return jsonResponse(text, cb) else: - email = request.GET.get("email", None) - group_text_list = library.get_text_permission_group(email) - for text in group_text_list: - if text_title == text['title']: - if not multiple or abs(multiple) == 1: - text = _get_text(oref, versionEn=versionEn, versionHe=versionHe, commentary=commentary, context=context, - pad=pad, - alts=alts, wrapLinks=wrapLinks, layer_name=layer_name) - return jsonResponse(text, cb) - else: - # Return list of many sections - assert multiple != 0 - direction = "next" if multiple > 0 else "prev" - target_count = abs(multiple) - - current = 0 - texts = [] - - while current < target_count: - text = _get_text(oref, versionEn=versionEn, versionHe=versionHe, commentary=commentary, context=context, - pad=pad, - alts=alts, wrapLinks=wrapLinks, layer_name=layer_name) - texts += [text] - if not text[direction]: - break - oref = Ref(text[direction]) - current += 1 - return jsonResponse(texts, cb) - - - return jsonResponse({"error": f"You do not have access permission to this text"}, cb) - + # Return list of many sections + assert multiple != 0 + direction = "next" if multiple > 0 else "prev" + target_count = abs(multiple) + current = 0 + texts = [] + while current < target_count: + text = _get_text(oref, versionEn=versionEn, versionHe=versionHe, commentary=commentary, context=context, + pad=pad, + alts=alts, wrapLinks=wrapLinks, layer_name=layer_name) + texts += [text] + if not text[direction]: + break + oref = Ref(text[direction]) + current += 1 + return jsonResponse(texts, cb) + if request.method == "POST": j = request.POST.get("json") if not j: @@ -1805,33 +1764,13 @@ def index_api(request, title, raw=False): API for manipulating text index records (aka "Text Info") """ if request.method == "GET": - if request.user.is_authenticated: - user_group_text_list = library.get_text_permission_group(request.user.email) - for user_text in user_group_text_list: - if title == user_text['title']: - with_content_counts = bool(request.GET.get("with_content_counts", False)) - i = library.get_index(title).contents(raw=raw, with_content_counts=with_content_counts) - - if request.GET.get("with_related_topics", False): - i["relatedTopics"] = get_topics_for_book(title, annotate=True) - - return jsonResponse(i, callback=request.GET.get("callback", None)) - return jsonResponse({"error":f"Either Index is not available OR You are not allowed to access."}, callback=request.GET.get("callback", None)) - else: - email = request.GET.get("email", None) - user_group_text_list = library.get_text_permission_group(email) - for user_text in user_group_text_list: - if title == user_text['title']: - with_content_counts = bool(request.GET.get("with_content_counts", False)) - i = library.get_index(title).contents(raw=raw, with_content_counts=with_content_counts) - - if request.GET.get("with_related_topics", False): - i["relatedTopics"] = get_topics_for_book(title, annotate=True) - - return jsonResponse(i, callback=request.GET.get("callback", None)) - return jsonResponse({"error":f"Either Index is not available OR You are not allowed to access."}, callback=request.GET.get("callback", None)) - + with_content_counts = bool(request.GET.get("with_content_counts", False)) + i = library.get_index(title).contents(raw=raw, with_content_counts=with_content_counts) + if request.GET.get("with_related_topics", False): + i["relatedTopics"] = get_topics_for_book(title, annotate=True) + return jsonResponse(i, callback=request.GET.get("callback", None)) + if request.method == "POST": # use the update function if update is in the params @@ -2376,26 +2315,8 @@ def versions_api(request, tref): API for retrieving available text versions list of a ref. """ oref = Ref(tref) - email = request.GET.get("email", None) - versions = [] - if request.user.is_authenticated: - group_text_list = library.get_text_permission_group(request.user.email) - for text in group_text_list: - if str(text['title']) == str(oref): - - versions = oref.version_list() - return jsonResponse(versions, callback=request.GET.get("callback", None)) - return jsonResponse(versions, callback=request.GET.get("callback", None)) - - else: - email = request.GET.get("email", None) - group_text_list = library.get_text_permission_group(email) - for text in group_text_list: - if str(text['title']) == str(oref): - versions = oref.version_list() - return jsonResponse(versions, callback=request.GET.get("callback", None)) - - return jsonResponse(versions, callback=request.GET.get("callback", None)) + versions = oref.version_list() + return jsonResponse(versions, callback=request.GET.get("callback", None)) @catch_error_as_json diff --git a/sefaria/client/wrapper.py b/sefaria/client/wrapper.py index 73bbe8d1ab..00289720f3 100644 --- a/sefaria/client/wrapper.py +++ b/sefaria/client/wrapper.py @@ -196,10 +196,6 @@ def get_links(tref, with_text=True, with_sheet_links=False): if node_depth is None or len(source_ref.sections) + 1 < node_depth: continue - linkPos = (pos + 1) % 2 - linkTref = link.refs[linkPos] - linkRef = Ref(linkTref) - com = format_link_object_for_client(link, False, nRef, pos) except InputError: logger.warning("Bad link: {} - {}".format(link.refs[0], link.refs[1])) @@ -289,12 +285,7 @@ def get_links(tref, with_text=True, with_sheet_links=False): com[versionAttr] = versions com[licenseAttr] = licenses com[vtitleInHeAttr] = versionTitlesInHebrew - - user_email = get_current_user() - text_list = library.get_text_permission_group(user_email) - for text in text_list: - if linkRef.index.get_title("en") == text['title']: - links.append(com) + links.append(com) except NoVersionFoundError as e: logger.warning("Trying to get non existent text for ref '{}'. Link refs were: {}".format(top_nref, link.refs)) continue diff --git a/sefaria/model/category.py b/sefaria/model/category.py index 2913b33800..9c97a9a768 100644 --- a/sefaria/model/category.py +++ b/sefaria/model/category.py @@ -9,7 +9,6 @@ from . import schema as schema from . import text as text from . import collection as collection -from sefaria.system.middleware import get_current_user class Category(abstract.AbstractMongoRecord, schema.AbstractTitledOrTermedObject): @@ -319,19 +318,9 @@ def _add_category(self, cat): try: from sefaria.model import library tc = TocCategory(category_object=cat) - user_email = get_current_user() - all_cats = [] # store previously loaded path - text_list = library.get_text_permission_group(user_email) - for c in text_list: - cat_subsets = [c['category'][:i] for i in range(1, len(c['category']) + 1)] - if cat.path in cat_subsets and cat.path not in all_cats: - all_cats.append(cat.path) - parent = self._path_hash[tuple(cat.path[:-1])] if len(cat.path[:-1]) else self._root - parent.append(tc) - self._path_hash[tuple(cat.path)] = tc - # parent = self._path_hash[tuple(cat.path[:-1])] if len(cat.path[:-1]) else self._root - # parent.append(tc) - # self._path_hash[tuple(cat.path)] = tc + parent = self._path_hash[tuple(cat.path[:-1])] if len(cat.path[:-1]) else self._root + parent.append(tc) + self._path_hash[tuple(cat.path)] = tc except KeyError: logger.warning(f"Failed to find parent category for {'/'.join(cat.path)}") @@ -519,7 +508,6 @@ def __init__(self, serial=None, **kwargs): self.order = self._index_object.order[0] def get_index_object(self): - print("index >>>>>>>>>>>>>>>>>>>>>>>>", self._index_object) return self._index_object optional_param_keys = [ diff --git a/sefaria/model/text.py b/sefaria/model/text.py index dc649d4790..e37f20f43d 100644 --- a/sefaria/model/text.py +++ b/sefaria/model/text.py @@ -5077,7 +5077,7 @@ def set_last_cached_time(self): self.last_cached = time.time() # just use the unix timestamp, we dont need any fancy timezone faffing, just objective point in time. scache.set_shared_cache_elem("last_cached", self.last_cached) - def get_toc(self, rebuild=True): + def get_toc(self, rebuild=False): """ Returns the ToC Tree from the cache, DB or by generating it, as needed. """ @@ -5090,7 +5090,7 @@ def get_toc(self, rebuild=True): self.set_last_cached_time() return self._toc - def get_toc_json(self, rebuild=True): + def get_toc_json(self, rebuild=False): """ Returns as JSON representation of the ToC. This is generated on Library start up as an optimization for the API, to allow retrieval of the data with a single call. @@ -5104,7 +5104,7 @@ def get_toc_json(self, rebuild=True): self.set_last_cached_time() return self._toc_json - def get_toc_tree(self, rebuild=True, mobile=False): + def get_toc_tree(self, rebuild=False, mobile=False): """ :param mobile: (Aug 30, 2021) Added as a patch after navigation redesign launch. Currently only adds 'firstSection' to toc for mobile export. This field is no longer required on prod but is still required diff --git a/static/js/BookPage.jsx b/static/js/BookPage.jsx index 72713491af..a688a769c1 100644 --- a/static/js/BookPage.jsx +++ b/static/js/BookPage.jsx @@ -174,7 +174,7 @@ class BookPage extends Component { const heTitle = index ? index.heTitle : title; const category = this.props.category; const isDictionary = this.state.indexDetails && !!this.state.indexDetails.lexiconName; - const categories = Sefaria.index(this.props.title)? Sefaria.index(this.props.title).categories : []; + const categories = Sefaria.index(this.props.title).categories; let currObjectVersions = this.state.currObjectVersions; let catUrl; if (category == "Commentary") { diff --git a/static/js/ReaderApp.jsx b/static/js/ReaderApp.jsx index ac30634500..9ee10a5b2f 100644 --- a/static/js/ReaderApp.jsx +++ b/static/js/ReaderApp.jsx @@ -1109,7 +1109,6 @@ toggleSignUpModal(modalContentKind = SignUpModalKind.Default) { this.showSaved(); } else if (path.match(/\/texts\/.+/)) { - console.log("my",path) this.showLibrary(path.slice(7).split("/")); } else if (path === "/collections") { diff --git a/static/js/TextColumn.jsx b/static/js/TextColumn.jsx index 1f6922139b..e72b850a85 100644 --- a/static/js/TextColumn.jsx +++ b/static/js/TextColumn.jsx @@ -33,16 +33,11 @@ class TextColumn extends Component { // Set on mount, so placeholders aren't rendered server side to prevent intial layout shift this.setState({showScrollPlaceholders: true}); - if (Sefaria.index(this.props.bookTitle)) { - const params = { - content_type: Sefaria.index(this.props.bookTitle).primary_category, - item_id: this.props.bookTitle - } - console.log("primary: ", Sefaria.index(this.props.bookTitle)) - gtag("event", "select_content", params) - } else { - gtag("event", "select_content", {}) - } + const params = { + content_type: Sefaria.index(this.props.bookTitle).primary_category, + item_id: this.props.bookTitle + } + gtag("event", "select_content", params) this.node.addEventListener("scroll", this.handleScroll);