Skip to content

Commit

Permalink
Merge pull request #124 from jedie/dev
Browse files Browse the repository at this point in the history
Bugfix broken event change list, if no events exists
  • Loading branch information
jedie authored Aug 13, 2024
2 parents 2891415 + d9bdc39 commit 0057a59
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ Because this is a project and not really a reuse-able-app ;)
[comment]: <> (✂✂✂ auto generated history start ✂✂✂)

* [v0.20.0.dev0](https://github.com/jedie/django-for-runners/compare/v0.19.0...v0.20.0.dev0)
* 2024-08-13 - Bugfix broken event change list, if no events exists
* 2024-08-13 - Allow facets in GPX change list
* 2024-08-13 - Dump Version
* 2024-08-13 - Update README
Expand Down
4 changes: 2 additions & 2 deletions for_runners/admin/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def get(self, events):

# turn defaultdict and counter to normal dict and convert some values:

total_costs = collections.Counter()
total_costs = collections.Counter(total=0)

# pprint(raw_person_data)
person_data = {}
Expand All @@ -106,7 +106,7 @@ def get(self, events):
else:
# costs item
# collect total costs:
total_costs += collections.Counter({"total": value, key: value})
total_costs.update({"total": value, key: value})
# convert decimal field:
value = convert_cash_values(value)

Expand Down
25 changes: 25 additions & 0 deletions for_runners_project/tests/test_admin_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from bx_django_utils.test_utils.html_assertion import HtmlAssertionMixin
from django.contrib.auth.models import User
from django.test import TestCase
from model_bakery import baker


class AdminEventParticipationTests(HtmlAssertionMixin, TestCase):
@classmethod
def setUpTestData(cls):
cls.superuser = baker.make(User, username='superuser', is_staff=True, is_active=True, is_superuser=True)

def test_event_change_list(self):
self.client.force_login(self.superuser)
response = self.client.get("/en/admin/for_runners/eventmodel/", HTTP_ACCEPT_LANGUAGE="en")
self.assertEqual(response.status_code, 200)
self.assert_html_parts(
response,
parts=(
"<strong>superuser</strong>",
'<a href="/en/admin/for_runners/">ForRunners</a>',
'<p class="paginator">0 Events</p>',
),
)
self.assertTemplateUsed(response, template_name="admin/for_runners/eventmodel/statistics.html")
self.assertTemplateUsed(response, template_name="admin/for_runners/eventmodel/change_list.html")

0 comments on commit 0057a59

Please sign in to comment.