-
Notifications
You must be signed in to change notification settings - Fork 5
Search saved searches #42
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
Open
Sentient07
wants to merge
8
commits into
Karplus-Lab-OSU:develop
Choose a base branch
from
Sentient07:Search-Saved-Searches
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3d4a8ae
Initial Commit
Sentient07 a5c5ad7
Commit 2: Added tests
Sentient07 f2dd7a8
Cleaned the code
Sentient07 f6d7606
Minor change
Sentient07 4b6062e
Global search feature added
Sentient07 1672269
Suggested changes made
Sentient07 5d5e12e
suggested changes made
Sentient07 23e4cd9
moved the css block back
Sentient07 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| {% extends 'base.html' %} | ||
|
|
||
| {% block content %} | ||
|
|
||
| <head> Matched Searches </head> | ||
|
|
||
| <style> | ||
|
|
||
| table { | ||
| border-collapse: collapse; | ||
| } | ||
|
|
||
| .sSearch{ | ||
| border: 1px solid black; | ||
| } | ||
| </style> | ||
|
|
||
| <table id="search_matches"> | ||
| <tbody> | ||
| <tr> | ||
| <th class="sSearch"> | ||
| Time stamp | ||
| </th> | ||
|
|
||
| <th class="Search"> | ||
| Tags | ||
| </th> | ||
|
|
||
| <th class="sSearch"> | ||
| Description | ||
| </th> | ||
|
|
||
| <th class="sSearch"> | ||
| Title | ||
| </th> | ||
| <!-- An empty tag because CSS fails to render table border if it has a text --> | ||
| <th class="sSearch"> | ||
|
|
||
| </th> | ||
|
|
||
| <th class="sSearch"> | ||
| User | ||
| </th> | ||
|
|
||
| <th class="sSearch"> | ||
| Public ? | ||
| </th> | ||
|
|
||
| </tr> | ||
|
|
||
| <p> | ||
| {% for var in matches %} | ||
|
|
||
| <p> | ||
| <tr> | ||
| <td class="sSearch">{{ var.timestamp }}</td> | ||
|
|
||
| <td class="sSearch"> {{ var.tags }} </td> | ||
|
|
||
| <td class="sSearch">{{ var.description }}</td> | ||
|
|
||
| <td class="sSearch">{{ var.title }}</td> | ||
|
|
||
| <!-- An empty tag because CSS fails to render table border if it has a text --> | ||
|
|
||
| <td class="sSearch"> </td> | ||
|
|
||
| <td class="sSearch"> {{ var.user.username }} </td> | ||
|
|
||
| <td class="sSearch">{{ var.isPublic }}</td> | ||
|
|
||
| </tr> | ||
| </p> | ||
|
|
||
| {% endfor %} | ||
| </p> | ||
| </tbody> | ||
| </table> | ||
| {% endblock %} |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| {% extends "base.html" %} | ||
| {% block content %} | ||
| <p style="text-align:center;">Sorry, the saved Search that you're trying to search does not exist.</p> | ||
| {% endblock %} |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ | |
| class RegistrationTestCase(TestCase): | ||
|
|
||
|
|
||
| fixtures = ['pgd_core'] | ||
| fixtures = ['users'] | ||
| default_url = "http://testserver" | ||
| test_email = {'email' : '[email protected]'} | ||
| test_credentials = {'username':'test_user', 'password':'hello'} | ||
|
|
@@ -93,7 +93,7 @@ def test_save_search(self): | |
| post_credentials = test_client.post(get_profile.redirect_chain[-1][0], self.test_credentials, follow=True) | ||
| self.assertEqual(post_credentials.status_code, 200) | ||
| profile_page = test_client.get(reverse('generic_profile', args=('test_user',))) | ||
| self.assertIn('<td class="sSearch">False</td>' , profile_page.content) | ||
| self.assertIn('<td class="sSearch"> False </td>' , profile_page.content) | ||
|
|
||
| def test_search_user(self): | ||
|
|
||
|
|
@@ -110,3 +110,52 @@ def test_search_user(self): | |
| #No matches | ||
| search_none = test_client.get(reverse('user-search'), {'q' : 'whatever'}, redirect=True) | ||
| self.assertEqual(search_none['Location'], self.default_url+reverse('notfound')) | ||
|
|
||
| def test_search_saved_searches(self): | ||
|
|
||
| test_client = Client() | ||
|
|
||
| #search before login, searches for some tag, checks if.. | ||
| #The tag that is not related to the search is not present | ||
|
|
||
| #Local Search | ||
| search = test_client.post(reverse('generic_profile', | ||
| args=('test_user',)), {'query' : 'Asp, cys', 'search_type' : 'LocalSearch'}, | ||
| follow=True) | ||
|
|
||
| #Asserts if non-Public search is not listed | ||
| self.assertNotIn('<td class="sSearch">False</td>' , search.content) | ||
| self.assertNotIn('<td class="sSearch"> Ala, Asn, Arg </td>', search.content) | ||
|
|
||
| #Global Search | ||
| search = test_client.post(reverse('generic_profile', | ||
| args=('test_user',)), {'query' : 'Asp, cys', 'search_type' : 'GlobalSearch'}, | ||
| follow=True) | ||
|
|
||
| #Asserts if non-Public search is not listed | ||
| self.assertNotIn('<td class="sSearch">False</td>' , search.content) | ||
| self.assertNotIn('<td class="sSearch"> Ala, Asn, Arg </td>', search.content) | ||
| #Checks for presence of User: Test | ||
| self.assertIn('<td class="sSearch"> test </td>', search.content) | ||
|
|
||
| #Search After login | ||
| get_profile = test_client.get(reverse('user_profile'), follow=True) | ||
| self.assertEqual(get_profile.status_code, 200) | ||
| post_credentials = test_client.post(get_profile.redirect_chain[-1][0], | ||
| self.test_credentials, follow=True) | ||
| self.assertEqual(post_credentials.status_code, 200) | ||
| #Local Search | ||
| local_search_result = test_client.post( post_credentials.redirect_chain[-1][0], | ||
| {'query' : 'Gln, Glu', 'search_type' : 'LocalSearch'}, follow=True) | ||
|
|
||
| self.assertIn('<td class="sSearch">False</td>' , local_search_result.content) | ||
| self.assertIn('<td class="sSearch"> Glu, Gln, Cys </td>', local_search_result.content) | ||
|
|
||
| #Global Search | ||
| global_search_result = test_client.post( post_credentials.redirect_chain[-1][0], | ||
| {'query' : 'Cys, Asp', 'search_type' : 'GlobalSearch'}, follow=True) | ||
|
|
||
| self.assertIn('<td class="sSearch"> Cys, Asp, Asn </td>', global_search_result.content) | ||
|
|
||
| #Checks for presence of User: Test | ||
| self.assertIn('<td class="sSearch"> test </td>', global_search_result.content) | ||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why all caps? (not saying change, just wondering why) Also, why this tabbing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even i wonder now :)