Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ RUN cd /app/ledgergw/static/common; npm install
RUN python manage_ledgergw.py collectstatic --noinput
# RUN service rsyslog start
USER root
RUN rm -rf /var/lib/{apt,dpkg,cache,log}/ /tmp/* /var/tmp/*
# RUN rm -rf /var/lib/{apt,dpkg,cache,log}/ /tmp/* /var/tmp/*
RUN rm -rf /tmp/* /var/tmp/*
USER oim

EXPOSE 8080
Expand Down
3 changes: 1 addition & 2 deletions ledger/accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
from ledger.accounts.models import EmailUser,EmailUserAction, UserAction, EmailUserChangeLog, Document, PrivateDocument, Address, Profile, Organisation, OrganisationAddress
from ledger.accounts.forms import ProfileAdminForm


@admin.register(EmailUser)
class EmailUserAdmin(UserAdmin):
change_list_template = "ledger/accounts/change_emailuser_list.html"
# change_list_template = "ledger/accounts/change_emailuser_list.html" # (disabled due to breaking styling in django admin)

raw_id_fields=('identification','identification2','senior_card','senior_card2','residential_address','postal_address','billing_address',)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


<BR>

<div class="container">
<div class="card">
<h2 class="card-header">
<div class='row'>
Expand Down Expand Up @@ -61,6 +61,7 @@ <h2 class="card-header">Change Log</h2>
</div>
</div>
</div>
</div>
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<style>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@


<BR>
<div class="container">

<div class="card">
<h2 class="card-header">
Expand All @@ -28,7 +29,7 @@ <h2 class="card-header">
</div>

</div>

</div>


</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<BR>


<div class="container">
<div class="card">
<h2 class="card-header">Account Management</h2>
<div class="card-body">
Expand Down Expand Up @@ -62,7 +62,7 @@ <h2 class="card-header">Account Management</h2>
</div>
</div>
</div>

</div>
<style>

div.dt-processing div:last-child {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
{% block extrahead %}
{{ block.super }}
{{ media.js }}

{% if action_form %}{% if actions_on_top or actions_on_bottom %}
<script type="text/javascript">
(function($) {
Expand Down
15 changes: 10 additions & 5 deletions ledger/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,19 @@ class AjaxFileUploader(FileInput):
initial_text = ugettext_lazy('Currently testing')
input_text = ugettext_lazy('Change')
clear_checkbox_label = ugettext_lazy('Clear')

template_name = ''
template_with_initial = (
'%(initial_text)s: <a href="%(initial_url)s">%(initial)s</a>'
'%(clear_template)s<br />%(input_text)s: %(input)s %(ajax_uploader)s'
)

template_with_clear = '%(clear)s <label for="%(clear_checkbox_id)s">%(clear_checkbox_label)s</label>'


def __init__(self, attrs=None):
super().__init__(attrs)


def clear_checkbox_name(self, name):
"""
Given the name of the file input, return the name of the clear checkbox
Expand Down Expand Up @@ -195,14 +200,14 @@ def get_template_substitution_values(self, value):
#}


def render(self, name, value, attrs=None):

substitutions = {
def render(self, name, value, attrs=None, *args, **kwargs):
substitutions = self.get_context(name, value, attrs)
substitutions.update({
'initial_text': self.initial_text,
'input_text': self.input_text,
'clear_template': '',
'clear_checkbox_label': self.clear_checkbox_label,
}
})
Comment on lines +203 to +210
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: get_template_substitution_values() returns None, causing TypeError when substitutions.update(None) is called.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

When self.is_initial(value) is true, the code attempts to call substitutions.update(self.get_template_substitution_values(value)). However, get_template_substitution_values() is commented out and returns None. This leads to a TypeError: 'NoneType' object is not iterable, causing a server crash when rendering forms with existing files.

💡 Suggested Fix

Uncomment and implement get_template_substitution_values() to return a dictionary with initial and initial_url keys, ensuring substitutions.update() receives a valid iterable.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: ledger/widgets.py#L203-L210

Potential issue: When `self.is_initial(value)` is true, the code attempts to call
`substitutions.update(self.get_template_substitution_values(value))`. However,
`get_template_substitution_values()` is commented out and returns `None`. This leads to
a `TypeError: 'NoneType' object is not iterable`, causing a server crash when rendering
forms with existing files.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 3430431


#if 'multiple' in attrs:
#final_attrs = self.build_attrs(attrs, type=self.input_type, name=name,)
Comment on lines +203 to 213
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: FILE_INPUT_CONTRADICTION is used without import, causing NameError when contradictory file input occurs.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The constant FILE_INPUT_CONTRADICTION is referenced in value_from_datadict() methods (e.g., line 373) without being imported. When a user attempts to upload a new file and simultaneously checks the 'clear' checkbox, this code path is executed, resulting in a NameError: name 'FILE_INPUT_CONTRADICTION' is not defined, which crashes the application.

💡 Suggested Fix

Import FILE_INPUT_CONTRADICTION from django.forms.fields or django.forms.widgets to resolve the NameError.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: ledger/widgets.py#L200-L213

Potential issue: The constant `FILE_INPUT_CONTRADICTION` is referenced in
`value_from_datadict()` methods (e.g., line 373) without being imported. When a user
attempts to upload a new file and simultaneously checks the 'clear' checkbox, this code
path is executed, resulting in a `NameError: name 'FILE_INPUT_CONTRADICTION' is not
defined`, which crashes the application.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 3430431

Expand Down
2 changes: 2 additions & 0 deletions ledgergw/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from ledger.settings_base import *
from django.contrib import messages
from decimal import Decimal
import decouple
import json
import os

ROOT_URLCONF = 'ledgergw.urls'
Expand Down
9 changes: 7 additions & 2 deletions ledgergw/templates/ledgergw/web/base_b5.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,22 +177,27 @@ <h1 id="site-title" class="site-logo">
{% endblock %}


<div class="container">



{% block messages %}
<div class="container">

<BR>
{% for message in messages %}
<div class="alert {{ message.tags }} alert-dismissible shadow fade show" role="alert">
{{ message | safe }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
{% endfor %}
</div>
{% endblock %}


{% block content %}
{% endblock %}


</div>

</body>
</html>
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ django-treebeard==4.7.1
psycopg2-binary>=2.9.4
whitenoise==5.3.0
git+https://github.com/dbca-wa/appmonitor_client.git#egg=appmonitor_client
python-decouple==3.7
python-decouple>=3.8
numpy==2.2.5
requests==2.31.0
wheel==0.37.1
Expand Down
Loading