Skip to content

Commit

Permalink
Merge e16ba82 into 298621b
Browse files Browse the repository at this point in the history
  • Loading branch information
cdubz committed Nov 9, 2019
2 parents 298621b + e16ba82 commit 8b57f5d
Show file tree
Hide file tree
Showing 27 changed files with 253 additions and 94 deletions.
6 changes: 3 additions & 3 deletions core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ def __str__(self):
def attributes(self):
attributes = []
if self.wet:
attributes.append(DiaperChange._meta.get_field('wet').name)
attributes.append(self._meta.get_field('wet').verbose_name)
if self.solid:
attributes.append(DiaperChange._meta.get_field('solid').name)
attributes.append(self._meta.get_field('solid').verbose_name)
if self.color:
attributes.append(self.color)
attributes.append(self.get_color_display())
return attributes

def clean(self):
Expand Down
2 changes: 1 addition & 1 deletion core/templates/core/diaperchange_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h1>{% trans "Diaper Changes" %}</h1>
<th scope="row"><a href="{% url 'core:child' change.child.slug %}">{{ change.child }}</a></th>
<td class="text-center">{{ change.wet|bool_icon }}</td>
<td class="text-center">{{ change.solid|bool_icon }}</td>
<td>{{ change.color }}</td>
<td>{{ change.get_color_display }}</td>
<td>{{ change.time|date:'n/j/y G:i' }}</td>
<td class="text-center">
<div class="btn-group btn-group-sm" role="group" aria-label="{% trans "Actions" %}">
Expand Down
4 changes: 2 additions & 2 deletions core/templates/core/feeding_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ <h1>{% trans "Feedings" %}</h1>
{% for feeding in object_list %}
<tr>
<th scope="row"><a href="{% url 'core:child' feeding.child.slug %}">{{ feeding.child }}</a></th>
<td>{{ feeding.method }}</td>
<td>{{ feeding.type }}</td>
<td>{{ feeding.get_method_display }}</td>
<td>{{ feeding.get_type_display }}</td>
<td>
{% if feeding.amount %}
{{ feeding.amount }}
Expand Down
2 changes: 1 addition & 1 deletion core/tests/tests_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_diaperchange_create(self):

def test_diaperchange_attributes(self):
self.assertListEqual(
self.change.attributes(), ['wet', 'solid', 'black'])
self.change.attributes(), ['Wet', 'Solid', 'Black'])


class FeedingTestCase(TestCase):
Expand Down
23 changes: 18 additions & 5 deletions core/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from django.utils import timezone
from django.utils.translation import ngettext


def duration_string(duration, precision='s'):
Expand All @@ -11,13 +12,25 @@ def duration_string(duration, precision='s'):

duration = ''
if h > 0:
duration = '{} hour{}'.format(h, 's' if h > 1 else '')
duration = ngettext('%(hours)s hour', '%(hours)s hours', h) % {
'hours': h
}
if m > 0 and precision != 'h':
duration += '{}{} minute{}'.format(
'' if duration == '' else ', ', m, 's' if m > 1 else '')
if duration != '':
duration += ', '
duration += ngettext(
'%(minutes)s minute',
'%(minutes)s minutes',
m
) % {'minutes': m}
if s > 0 and precision != 'h' and precision != 'm':
duration += '{}{} second{}'.format(
'' if duration == '' else ', ', s, 's' if s > 1 else '')
if duration != '':
duration += ', '
duration += ngettext(
'%(seconds)s second',
'%(seconds)s seconds',
s
) % {'seconds': s}

return duration

Expand Down
5 changes: 3 additions & 2 deletions core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ class CoreDeleteView(PermissionRequired403Mixin, DeleteView):
See: https://code.djangoproject.com/ticket/21936
"""
def delete(self, request, *args, **kwargs):
success_message = '{} entry deleted.'.format(
self.model._meta.verbose_name.title())
success_message = _('%(model)s entry deleted.') % {
'model': self.model._meta.verbose_name.title()
}
messages.success(request, success_message)
return super(CoreDeleteView, self).delete(request, *args, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion dashboard/templates/cards/feeding_last.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

{% block content %}
{% if feeding %}
{{ feeding.type }}, {{ feeding.method }}
{{ feeding.get_type_display }}, {{ feeding.get_method_display }}
{% if feeding.amount %}
({{ feeding.amount }})
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion dashboard/templates/cards/feeding_last_method.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{% block title %}
{% if feeding %}
<div class="display-4 text-center">{{ feeding.method }}</div>
<div class="display-4 text-center">{{ feeding.get_method_display }}</div>
{% else %}
{% trans "None" %}
{% endif %}
Expand Down
8 changes: 8 additions & 0 deletions gulpfile.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ module.exports = {
dest: basePath + 'img/',
files: '**/static_src/img/**/*'
},
plotlyLocales: {
dest: basePath + 'plotly-locales/',
files: [
'node_modules/plotly.js/dist/plotly-locale-de.js',
'node_modules/plotly.js/dist/plotly-locale-fr.js',
'node_modules/plotly.js/dist/plotly-locale-sv.js'
]
},
logo: {
dest: basePath + 'logo/',
files: 'babybuddy/static_src/logo/**/*'
Expand Down
5 changes: 5 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ function extras(cb) {
gulp.dest(config.extrasConfig.images.dest)
], cb);

pump([
gulp.src(config.extrasConfig.plotlyLocales.files),
gulp.dest(config.extrasConfig.plotlyLocales.dest)
], cb);

pump([
gulp.src(config.extrasConfig.logo.files),
flatten({ subPath: 3 }),
Expand Down
Binary file modified locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 8b57f5d

Please sign in to comment.