-
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
56 changed files
with
8,579 additions
and
110 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,28 @@ | ||
from django.contrib.admin import site | ||
from django.contrib.admin.sites import site | ||
from django.contrib.auth.models import Permission | ||
from django.contrib.contenttypes.models import ContentType | ||
|
||
from smart_admin.smart_auth.admin import ContentTypeAdmin | ||
from smart_admin.console import panel_migrations, panel_redis, panel_sentry, panel_sysinfo | ||
from smart_admin.smart_auth.admin import ContentTypeAdmin, PermissionAdmin | ||
|
||
from .batch import BatchAdmin # noqa | ||
from .household import HouseholdAdmin # noqa | ||
from .individual import IndividualAdmin # noqa | ||
from .job import AsyncJobAdmin # noqa | ||
from .locations import AreaAdmin, AreaTypeAdmin, CountryAdmin # noqa | ||
from .office import OfficeAdmin # noqa | ||
from .panels.cache import panel_cache | ||
from .program import ProgramAdmin # noqa | ||
from .role import UserRoleAdmin # noqa | ||
from .sync import SyncLog # noqa | ||
from .user import UserAdmin # noqa | ||
|
||
site.register(ContentType, admin_class=ContentTypeAdmin) | ||
site.register(Permission, admin_class=PermissionAdmin) | ||
|
||
|
||
site.register_panel(panel_sentry) | ||
site.register_panel(panel_cache) | ||
site.register_panel(panel_sysinfo) | ||
site.register_panel(panel_migrations) | ||
site.register_panel(panel_redis) |
Empty file.
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,40 @@ | ||
from django import forms | ||
from django.shortcuts import render | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from country_workspace.cache.manager import cache_manager | ||
|
||
|
||
class CacheManagerForm(forms.Form): | ||
pattern = forms.CharField() | ||
|
||
|
||
def panel_cache(self, request): | ||
context = self.each_context(request) | ||
client = cache_manager.get_redis_client() | ||
limit_to = "*" | ||
|
||
def _get_keys(): | ||
return list(client.scan_iter(f"*:cache:entry:{limit_to}")) | ||
|
||
if request.method == "POST": | ||
form = CacheManagerForm(request.POST) | ||
if form.is_valid(): | ||
limit_to = form.cleaned_data["pattern"] | ||
if "_delete" in request.POST: | ||
to_delete = list(_get_keys()) | ||
if to_delete: | ||
client.delete(*to_delete) | ||
else: | ||
form = CacheManagerForm() | ||
|
||
context["title"] = "Cache Manager" | ||
context["form"] = form | ||
cache_data = _get_keys() | ||
context["cache_data"] = cache_data | ||
|
||
return render(request, "smart_admin/panels/cache.html", context) | ||
|
||
|
||
panel_cache.verbose_name = _("Cache") # type: ignore[attr-defined] | ||
panel_cache.url_name = "cache" # type: ignore[attr-defined] |
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,7 @@ | ||
from smart_admin.site import SmartAdminSite | ||
|
||
|
||
class HCWAdminSite(SmartAdminSite): | ||
site_header = "Workspace Admin" | ||
site_title = "Workspace Admin Portal" | ||
index_title = "Welcome to HOPE Workspace" |
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 |
---|---|---|
@@ -1,16 +1,21 @@ | ||
from django.db.models.signals import post_save | ||
from django.dispatch import receiver | ||
|
||
from ..models import Household, Individual, Program | ||
from ..workspaces.models import CountryHousehold, CountryIndividual, CountryProgram | ||
from ..models import AsyncJob, Batch, Household, Individual, Program | ||
from ..workspaces.models import CountryAsyncJob, CountryBatch, CountryHousehold, CountryIndividual, CountryProgram | ||
from .manager import cache_manager | ||
|
||
|
||
@receiver(post_save) | ||
def update_cache(sender, instance, **kwargs): | ||
program = None | ||
if isinstance(instance, (Household, Individual, CountryHousehold, CountryIndividual)): | ||
program = instance.program | ||
cache_manager.incr_cache_version(program=program) | ||
elif isinstance(instance, (Program, CountryProgram)): | ||
program = instance | ||
elif isinstance(instance, (AsyncJob, CountryAsyncJob)): | ||
program = instance.program | ||
elif isinstance(instance, (Batch, CountryBatch)): | ||
program = instance.program | ||
if program: | ||
cache_manager.incr_cache_version(program=program) |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,17 @@ | ||
// ADMIN | ||
#container { | ||
|
||
} | ||
.redis-cli{ | ||
input[type=text]{ | ||
width: 100%; | ||
} | ||
.code{ | ||
padding-left: 2px; | ||
padding-right: 2px; | ||
background-color: black; | ||
color: white; | ||
height: 500px; | ||
overflow-scrolling: auto; | ||
} | ||
} |
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 @@ | ||
.panel{display:none}.panel.active{display:block}.console-buttons .button.selected{background-color:#114e6c}.sysinfo-results caption a{color:#fff}/*# sourceMappingURL=smart_admin.css.map */ |
1 change: 1 addition & 0 deletions
1
src/country_workspace/web/static/smart_admin/smart_admin.css.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.