-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
182 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,5 +21,7 @@ | |
{% endif %} | ||
|
||
{% endif %} | ||
{% else %} | ||
<h1> </h1> | ||
{% endif %} | ||
</h1> |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from .batch import CountryBatchAdmin # noqa | ||
from .household import CountryHouseholdAdmin # noqa | ||
from .individual import CountryIndividualAdmin # noqa | ||
from .job import CountryJobAdmin # noqa | ||
from .program import CountryProgramAdmin # noqa |
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
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,21 @@ | ||
from django.contrib.admin import register | ||
|
||
from ..models import CountryJob | ||
from ..options import WorkspaceModelAdmin | ||
from ..sites import workspace | ||
|
||
|
||
@register(CountryJob, site=workspace) | ||
class CountryJobAdmin(WorkspaceModelAdmin): | ||
list_display = ( | ||
"name", | ||
"sector", | ||
"status", | ||
"active", | ||
) | ||
|
||
def has_add_permission(self, request): | ||
return False | ||
|
||
|
||
# workspace.register(CountryJob, CountryJobAdmin) |
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
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,31 @@ | ||
from constance.test import override_config | ||
|
||
from country_workspace.utils.constance import GroupChoiceField, ObfuscatedInput, WriteOnlyInput, WriteOnlyTextarea | ||
|
||
|
||
def test_utils_groupchoicefield(): | ||
field = GroupChoiceField() | ||
assert field | ||
|
||
|
||
# LdapDNField | ||
|
||
|
||
# ObfuscatedInput | ||
def test_obfuscatedinput(): | ||
field = ObfuscatedInput() | ||
assert field.render("name", "value") == '<input type="hidden" name="name" value="value">Set' | ||
|
||
|
||
# WriteOnlyTextarea | ||
def test_writeonlytextarea(): | ||
field = WriteOnlyTextarea() | ||
assert field.render("name", "value") == '<textarea name="name" cols="40" rows="10">\n***</textarea>' | ||
|
||
|
||
@override_config(HOPE_API_TOKEN="abc") | ||
def test_writeonlyinput(): | ||
field = WriteOnlyInput() | ||
assert field.render("name", "value") | ||
assert field.value_from_datadict({"HOPE_API_TOKEN": "***"}, {}, "HOPE_API_TOKEN") == "abc" | ||
assert field.value_from_datadict({"HOPE_API_TOKEN": "123"}, {}, "HOPE_API_TOKEN") == "123" |
File renamed without changes.
File renamed without changes.
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,35 @@ | ||
from django.urls import reverse | ||
|
||
import pytest | ||
from django_webtest import DjangoTestApp | ||
from django_webtest.pytest_plugin import MixinWithInstanceVariables | ||
from responses import RequestsMock | ||
from testutils.utils import select_office | ||
|
||
|
||
@pytest.fixture() | ||
def program(): | ||
from testutils.factories import CountryProgramFactory | ||
|
||
return CountryProgramFactory() | ||
|
||
|
||
@pytest.fixture() | ||
def app(django_app_factory: "MixinWithInstanceVariables", mocked_responses: "RequestsMock") -> "DjangoTestApp": | ||
from testutils.factories.user import SuperUserFactory | ||
|
||
django_app = django_app_factory(csrf_checks=False) | ||
admin_user = SuperUserFactory(username="superuser") | ||
django_app.set_user(admin_user) | ||
django_app._user = admin_user | ||
return django_app | ||
|
||
|
||
def test_project_autocomplete(app: DjangoTestApp, program) -> None: | ||
url = reverse("workspace:autocomplete") | ||
with select_office(app, program.country_office): | ||
res = app.get(url, expect_errors=True) | ||
assert res.status_code == 403 | ||
|
||
res = app.get(f"{url}?app_label=country_workspace&model_name=batch&field_name=program") | ||
assert res.status_code == 200 |