Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/sc 28125/backend for sheets with ref #1940

Conversation

stevekaplan123
Copy link
Contributor

For /api/sheets/ref, passed parameter include_collections to get_sheets_for_ref, which in turn calls get_collections_with_sheets. This function returns every public collection that has a sheet in sheet_ids so that get_sheets_for_ref returns sheets with a collections field. Instead of including the whole collection, I include the name and slug only. I also added a 'dateCreated' field since on the front end, in the "Sheets With" page, each sheet entry displays a date.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tabs throughout this PR seem way too big

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure github is formatting it strangely. The tabs don't look weird on my screen

@@ -874,6 +889,9 @@ def get_sheets_for_ref(tref, uid=None, in_collection=None):
"category": "Sheets", # ditto
"type": "sheet", # ditto
}
if include_collections:
sheet_data["collections"] = sheet_id_to_collection[sheet["id"]]
sheet_data["dateCreated"] = sheet["dateCreated"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is dateCreated part of this if statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure where to put it. It's supposed to show up next to the user profile in SearchSheetResult now. It's not necessary for the related API to have access to dateCreated, so I didn't add dateCreated to the big "sheet_data = {...}" but it is necessary for the sheets ref API to have access to dateCreated. But it is definitely confusing to set dateCreated only when include_collections is True, so maybe dateCreated should just be set in the original "sheet_data = {...}". What do you think?

@@ -1020,7 +1020,7 @@ def sheets_by_ref_api(request, ref):
"""
API to get public sheets by ref.
"""
return jsonResponse(get_sheets_for_ref(ref))
return jsonResponse(get_sheets_for_ref(ref, include_collections=True))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this API should take a URL parameter that indicates whether it should include collections. For boolean parameters, our standard is to use 0 to mean false and 1 to mean true. Here's an example bool(int(request.GET.get("annotate", 0)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants