Skip to content

Commit

Permalink
Merge branch 'develop' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
domdinicola committed Feb 27, 2025
2 parents 8773f3a + 7bc569d commit 741dc5f
Show file tree
Hide file tree
Showing 15 changed files with 10,257 additions and 520 deletions.
11 changes: 6 additions & 5 deletions src/aurora/core/fields/uba.py
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@
(AKUCHUKWU_MFB, "Akuchukwu MFB"),
)

SORTED_CHOICES = sorted(BANKS_CHOICE, key=lambda x: x[1])
BANKS_SORTED_CHOICES = sorted(BANKS_CHOICE, key=lambda x: x[1])


class AccountNumberUBATextInput(SmartTextWidget):
Expand All @@ -1284,7 +1284,7 @@ class UBASelect(forms.Select):

def __init__(self, attrs=None):
attrs = {
"choices": SORTED_CHOICES,
"choices": BANKS_SORTED_CHOICES,
**(attrs or {}),
}
super().__init__(attrs)
Expand Down Expand Up @@ -1331,21 +1331,22 @@ class UBANameEnquiryField(forms.MultiValueField):

def __init__(self, *args, **kwargs):
fields = [
forms.ChoiceField(choices=SORTED_CHOICES),
forms.ChoiceField(choices=BANKS_SORTED_CHOICES),
forms.CharField(),
forms.CharField(),
]
kwargs["template_name"] = "django/forms/uba.html"
super().__init__(fields, *args, **kwargs)

def compress(self, values):
return dict(zip(["institution_code", "account_number", "account_holder"], values, strict=True))
values.insert(0, dict(BANKS_CHOICE)[values[0]])
return dict(zip(["name", "code", "number", "holder_name"], values, strict=True))

def validate(self, value):
super().validate(value)

try:
bank_code, account_number, account_full_name = value.values()
_, bank_code, account_number, account_full_name = value.values()
except ValueError:
raise ValidationError("ValueError: not enough values to unpack")

Expand Down
6 changes: 2 additions & 4 deletions src/aurora/core/templates/admin/core/flexformfield/test.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "admin_extra_buttons/action_page.html" %}{% load static itrans aurora %}
{% extends "admin_extra_buttons/action_page.html" %}{% load aurora itrans static %}
{% block action-content %}
<link href="https://unpkg.com/[email protected]/dist/tailwind.min.css" rel="stylesheet">
<link rel="stylesheet" href="{% static "base.css" %}">
Expand Down Expand Up @@ -38,9 +38,7 @@

