Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
188 commits
Select commit Hold shift + click to select a range
5c1a3ce
Update dependency date-fns to v4
Apr 19, 2025
8b466ba
add link to feedback
Lejinnie Jun 4, 2025
93a6b38
Merge branch 'master' into make-feedback-button-more-clear
Lejinnie Jun 22, 2025
80c6cef
make feedback appear if less than 10 exams are there
Lejinnie Jun 22, 2025
97c9425
Merge remote-tracking branch 'origin/master' into make-feedback-butto…
Byczax Sep 4, 2025
c91602f
Collapsible categories and subcategories
BrachiumX Oct 9, 2025
78c4462
Wrapper around collapse and other suggestions
BrachiumX Oct 23, 2025
8b716c1
Change collapse on feedback page to use the wrapper
BrachiumX Oct 23, 2025
35e5d92
Prettified
BrachiumX Oct 24, 2025
6617405
Merge branch 'collapse-categories' into 'master'
yutotakano Oct 25, 2025
1398a53
Replace all usage of moment.js with date-fns, cutting ~60kB from bund…
yutotakano Sep 14, 2025
8c5f339
Merge branch 'remove-moment' into 'master'
yutotakano Oct 26, 2025
e422bb0
Create a separate route for exam edit page
yutotakano Sep 14, 2025
4ca767b
Run prettier on exam page
yutotakano Sep 14, 2025
f388050
Fix wildcard subroute match in ExamPage to be explicit for consistenc…
yutotakano Oct 26, 2025
0fe3608
Merge branch 'separate-exam-edit-path' into 'master'
yutotakano Oct 26, 2025
6b8f348
Improve commenting UX by adding button at bottom of chain
yutotakano May 6, 2025
6c66081
Remove double shadow from Answer draft editor
yutotakano May 6, 2025
70dba26
Run prettier on answer.tsx
yutotakano May 6, 2025
b6f7fb1
Move answer/comment 'Save' button to the right edge
yutotakano May 6, 2025
b721035
Move 'Load more comments' button in CommentSectionComponent to a comm…
yutotakano Oct 27, 2025
daaa9f5
Make the 'Add Comment' button at bottom of comment chain more compact
yutotakano Oct 27, 2025
083362e
Improve visibility of editor box by increasing shadow on hover and ou…
yutotakano Oct 27, 2025
9072abd
Merge branch 'renovate-date-fns-4.x' into 'master'
yutotakano Oct 27, 2025
40d9179
Fix wrong comment for .chain-reply now that the 'show more' button is…
yutotakano Oct 27, 2025
96adb25
Remove extraneous Group wrapper for chain reply button as it is the s…
yutotakano Oct 27, 2025
f6f5dd1
Format Editor/index.tsx with Prettier
yutotakano Oct 27, 2025
3475bcc
Merge branch 'better-commenting-ux' into 'master'
yutotakano Oct 27, 2025
a4387c5
setup gitlab runner - ci
jaqxues Oct 28, 2025
252540b
Update .gitlab-ci.yml file
jaqxues Oct 28, 2025
52d3437
Create a GitLab CI that performs backend UTs and frontend typecheck &…
yutotakano Oct 27, 2025
99a841a
Fix minio/minio version being wrongly of minio/mc's version in GitLab CI
yutotakano Oct 28, 2025
dc03386
Merge branch 'add-ci-check' into 'master'
yutotakano Oct 29, 2025
a09297d
Rewrite CI for VM executor
yutotakano Oct 29, 2025
3dc17af
Merge branch 'rewrite-ci-for-vm-executor' into 'master'
yutotakano Oct 29, 2025
f5c7d8a
Fix merge-request specific CI running on master branch
yutotakano Oct 29, 2025
eaf2c35
Merge branch 'fix-mr-master' into 'master'
yutotakano Oct 29, 2025
25725a7
Fix frontend CI failing on master branch due to -u flag
yutotakano Oct 30, 2025
4d5ade9
Merge branch 'fix-unbound-variable-in-ci' into 'master'
yutotakano Oct 30, 2025
9012dcf
Change color of three dot icon for comments in user profile page
Oct 30, 2025
a4dcea2
Run prettier on modified file src/components/comment-single.tsx
Oct 30, 2025
4b9f751
Merge branch '379-fix-black-buttons-comments' into 'master'
yutotakano Oct 30, 2025
a24ac0d
Migrate eslint to flat configs, bump version to v9
yutotakano Oct 19, 2025
4136369
Remove deprecated formatting-related eslint rules (Prettier covers them)
yutotakano Oct 19, 2025
7a4d246
Sort eslint rules, perform untyped import check on all files
yutotakano Oct 19, 2025
7027b79
Add a whole lot of eslint exceptions so that our codebase is passable
yutotakano Oct 20, 2025
bcdb017
Fix JSX array in ExamPanel not having a unique key prop
yutotakano Oct 20, 2025
c19910a
Fix Dockerfile referring to legacy eslint JSON instead of flat config
yutotakano Oct 20, 2025
d6b6edb
Format exam panel with Prettier
yutotakano Oct 31, 2025
e9c58cc
Merge branch 'remove-eslint-config-react-app' into 'master'
yutotakano Oct 31, 2025
4863b0a
Turn the grid column layout to a row one when display resolution is s…
BrachiumX Jun 6, 2025
4a1a411
Fix problems
BrachiumX Oct 31, 2025
1391f2d
Autoformat answers.views_search with editor
yutotakano Aug 17, 2025
5bd1274
Add 'category' field for search to filter to results in a single cate…
yutotakano Aug 17, 2025
5ccfe17
Add a unit test for searching with a category filter
yutotakano Aug 17, 2025
488b286
Add unit tests for searching for answers/comments (within category too)
yutotakano Aug 17, 2025
f9bce45
Add a frontend hook for /api/exam/search
yutotakano Aug 27, 2025
9de3305
Add a search bar in nav menu (nonfunctional, but UI near final)
yutotakano Aug 27, 2025
5a13923
Show Unauthorized error in search bar if not logged in
yutotakano Aug 28, 2025
79576fb
Extract headline highlighting from SearchResults into its own component
yutotakano Aug 28, 2025
96bd5cc
Fix highlighting of exam results in search bar by reusing Highlighted…
yutotakano Aug 28, 2025
579914f
Implement optional exam full-text-search with category displayname
yutotakano Aug 29, 2025
8f66469
Expose search option to do full text search of exams with category name
yutotakano Aug 29, 2025
a6e944f
Reduce SearchBar local search's max allowed error cost for better UX
yutotakano Aug 29, 2025
7c91e46
Add SearchBar result UI for answers, comments, exam pages
yutotakano Aug 29, 2025
26e77bb
Add type badge to SearchBar results, move out styles into CSS module
yutotakano Aug 29, 2025
fb4f65a
Limit exam page search result to 4 pages, show highlighted excerpt
yutotakano Aug 29, 2025
68b6083
Use 150ms of debounce in SearchBar to reduce fetches while typing
yutotakano Aug 29, 2025
ed9dbe6
Move searchResults-related error below categoryResults in SearchBar
yutotakano Aug 29, 2025
7f37f3a
Implement React context for get/setting quick search category filter
yutotakano Aug 29, 2025
860d0a6
Rename filter variable in SearchBar component to contextFilter for cl…
yutotakano Aug 29, 2025
03ab2e0
Implement functional filter dropdown selection logic in SearchBar
yutotakano Aug 30, 2025
488ee47
Fix infinite re-render loop bug with useQuickSearchFilter
yutotakano Aug 30, 2025
d9677db
Add short comment explaining use of useCombobox in SearchBar
yutotakano Aug 30, 2025
6bcb56e
Trigger re-search when SearchBox filter dropdown is changed
yutotakano Aug 30, 2025
262f75f
Implement working up/down type-aware selector in SearchBar
yutotakano Aug 30, 2025
a9275d6
Extract quick search result into its own component
yutotakano Aug 30, 2025
3caf39c
Add back quick search result fade above 100px until max 150px
yutotakano Aug 30, 2025
45cf3db
Remove from SearchBar CSS module styles that were migrated to QuickSe…
yutotakano Aug 30, 2025
75619a9
Improve quick search highlight color and adapt to dark/light theme
yutotakano Aug 30, 2025
ab37d63
Add labels on top of dividers on quick search results
yutotakano Aug 30, 2025
3fe90ab
Move Quick Search input button styles to CSS module and use better co…
yutotakano Aug 30, 2025
a1895a5
Rename SearchBar to QuickSearchBox and move into its own folder
yutotakano Aug 30, 2025
5617ccb
Move QuickSearchFilterContext and its hook into its own file
yutotakano Aug 30, 2025
fc2e01f
Clean up unused imports in QuickSearchBox
yutotakano Aug 30, 2025
aaa603d
Implement ability to press Enter to navigate to quick search results
yutotakano Aug 31, 2025
41a7a25
Implement mouse click navigation & styles for quick search results
yutotakano Aug 31, 2025
060f63d
Fix duplicate key errors in quick search for exam pages from same exam
yutotakano Aug 31, 2025
919cd0a
Fix /category/:slug and /exams/:filename not refreshing when params c…
yutotakano Aug 31, 2025
49f7358
Fix /category/:slug and /exams/:filename showing stale data while ref…
yutotakano Aug 31, 2025
0d3d616
Improve quick search UX by selecting text input content upon opening
yutotakano Aug 31, 2025
f0883ea
Fix long quick search results cropping on the top side when it should…
yutotakano Aug 31, 2025
32ad9e5
Show explicit message when quick search has no results
yutotakano Aug 31, 2025
6645145
Improve rendering of answers/comments in quick search by showing auth…
yutotakano Aug 31, 2025
2a37ad0
Make badge optional for QuickSearchResult
yutotakano Aug 31, 2025
9df09fd
Add a quick search result entry at bottom to navigate to /search
yutotakano Aug 31, 2025
aba6da5
Fix quick search box triggering when composing answers/comments/searc…
yutotakano Aug 31, 2025
d006101
Fix /search page not refreshing input box when query params changed v…
yutotakano Aug 31, 2025
3bfe94f
Fix quick search badge not being center-aligned with respect to text
yutotakano Aug 31, 2025
b12b198
Remove full-page Search from nav bar as Quick Search links to it
yutotakano Aug 31, 2025
f3d26ca
Implement scrollIntoView for quick search when navigating long list b…
yutotakano Aug 31, 2025
2d893af
Remove category results from quick search when a filter is set
yutotakano Aug 31, 2025
0f2057a
Fix the extra dimmed text in quick search results being hard to read …
yutotakano Aug 31, 2025
14500a4
Set MaxFragments=0 when searching exam names in backend to fix partia…
yutotakano Aug 31, 2025
8c8e956
Change quick search exam result format to 'Category Name - Exam Name'
yutotakano Aug 31, 2025
af3902b
Fix long quick search results fading selection highlight too
yutotakano Aug 31, 2025
ff325ba
Fix text contrast ratios on themes with darker primary colors
yutotakano Sep 1, 2025
fd8c5f1
Fixed typing build issues
jupieper Sep 2, 2025
0bdaf6a
Fix local category search not working for non-admins
yutotakano Sep 3, 2025
5226176
Implement mod+K as alternative optional shortcut for command palette
yutotakano Oct 28, 2025
118cb03
Fix quick search results to comments requiring parent answer's long ID
yutotakano Oct 29, 2025
719a179
Lengthen quick search dialogue transition from 50ms to 100ms to preve…
yutotakano Oct 29, 2025
01fe1f6
Improve QuickSearch's visual accessibility by outlining input box and…
yutotakano Oct 30, 2025
0f4bc67
Add a loader indicator for QuickSearchBox to visually show network re…
yutotakano Oct 30, 2025
1ca6b15
Format QuickSearch frontend files with Prettier
yutotakano Oct 30, 2025
8707620
Allow Control+K to also hide quick search
yutotakano Oct 31, 2025
80d2576
Make search box and shortcut help sticky in quick search modal
yutotakano Oct 31, 2025
453ffac
Show Cmd/Ctrl K as the quick search shortcut in the UI instead of slash
yutotakano Oct 31, 2025
edb0b27
Limit quick search results to 100px height instead of 150px for more …
yutotakano Oct 31, 2025
015d91e
Promote Control K to unchangable default shortcut for Quick Search
yutotakano Oct 31, 2025
0ece496
Format files that were modified with QuickSearch
yutotakano Oct 31, 2025
f77c3d2
Reorder the useOs hook in QuickSearchBox to group it with isMobile
yutotakano Oct 31, 2025
c3146a5
Merge branch 'improve-search-ux' into 'master'
yutotakano Nov 1, 2025
02b6f9b
Get rid of extra parent div of buttons
BrachiumX Nov 1, 2025
150c76d
Merge branch '366-show-answers-button-is-cut-off-in-mobile-screens' i…
yutotakano Nov 1, 2025
f560631
Disable double scroll bar that occurs with staging data (core reason …
yutotakano Nov 1, 2025
01e06de
Reduce debounce timeout on QuickSearch query so it feels more responsive
yutotakano Nov 1, 2025
8a88eaf
Merge branch 'improve-search-ux' into 'master'
yutotakano Nov 1, 2025
506343b
Change hide so that it hides the section without deleting the answers
BrachiumX Nov 1, 2025
35fe7da
Fix QuickSearch having y overflow due to KaTeX MathML being absolutel…
yutotakano Nov 1, 2025
bea1716
Merge branch 'improve-search-ux' into 'master'
yutotakano Nov 1, 2025
ba2b8e3
Merge branch 'warning-when-deleting-sections' into 'master'
yutotakano Nov 1, 2025
ab21984
Limit lenght of document titles
Nov 1, 2025
c57691b
new feedback design + proper counting of exams
Lejinnie Nov 1, 2025
175b314
Limit title lenght in category card
Nov 1, 2025
8a885d2
Update dependency vite-tsconfig-paths to v5
Nov 2, 2025
9c713d7
Fix regression in adding cuts for already finished exams (request fro…
yutotakano Nov 3, 2025
262d8ff
Merge branch 'hotfix-cut-with-finished-cuts-true' into 'master'
yutotakano Nov 3, 2025
7a9095e
Fix incorrect patch (35fe7dab8) for KaTeX overflow in quick search
yutotakano Nov 3, 2025
aca5494
Merge branch '380-long-document-titles-overflow' into 'master'
yutotakano Nov 3, 2025
6e23066
Allow changing the document file order
BrachiumX Oct 31, 2025
fa6380a
Add order field for documentfiles in create_testdata
BrachiumX Nov 1, 2025
4dd6a99
Use json for direction and make the transaction atomic
BrachiumX Nov 3, 2025
8c09bf3
Merge branch 'hotfix-extra-space-in-quick-search' into 'master'
yutotakano Nov 4, 2025
669c4ec
Merge branch 'renovate-vite-tsconfig-paths-5.x' into 'master'
yutotakano Nov 4, 2025
d4ec087
Merge branch '362-allow-users-to-reorder-document-files' into 'master'
yutotakano Nov 4, 2025
a8f1422
make feedback link default color
Lejinnie Nov 5, 2025
b503350
Merge branch 'master' into make-feedback-button-more-clear
Lejinnie Nov 5, 2025
ad91fb2
Make homepage cards feel softer to touch
yutotakano May 6, 2025
8abff92
Make document cards feel softer to touch
yutotakano May 6, 2025
44e9f22
Make exam cards feel softer to touch
yutotakano May 6, 2025
8152faf
Change hover border colour to a more subtle color than brand
yutotakano May 6, 2025
ca1a567
Change hover border colour to be more prominent
yutotakano May 6, 2025
4c014d7
Fix outline being 1px thicker than rest of Mantine UI norms
yutotakano Jul 8, 2025
715fe75
Only show focus ring for category cards with tab nav, not on click
yutotakano Oct 6, 2025
7678495
Make exam card parent component a Link so you can click anywhere on it
yutotakano Oct 19, 2025
9d05941
Apply focusOutline and hoverShadow styles to Add Document/Category bu…
yutotakano Oct 19, 2025
328c1ee
Remove unused imports from HomePage
yutotakano Nov 1, 2025
58e8005
Merge branch 'softer-category-cards' into 'master'
yutotakano Nov 6, 2025
fcc2a4b
use yarn.lock from master
Lejinnie Nov 6, 2025
aa2317d
Merge branch 'make-feedback-button-more-clear' into 'master'
yutotakano Nov 7, 2025
8bcb7d9
Refactor away custom Route to a wrapper component instead
yutotakano Sep 7, 2025
abf437f
Fix 404 route no longer matching after using AuthenticatedRoutes
yutotakano Nov 13, 2025
c79abd9
Merge branch 'remove-userroutes' into 'master'
yutotakano Nov 14, 2025
08d2821
Revert "Merge branch 'remove-userroutes' into 'master'"
yutotakano Nov 16, 2025
77a81f5
Merge branch 'revert-c79abd92' into 'master'
yutotakano Nov 16, 2025
acb7e76
Format MarkdownText with Prettier
yutotakano Nov 25, 2025
664b649
Apply eslint suggestions to useCategorisedNavigation
yutotakano Nov 25, 2025
dd1f960
Fix currentSelection object being recreated on keystroke if result is…
yutotakano Nov 25, 2025
9919d45
Prevent re-renders of quick search result content if only changing se…
yutotakano Nov 25, 2025
ea9cf7e
Fix eslint wanting to use an uglier syntax for void callbacks
yutotakano Nov 25, 2025
b35cca1
Add comment explaining why categoryResults data is [] if !isGlobal
yutotakano Nov 25, 2025
7cbadb7
Address eslint feedback on use of null-coalescing operator in QuickSe…
yutotakano Nov 25, 2025
ce938f0
Use unknown instead of any for type accuracy in maxdepth function
yutotakano Nov 25, 2025
934b55e
Extract itemToPath to utils/search-utils to address code duplication
yutotakano Nov 25, 2025
5db98e8
Add TODO comment for duplicate calls to itemToPath from separate files
yutotakano Nov 25, 2025
921387f
Fix useSearch import being erroneously removed in 934b55e6
yutotakano Nov 25, 2025
d53f1bc
Merge branch 'reduce-rerender-in-search' into 'master'
yutotakano Nov 25, 2025
d5ed80c
Fix browser freezing when PostgreSQL decides not to highlight any mat…
yutotakano Nov 25, 2025
9244155
Combine HighlightedMarkdown functionality into MarkdownText
yutotakano Nov 25, 2025
d43a705
Merge branch 'fix-infinite-loop-search' into 'master'
yutotakano Nov 25, 2025
c3ee357
Change home-page loader to be more subtle
yutotakano Sep 14, 2025
eb676a9
Cache the homepage category data in Local Storage for faster load
yutotakano Sep 14, 2025
b0e2f41
Format the subtle home-page loader with Prettier
yutotakano Nov 26, 2025
33e6618
Merge branch 'faster-perceived-home-page' into 'master'
yutotakano Nov 26, 2025
dd67eeb
Merge remote-tracking branch 'ethz/master' into upstream-integration
yutotakano Nov 26, 2025
f9d3456
Address lint feedback in UoE-specific paths after upstream upgraded t…
yutotakano Nov 26, 2025
e5f5904
Remove popover hint on exam list that is ETHZ specific and doesn't ap…
yutotakano Nov 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ARG git_commit
COPY ./frontend/tsconfig.json \
./frontend/postcss.config.cjs \
./frontend/vite.config.ts \
./frontend/.eslintrc.json \
./frontend/eslint.config.mjs \
./frontend/.env.production \
./frontend/.prettierrc.json .
COPY ./frontend/public ./public
Expand Down
187 changes: 174 additions & 13 deletions backend/answers/test/tests_search.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from answers.models import Exam, ExamPage, ExamType
from testing.tests import ComsolTestExamsData
from testing.tests import ComsolTestExamData
from categories.models import Category
import logging
from time import sleep
Expand All @@ -11,22 +11,183 @@
logger = logging.getLogger(__name__)


class TestSearch(ComsolTestExamsData):
def test_search_page(self):
class TestSearch(ComsolTestExamData):
add_answers = True
add_comments = True

def mySetUp(self, call_my_setup=True):
"""Upload a test PDF file and create a search vector for it."""
location = join(dirname(__file__), "search_test.pdf")
with open(location, "rb") as infile:
filename = self.post(
"/api/exam/upload/exam/",
{"category": "default", "displayname": "Test", "file": infile},
)["filename"]
ExamPage.objects.update(search_vector=SearchVector("text"))
res = self.post("/api/exam/search/", {"term": "uniqueidthatwecansearch"})[
"value"
]
self.assertEqual(len(res), 1)
match = res[0]
self.assertEqual(match["type"], "exam")
self.assertEqual(len(match["headline"]), 1)
self.assertEqual(match["category_displayname"], "default")
self.assertEqual(match["category_slug"], "default")
self.assertEqual(len(match["pages"]), 1)

# Edit the first answer to have a unique text that we can search
self.answers[0].text = "mywacky answer"
self.answers[0].save()
# This is in category self.answers[0].answer_section.exam.category.slug

# Edit the first comment to have a unique text that we can search
self.comments[0].text = "mywacky comment"
self.comments[0].save()

def test_search_exam(self):
"""Test searching for a specific term in an exam."""
# First check that we get nothing if we don't include exams
res = self.post(
"/api/exam/search/",
{"term": "uniqueidthatwecansearch", "include_exams": False},
)["value"]
self.assertEqual(len(res), 0)

# Then check that we get a result if we include exams
res = self.post("/api/exam/search/", {"term": "uniqueidthatwecansearch"})[
"value"
]
self.assertEqual(len(res), 1)

# Check that the result is what we expect
match = res[0]
self.assertEqual(match["type"], "exam")
self.assertEqual(len(match["headline"]), 1)
self.assertEqual(match["category_displayname"], "default")
self.assertEqual(match["category_slug"], "default")
self.assertEqual(len(match["pages"]), 1)

def test_search_exam_with_category_filter(self):
"""Test that searching with a category filter works as expected when
specifying a non-matching category vs a matching category.
"""
res = self.post(
"/api/exam/search/",
{"term": "uniqueidthatwecansearch", "category": "not_default"},
)["value"]
self.assertEqual(len(res), 0)

res = self.post(
"/api/exam/search/",
{"term": "uniqueidthatwecansearch", "category": "default"},
)["value"]
self.assertEqual(len(res), 1)

def test_search_answer(self):
"""Test searching for a specific term in an answer."""
res = self.post(
"/api/exam/search/",
{"term": "mywacky answer", "include_answers": False},
)["value"]
self.assertEqual(len(res), 0)

res = self.post(
"/api/exam/search/",
{"term": "mywacky answer"},
)["value"]
self.assertEqual(len(res), 1)

match = res[0]
self.assertEqual(match["type"], "answer")
self.assertEqual(
match["category_displayname"],
self.answers[0].answer_section.exam.category.displayname,
)
self.assertEqual(
match["category_slug"], self.answers[0].answer_section.exam.category.slug
)

def test_search_answer_with_category_filter(self):
"""Test that searching for an answer with a category filter works as
expected when specifying a non-matching category vs a matching category.
"""
res = self.post(
"/api/exam/search/",
{"term": "mywacky answer", "category": "something"},
)["value"]
self.assertEqual(len(res), 0)

res = self.post(
"/api/exam/search/",
{
"term": "mywacky answer",
"category": self.answers[0].answer_section.exam.category.slug,
},
)["value"]
self.assertEqual(len(res), 1)

def test_search_comment(self):
"""Test searching for a specific term in a comment."""
res = self.post(
"/api/exam/search/",
{"term": "mywacky comment", "include_comments": False},
)["value"]
self.assertEqual(len(res), 0)

res = self.post(
"/api/exam/search/",
{"term": "mywacky comment"},
)["value"]
self.assertEqual(len(res), 1)

match = res[0]
self.assertEqual(match["type"], "comment")
self.assertEqual(
match["category_displayname"],
self.comments[0].answer.answer_section.exam.category.displayname,
)
self.assertEqual(
match["category_slug"],
self.comments[0].answer.answer_section.exam.category.slug,
)

def test_search_comment_with_category_filter(self):
"""Test that searching for a comment with a category filter works as
expected when specifying a non-matching category vs a matching category.
"""
res = self.post(
"/api/exam/search/",
{"term": "mywacky comment", "category": "something"},
)["value"]
self.assertEqual(len(res), 0)

res = self.post(
"/api/exam/search/",
{
"term": "mywacky comment",
"category": self.comments[0].answer.answer_section.exam.category.slug,
},
)["value"]
self.assertEqual(len(res), 1)

def test_search_answer_comment(self):
"""Test searching for a specific term in both answers and comments."""
res = self.post(
"/api/exam/search/",
{"term": "mywacky", "include_comments": True, "include_answers": True},
)["value"]
self.assertEqual(len(res), 2)

# Specifying category shouldn't change result - they are both in it
res = self.post(
"/api/exam/search/",
{
"term": "mywacky",
"include_comments": True,
"include_answers": True,
"category": self.comments[0].answer.answer_section.exam.category.slug,
},
)["value"]
self.assertEqual(len(res), 2)

# Specifying a non-matching category should return no results
res = self.post(
"/api/exam/search/",
{
"term": "mywacky",
"include_comments": True,
"include_answers": True,
"category": "something",
},
)["value"]
self.assertEqual(len(res), 0)
3 changes: 0 additions & 3 deletions backend/answers/views_cuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ def edit_cut(request, oid):
section.hidden = request.POST['hidden'] == 'true'
if 'has_answers' in request.POST:
section.has_answers = request.POST['has_answers'] == 'true'
if not section.has_answers:
answers = Answer.objects.filter(answer_section=oid)
answers.delete()

section.cut_version += 1
section.save()
Expand Down
Loading