Skip to content

Portrait or landscape option#75

Closed
thejoeyluu wants to merge 7 commits intomainfrom
feat/landscape-orientation
Closed

Portrait or landscape option#75
thejoeyluu wants to merge 7 commits intomainfrom
feat/landscape-orientation

Conversation

@thejoeyluu
Copy link
Copy Markdown
Contributor

Added portrait or landscape mode to layout options

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 leaves orientation from the request (defaulting to portrait). This makes saved landscape sheets download/compile as portrait. Set orientation = cheatsheet.orientation in the if cheat_sheet_id: branch (and re-run validate_layout_params after overrides, or validate cheatsheet.orientation directly) 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 thread backend/api/models.py
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 thread backend/api/tests.py
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
@bdtran2002
Copy link
Copy Markdown
Contributor

bdtran2002 commented May 6, 2026

joey can you remake the PR without changing the test files? @thejoeyluu

@bdtran2002 bdtran2002 closed this May 6, 2026
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.

4 participants