<form method="post" id="registrationForm">
{% csrf_token %}
{% for field in form %}
{% include "smart/_fieldset.html" %}
{% endfor %}
{{ form }}
<div lass="submit-row">
<input style="background-color: cornflowerblue" type="submit" value="Submit">
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/aurora/core/templates/django/forms/uba.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{{ field.errors }}
{% for err in field.errors.as_data %}
{% if err.code == "name_mismatch" %}
<a id="{{ field.auto_id }}_uba_accept" href="#">Accept value</a>
<a class="button" id="{{ field.auto_id }}_uba_accept" href="#">Accept value</a>
<script>
$("#{{ field.auto_id }}_uba_accept").on("click", function (){
$("#{{ field.auto_id }}_2").val("{{ err.params.name }}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@
{% for x in widget.attrs.choices %}
<option {% if x.0 in widget.value %} selected {% endif %}value="{{ x.0 }}">{{ x.1 }}</option>
{% endfor %}
{# <optgroup label="{{ group_name }}">{% endif %}{% for option in group_choices %} #}
{# {% include option.template_name with widget=option %}{% endfor %}{% if group_name %} #}
{# </optgroup>{% endif %}{% endfor %} #}
</select>
30 changes: 17 additions & 13 deletions src/aurora/core/templates/smart/_fieldset.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load itrans aurora %}{% with field.field.flex_field.advanced as ADV %}
{% load aurora itrans %}{% with ADV=field.field.flex_field.advanced %}
{% if can_edit_inpage %}{% include "registration/_staff_edit_field.html" %}{% endif %}
<fieldset data-fpk="{{ field.field.flex_field.pk }}" data-fname="{{ field.name }}" data-fid="{{ field.auto_id }}" class="{{ field.name }} {{ field.field.flex_field.advanced.widget_kwargs.fieldset }}">
{% if field.field.flex_field.validator and registration.client_validation %}
Expand All @@ -13,30 +13,34 @@
data-target="field-container-{{ field.name }}"
{% if field.errors %} checked {% endif %}
type="checkbox">
{# {% if can_translate %}{% include "i18n/_staff_edit_i18n.html" with original=field.field.flex_field.advanced.smart.question %}{% endif %}#}
{# {% if can_translate %}{% include "i18n/_staff_edit_i18n.html" with original=field.field.flex_field.advanced.smart.question %}{% endif %} #}
<span data-i18n-Type="Question" data-msgid="{{ field|smart:"question,0" }}">{{ field|smart:"question,1"|md }}</span>
</label>
{% endif %}
<div class="mb-4 field-container field-container-{{ field.name }} mb-5{% if field.field.required or field.field.smart_attrs.required_by_question %} required{% endif %}">
<label data-msgid="{{ field.label }}" data-i18n-Type="FieldLabel"
class="itrans {{ ADV.css.label|default:"block uppercase tracking-wide text-gray-700 font-bold mb-2" }}" for="{{ field.auto_id }}">
{# {% if can_translate %}{% include "i18n/_staff_edit_i18n.html" with original=field.label %}{% endif %}#}
{% trans field.label|md %}
{# {% if field.field.required or field.field.smart_attrs.required_by_question %}#}
{# {% if can_translate %}{% include "i18n/_staff_edit_i18n.html" with original=field.label %}{% endif %} #}
{% translate field.label|md %}
{# {% if field.field.required or field.field.smart_attrs.required_by_question %} #}
<span data-msgid="required"
class="required-label hidden itrans lowercase font-thin required text-xs">({% trans "required" %})</span>
{# {% endif %}#}
class="required-label hidden itrans lowercase font-thin required text-xs">({% translate "required" %})</span>
{# {% endif %} #}
</label>
<div class="itrans text-sm description" data-msgid="{{ ADV.smart.description }}">
{% if ADV.smart.description %}{% trans ADV.smart.description %}{% endif %}
{% if ADV.smart.description %}{% translate ADV.smart.description %}{% endif %}
</div>
{# -- {{ field.field.flex_field.advanced.events.validation }} --#}
{# -- {{ field.field.flex_field.advanced.events.validation }} -- #}

<span class="errors">{{ field.errors }}</span>
{{ field }}
{% if field.template_name %}
{{ field.render }}
{% else %}
<span class="errors">{{ field.errors }}</span>
{{ field }}
{% endif %}
<div class="text-xs italic hint" data-msgid="{{ ADV.smart.hint }}">
{# {% if user.is_staff %}{% include "i18n/_staff_edit_i18n.html" with original=field|smart:"hint,0" %}{% endif %}#}
{% trans ADV.smart.hint %}
{# {% if user.is_staff %}{% include "i18n/_staff_edit_i18n.html" with original=field|smart:"hint,0" %}{% endif %} #}
{% translate ADV.smart.hint %}
</div>
</div>
{% if ADV.events.init %}
Expand Down
31 changes: 15 additions & 16 deletions src/dbtemplates/admin.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import logging
import posixpath

from django import forms
from django.contrib import admin
from django.core.exceptions import ImproperlyConfigured
from django.http import HttpResponse
from django.shortcuts import render
from django.utils.translation import gettext_lazy as _
from django.utils.translation import ngettext

from admin_extra_buttons.decorators import button, view

# Check if django-reversion is installed and use reversions' VersionAdmin
# as the base admin class if yes
from admin_sync.mixin import PublishMixin, SyncMixin
from adminfilters.mixin import AdminFiltersMixin
from adminfilters.value import ValueFilter
from django import forms
from django.contrib import admin
from django.core.exceptions import ImproperlyConfigured
from django.http import HttpResponse
from django.shortcuts import render
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
from django.utils.translation import ngettext

from dbtemplates.conf import settings
from dbtemplates.models import Template, add_template_to_cache, remove_cached_template
Expand All @@ -40,23 +40,21 @@ def render(self, name, value, attrs=None, renderer=None):
result = []
result.append(super().render(name, value, attrs))
result.append(
"""
<script type="text/javascript">
var editor = CodeMirror.fromTextArea('id_%(name)s', {
path: "%(media_prefix)sjs/",
f"""<script type="text/javascript">
var editor = CodeMirror.fromTextArea(document.getElementById('id_{name}'), {{
path: "{settings.DBTEMPLATES_MEDIA_PREFIX}js/",
parserfile: "parsedjango.js",
stylesheet: "%(media_prefix)scss/django.css",
stylesheet: "{settings.DBTEMPLATES_MEDIA_PREFIX}css/django.css",
continuousScanning: 500,
height: "40.2em",
tabMode: "shift",
indentUnit: 4,
lineNumbers: true
});
}});
</script>
"""
% {"media_prefix": settings.DBTEMPLATES_MEDIA_PREFIX, "name": name}
)
return "".join(result)
return mark_safe("".join(result)) # noqa: S308


if settings.DBTEMPLATES_USE_CODEMIRROR:
Expand Down Expand Up @@ -142,6 +140,7 @@ class TemplateAdmin(SyncMixin, AdminFiltersMixin, PublishMixin, TemplateModelAdm
save_as = True
search_fields = ("name", "content")
actions = ["invalidate_cache", "repopulate_cache", "check_syntax"]
change_form_template = "admin/dbtemplates/template/change_form.html"

def invalidate_cache(self, request, queryset):
for template in queryset:
Expand Down
3 changes: 1 addition & 2 deletions src/dbtemplates/conf.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import posixpath

from appconf import AppConf
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured

from appconf import AppConf


class DbTemplatesConf(AppConf):
USE_CODEMIRROR = False
Expand Down
1 change: 0 additions & 1 deletion src/dbtemplates/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from django.template import TemplateDoesNotExist
from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _

from natural_keys import NaturalKeyModel, NaturalKeyModelManager

from dbtemplates.conf import settings
Expand Down
Loading

0 comments on commit 741dc5f

Please sign in to comment.