-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#1657] add option to hide search bar and page from anonymous users
- Loading branch information
Showing
7 changed files
with
104 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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 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
25 changes: 25 additions & 0 deletions
25
src/open_inwoner/configurations/migrations/0048_auto_20230816_1255.py
This file contains 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,25 @@ | ||
# Generated by Django 3.2.20 on 2023-08-16 10:55 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
( | ||
"configurations", | ||
"0047_siteconfiguration_hide_categories_from_anonymous_users", | ||
), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="siteconfiguration", | ||
name="hide_search_from_anonymous_users", | ||
field=models.BooleanField( | ||
default=False, | ||
help_text="If checked, only authenticated users will be able to search the page.", | ||
verbose_name="Hide search from anonymouns users", | ||
), | ||
), | ||
] |
This file contains 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 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,25 @@ | ||
from django.test import TestCase | ||
from django.urls import reverse | ||
|
||
from open_inwoner.configurations.models import SiteConfiguration | ||
|
||
|
||
class TestSearchView(TestCase): | ||
def test_search_hidden_from_anonymous_users(self): | ||
config = SiteConfiguration.get_solo() | ||
config.hide_categories_from_anonymous_users = True | ||
config.save() | ||
|
||
response = self.client.get(reverse("search:search")) | ||
|
||
self.assertEqual(response.status_code, 302) | ||
self.assertEqual(response.url, "/accounts/login/?next=/search/") | ||
|
||
def test_search_not_hidden_from_anonymous_users(self): | ||
config = SiteConfiguration.get_solo() | ||
config.hide_categories_from_anonymous_users = False | ||
config.save() | ||
|
||
response = self.client.get(reverse("search:search")) | ||
|
||
self.assertEqual(response.status_code, 200) |
This file contains 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