Skip to content

Commit

Permalink
some profile tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jchate6 committed Dec 20, 2024
1 parent d401a03 commit 58fa760
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
15 changes: 8 additions & 7 deletions tom_common/templates/tom_common/partials/profile_app_addons.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
{% load user_extras %}
{% load user_extras tom_common_extras %}
{% load bootstrap4 %}

<div class="container">

<div class="row">
<div class="col-6">
{% for profile in profile_list %}
<div class="col-6">
{% include profile %}
</div>
{% if forloop.counter|divisibleby:2 %}

{% if forloop.counter > profile_list|length|add:"1"|multiplyby:"0.5" and forloop.counter <= profile_list|length|add:"1"|multiplyby:"0.5"|add:"1" %}
</div>
<div class="row">

<div class="col-6">
{% endif %}
{% include profile %}
{% empty %}
This user has no profile.
{% endfor %}
</div>
</div>
</div>
9 changes: 9 additions & 0 deletions tom_common/templatetags/tom_common_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ def truncate_number(value):
return value


@register.filter
def multiplyby(value, arg):
"""
Multiply the value by a number and return a float.
`{% value|multiplyby:"x.y" %}`
"""
return float(value) * float(arg)


@register.filter
def addstr(arg1, arg2):
"""
Expand Down
29 changes: 15 additions & 14 deletions tom_common/templatetags/user_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,22 @@ def profile_app_addons(context, user):
for app in apps.get_app_configs():
try:
profile_details = app.profile_details()
if profile_details:
for profile in profile_details:
try:
clazz = import_string(profile['context'])
except ImportError:
logger.warning(f'WARNING: Could not import context for {app.name} profile from '
f'{profile["context"]}.\n'
f'Are you sure you have the right path?')
continue
new_context = clazz(user)
for item in new_context:
context[item] = new_context[item]
partial_list.append(profile['partial'])
except AttributeError:
pass
continue
if profile_details:
for profile in profile_details:
try:
clazz = import_string(profile['context'])
except ImportError:
logger.warning(f'WARNING: Could not import context for {app.name} profile from '
f'{profile["context"]}.\n'
f'Are you sure you have the right path?')
continue
new_context = clazz(user)
for item in new_context:
context[item] = new_context[item]
partial_list.append(profile['partial'])

context['user'] = user
context['profile_list'] = partial_list
return context

0 comments on commit 58fa760

Please sign in to comment.