Skip to content

Commit

Permalink
Merge remote-tracking branch 'local/s4d'
Browse files Browse the repository at this point in the history
  • Loading branch information
stevekaplan123 committed Jan 26, 2023
2 parents 1cf9aad + 2d39a03 commit 23e1a49
Show file tree
Hide file tree
Showing 31 changed files with 877 additions and 199 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/continuous.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ jobs:
flavor: |
latest=true
- name: build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
cache-from: type=registry, ref=sefaria-${{ matrix.app }}/cache
cache-to: type=registry, ref=sefaria-${{ matrix.app }}/cache, mode=max
# cache-from: type=registry,ref=gcr.io/${{ secrets.DEV_PROJECT }}/sefaria-${{ matrix.app }}/cache
# cache-to: type=registry,ref=gcr.io/${{ secrets.DEV_PROJECT }}/sefaria-${{ matrix.app }}/cache, mode=max
context: .
push: true
file: ./build/${{ matrix.app }}/Dockerfile
Expand Down Expand Up @@ -119,10 +119,10 @@ jobs:
id: get-sha
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
cache-from: type=registry, ref=sefaria-${{ matrix.app }}/cache
cache-to: type=registry, ref=sefaria-${{ matrix.app }}/cache, mode=max
# cache-from: type=registry,ref=gcr.io/${{ secrets.DEV_PROJECT }}/sefaria-${{ matrix.app }}/cache
# cache-to: type=registry,ref=gcr.io/${{ secrets.DEV_PROJECT }}/sefaria-${{ matrix.app }}/cache,mode=max
context: .
push: true
build-args: |
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/production-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ jobs:
flavor: |
latest=true
- name: build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
cache-from: type=registry, ref=${{ secrets.IMAGE_NAME }}-${{ matrix.app }}/cache
cache-to: type=registry, ref=${{ secrets.IMAGE_NAME }}-${{ matrix.app }}/cache, mode=max
# cache-from: type=registry,ref=$gcr.io/${{ secrets.PROD_GKE_PROJECT_PROJECT }}/{{ secrets.IMAGE_NAME }}-${{ matrix.app }}/cache
# cache-to: type=registry,ref=$gcr.io/${{ secrets.PROD_GKE_PROJECT }}/{{ secrets.IMAGE_NAME }}-${{ matrix.app }}/cache,mode=max
context: .
push: true
file: ./build/${{ matrix.app }}/Dockerfile
Expand Down Expand Up @@ -114,10 +114,10 @@ jobs:
flavor: |
latest=true
- name: build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
cache-from: type=registry, ref=${{ secrets.IMAGE_NAME }}-${{ matrix.app }}/cache
cache-to: type=registry, ref=${{ secrets.IMAGE_NAME }}-${{ matrix.app }}/cache, mode=max
# cache-from: type=registry,ref=${{ secrets.IMAGE_NAME }}-${{ matrix.app }}/cache
# cache-to: type=registry,ref=${{ secrets.IMAGE_NAME }}-${{ matrix.app }}/cache,mode=max
context: .
push: true
build-args: |
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/release-contextus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,9 @@ jobs:
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
verify:
runs-on: ubuntu-latest
needs: semantic-release
steps:
- run: echo ${{ needs.semantic-release.outputs.version }}
- name: fail if no version
if: steps.semantic.outputs.new-release-published == 'false'
run: exit 1
deploy:
needs: semantic-release
uses: ./.github/workflows/production-deploy.yaml
Expand Down
48 changes: 25 additions & 23 deletions reader/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3133,14 +3133,15 @@ def topics_api(request, topic, v2=False):
API to get data or edit data for an existing topic
"""
if request.method == "GET":
with_html = bool(int(request.GET.get("with_html", False)))
with_links = bool(int(request.GET.get("with_links", False)))
annotate_links = bool(int(request.GET.get("annotate_links", False)))
group_related = bool(int(request.GET.get("group_related", False)))
with_refs = bool(int(request.GET.get("with_refs", False)))
annotate_time_period = bool(int(request.GET.get("annotate_time_period", False)))
with_indexes = bool(int(request.GET.get("with_indexes", False)))
ref_link_type_filters = set(filter(lambda x: len(x) > 0, request.GET.get("ref_link_type_filters", "").split("|")))
response = get_topic(v2, topic, with_links=with_links, annotate_links=annotate_links, with_refs=with_refs, group_related=group_related, annotate_time_period=annotate_time_period, ref_link_type_filters=ref_link_type_filters, with_indexes=with_indexes)
response = get_topic(v2, topic, with_html=with_html, with_links=with_links, annotate_links=annotate_links, with_refs=with_refs, group_related=group_related, annotate_time_period=annotate_time_period, ref_link_type_filters=ref_link_type_filters, with_indexes=with_indexes)
return jsonResponse(response, callback=request.GET.get("callback", None))
elif request.method == "POST":
if not request.user.is_staff:
Expand All @@ -3156,38 +3157,39 @@ def topics_api(request, topic, v2=False):

if topic_data["origCategory"] != topic_data["category"]:
# change IntraTopicLink from old category to new category and set newSlug if it changed
# special casing for moving to and fro the Main Menu
# and if we move the topic from top level, we must create one

origLinkDict = {"fromTopic": topic_obj.slug, "toTopic": topic_data["origCategory"], "linkType": "displays-under"}
# special casing for moving to the Main Menu, where we delete the IntraTopicLink that linked it to its previous parent
from_topic = topic_obj.slug
orig_to_topic = topic_data["origCategory"]
orig_link_dict = {"fromTopic": from_topic, "toTopic": orig_to_topic, "linkType": "displays-under"}
orig_link = IntraTopicLink().load(orig_link_dict)
has_link_to_itself = (from_topic == orig_to_topic) and orig_link is not None

if topic_data["category"] == "Main Menu":
# create new link if existing link links topic to itself, as this means the topic
# functions as both a topic and category. otherwise modify existing link
origLink = IntraTopicLink() if topic_data["origCategory"] == topic_obj.slug else IntraTopicLink().load(origLinkDict)

# a top-level topic won't display properly if it doesn't have children so need to set shouldDisplay flag
child = IntraTopicLink().load({"linkType": "displays-under", "toTopic": topic_obj.slug})
if child is None:
# a top-level topic won't display properly if it doesn't have children so need to set shouldDisplay flag
topic_obj.shouldDisplay = True
topic_obj.save()

origLink.delete() # if we move topic to top level, we delete the IntraTopicLink
if orig_link: # top of the tree doesn't need an IntraTopicLink to its previous parent
orig_link.delete()

# if topic has sources and we dont create an IntraTopicLink to itself, they wont be accessible from the topic TOC
linkToItself = {"fromTopic": topic_obj.slug, "toTopic": topic_obj.slug, "dataSource": "sefaria",
link_to_itself = {"fromTopic": from_topic, "toTopic": from_topic, "dataSource": "sefaria",
"linkType": "displays-under"}
if getattr(topic_obj, "numSources", 0) > 0 and IntraTopicLink().load(linkToItself) is None:
IntraTopicLink(linkToItself).save()
if getattr(topic_obj, "numSources", 0) > 0 and IntraTopicLink().load(link_to_itself) is None:
# if topic has sources and we dont create an IntraTopicLink to itself, they wont be accessible from the topic TOC
IntraTopicLink(link_to_itself).save()
else:
# create new link (1) if existing link links topic to itself, as this means the topic
# functions as both a topic and category, or (2) if topic is being moved out of main menu, as this means no current link may exist
origLink = IntraTopicLink() if topic_data["origCategory"] in ["Main Menu", topic_obj.slug] else IntraTopicLink().load(origLinkDict)
origLink.fromTopic = topic_obj.slug
origLink.toTopic = topic_data["category"]
origLink.linkType = "displays-under"
origLink.dataSource = "sefaria"
origLink.save()
# (1) create new link if existing link links topic to itself, as this means the topic
# functions as both a topic and category and we don't want to modify that link, or
# (2) create new link if topic is being moved out of main menu, as this means no current IntraTopicLink may exist
# (3) otherwise, modify existing link so that it has new category
link = IntraTopicLink() if (has_link_to_itself or orig_to_topic == "Main Menu") else orig_link
link.fromTopic = from_topic
link.toTopic = topic_data["category"]
link.linkType = "displays-under"
link.dataSource = "sefaria"
link.save()

topic_needs_save = False # will get set to True if isTopLevelDisplay or description is changed

Expand Down
Loading

0 comments on commit 23e1a49

Please sign in to comment.