Skip to content

Commit

Permalink
updates UI
Browse files Browse the repository at this point in the history
  • Loading branch information
saxix committed Nov 15, 2024
1 parent f0cbd87 commit 1efc866
Show file tree
Hide file tree
Showing 9 changed files with 360 additions and 90 deletions.
1 change: 1 addition & 0 deletions docker/bin/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ case "$1" in
set -- tini -- "$@"
set -- uwsgi --http :8000 \
--module country_workspace.config.wsgi \
--mimefile=/conf/mime.types \
--uid hope \
--gid unicef \
--buffer-size 8192 \
Expand Down
8 changes: 4 additions & 4 deletions docker/conf/uwsgi.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ master = 1
buffer-size = 8192
http-buffer-size = 8192

;processes=$(UWSGI_PROCESSES)
processes=$(UWSGI_PROCESSES)
;virtualenv=/app/.venv/
;pythonpath=/app/.venv/lib/python3.12/site-packages
;virtualenv=%(_)
;venv=%(_)
chdir=app/
;uid = user
;gid = app
uid = hope
gid = unicef
;username = user
;gropuname = app
;offload-threads=%k
;static-gzip-all=true
;route = /static/(.*) static:$(STATIC_ROOT)/$1
;http-keepalive = 1
;collect-header=Content-Type RESPONSE_CONTENT_TYPE
;mimefile=/conf/mime.types
mimefile=/conf/mime.types
;honour-stdin = true
71 changes: 43 additions & 28 deletions src/country_workspace/workspaces/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,35 +55,39 @@ def get_url(self) -> str:
return f"{url}?{flt}={oid}"
return url

# @classmethod
# def factory(cls, **kwargs):
# kwargs.setdefault(**{
# "filter_title": None,
# "lookup_name": "exact",
# })
# # kwargs["filter_title"] = title
# # kwargs["lookup_name"] = lookup_name
# return type("LinkedAutoCompleteFilter", (cls,), kwargs)


class ProgramFilter(CWLinkedAutoCompleteFilter):

def queryset(self, request: HttpRequest, queryset: "QuerySet[Beneficiary]") -> "QuerySet[Beneficiary]":
def html_attrs(self):
classes = f"adminfilters {self.__class__.__name__.lower()}"
if self.error_message:
classes += " error"
if self.lookup_val:
p = state.tenant.programs.get(pk=self.lookup_val)
# if request.usser.has_perm()
queryset = super().queryset(request, queryset).filter(batch__program=p)
return queryset


class BatchFilter(CWLinkedAutoCompleteFilter):
def has_output(self) -> bool:
return bool("batch__program__exact" in self.request.GET)

def queryset(self, request: HttpRequest, queryset: "QuerySet[Beneficiary]") -> "QuerySet[Beneficiary]":
if self.lookup_val:
queryset = super().queryset(request, queryset).filter(batch=self.lookup_val)
return queryset
classes += " active"

return {
"class": classes,
"id": "_".join(self.expected_parameters()),
}


#
# class ProgramFilter(CWLinkedAutoCompleteFilter):
#
# def queryset(self, request: HttpRequest, queryset: "QuerySet[Beneficiary]") -> "QuerySet[Beneficiary]":
# if self.lookup_val:
# p = state.tenant.programs.get(pk=self.lookup_val)
# # if request.usser.has_perm()
# queryset = super().queryset(request, queryset).filter(batch__program=p)
# return queryset
#
#
# class BatchFilter(CWLinkedAutoCompleteFilter):
# def has_output(self) -> bool:
# return bool("batch__program__exact" in self.request.GET)
#
# def queryset(self, request: HttpRequest, queryset: "QuerySet[Beneficiary]") -> "QuerySet[Beneficiary]":
# if self.lookup_val:
# queryset = super().queryset(request, queryset).filter(batch=self.lookup_val)
# return queryset
#


class HouseholdFilter(CWLinkedAutoCompleteFilter):
Expand All @@ -106,6 +110,7 @@ class IsValidFilter(SimpleListFilter):
title = "Valid"
# lookup_val = "valid"
parameter_name = "valid"
template = "workspace/adminfilters/combobox.html"

def lookups(self, request, model_admin):
return (
Expand All @@ -125,3 +130,13 @@ def queryset(self, request, queryset):

def has_output(self):
return True

def html_attrs(self):
classes = f"adminfilters {self.__class__.__name__.lower()}"
if self.value():
classes += " active"

return {
"class": classes,
"id": "_".join(self.expected_parameters()),
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

<details {% include "adminfilters/_attrs.html" with spec=spec %}>
{% block title %}
<summary>{% blocktrans with spec.get_title as filter_title %} By {{ filter_title }} {% endblocktrans %}
{# <span class="opener"></span>#}
</summary>
<summary>{% blocktrans with spec.get_title as filter_title %} By {{ filter_title }} {% endblocktrans %}</summary>
{% endblock %}
<div class="filter-content">
{% block content %}{% endblock %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
{% load i18n %}
<h3>{% blocktrans with title as filter_title %} By {{ filter_title }} {% endblocktrans %}</h3>
<ul>
<select id="filter-{{ spec.field.name }}" onchange="location.href=this.options[selectedIndex].value">
{% for choice in choices %}
<option{% if choice.selected %} selected="selected"{% endif %}
value="{{ choice.query_string|iriencode }}">{{ choice.display }}</option>
{% endfor %}
</select>
</ul>
{% extends "workspace/adminfilters/_wrapper.html" %}{% load i18n %}
{% block content %}
<ul>
<select id="filter-{{ spec.field.name }}" onchange="location.href=this.options[selectedIndex].value">
{% for choice in choices %}
<option{% if choice.selected %} selected="selected"{% endif %}
value="{{ choice.query_string|iriencode }}">{{ choice.display }}</option>
{% endfor %}
</select>
</ul>
{% endblock %}
{#{% load i18n %}#}
{#<h3>{% blocktrans with title as filter_title %} By {{ filter_title }} {% endblocktrans %}</h3>#}
{#<ul>#}
{#<select id="filter-{{ spec.field.name }}" onchange="location.href=this.options[selectedIndex].value">#}
{# {% for choice in choices %}#}
{# <option{% if choice.selected %} selected="selected"{% endif %}#}
{# value="{{ choice.query_string|iriencode }}">{{ choice.display }}</option>#}
{# {% endfor %}#}
{#</select>#}
{#</ul>#}
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
</ul>
{% endblock %}
<div id="content-main">
{% if cl.formset and cl.formset.errors %}
<p class="errornote">
{% blocktranslate count counter=cl.formset.total_error_count %}Please correct the error below.
{% plural %}Please correct the errors below.{% endblocktranslate %}
</p>
{{ cl.formset.non_form_errors }}
{% endif %}
{# {% if cl.formset and cl.formset.errors %}#}
{# <p class="errornote">#}
{# {% blocktranslate count counter=cl.formset.total_error_count %}Please correct the error below.#}
{# {% plural %}Please correct the errors below.{% endblocktranslate %}#}
{# </p>#}
{# {{ cl.formset.non_form_errors }}#}
{# {% endif %}#}

<div class="module{% if cl.has_filters %} filtered{% endif %} min-w-full flex" id="changelist">
<div class="changelist-form-container flex-1">
{% block search %}{% search_form cl %}{% endblock %}
Expand Down
Loading

0 comments on commit 1efc866

Please sign in to comment.