Portrait or landscape option#75
Closed
thejoeyluu wants to merge 7 commits intomainfrom
Closed
Conversation
impxcts
approved these changes
May 6, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
backend/api/views.py:375
- When compiling via
cheat_sheet_id, the endpoint overwrites columns/font_size/margins/spacing from the saved CheatSheet but leavesorientationfrom the request (defaulting to portrait). This makes saved landscape sheets download/compile as portrait. Setorientation = cheatsheet.orientationin theif cheat_sheet_id:branch (and re-runvalidate_layout_paramsafter overrides, or validatecheatsheet.orientationdirectly) so the compiled output matches the persisted layout.
orientation = request.data.get("orientation", "portrait")
columns, font_size, margins, spacing, orientation = validate_layout_params(columns, font_size, margins, spacing, orientation)
if cheat_sheet_id:
cheatsheet = get_object_or_404(CheatSheet, pk=cheat_sheet_id, user=request.user)
columns = cheatsheet.columns
font_size = cheatsheet.font_size
margins = cheatsheet.margins
spacing = cheatsheet.spacing
content = cheatsheet.build_full_latex()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
1027
to
+1031
| setSpacing, | ||
| margins, | ||
| setMargins, | ||
| orientation, | ||
| setOrientation, |
Comment on lines
38
to
+42
| columns = models.IntegerField(default=4) | ||
| margins = models.CharField(max_length=20, default="0.15in") | ||
| font_size = models.CharField(max_length=10, default="9pt") | ||
| spacing = models.CharField(max_length=10, default="small") | ||
| orientation = models.CharField(max_length=20, default="portrait") |
Comment on lines
1371
to
+1402
| resp = api_client.post( | ||
| "/api/compile/", | ||
| { | ||
| "content": raw, | ||
| "normalize_only": True, | ||
| "columns": 2, | ||
| "font_size": "8pt", | ||
| "spacing": "tiny", | ||
| "margins": "0.25in", | ||
| "orientation": "portrait", | ||
| }, | ||
| format="json", | ||
| ) | ||
|
|
||
| assert resp.status_code == 200 | ||
| data = resp.json() | ||
| tex = data["tex_code"] | ||
| assert data["layout"] == { | ||
| "columns": 2, | ||
| "font_size": "8pt", | ||
| "spacing": "tiny", | ||
| "margins": "0.25in", | ||
| "orientation": "portrait", | ||
| } | ||
| assert "\\begin{multicols}{2}" in tex | ||
| assert "\\fontsize{8pt}{8.8pt}\\selectfont" in tex | ||
| assert "\\setlength{\\parskip}{0pt}" in tex | ||
| assert "% @cheatsheet-layout columns: 2 | change layout options up top to update columns" in tex | ||
| assert "% @cheatsheet-layout font_size: 8pt | change layout options up top to update text size" in tex | ||
| assert "% @cheatsheet-layout spacing: tiny | change layout options up top to update spacing" in tex | ||
| assert "% @cheatsheet-layout margins: 0.25in | change layout options up top to update margins" in tex | ||
| assert "orientation: portrait" in tex |
Contributor
|
joey can you remake the PR without changing the test files? @thejoeyluu |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added portrait or landscape mode to layout options