diff --git a/.tern-port b/.tern-port new file mode 100644 index 0000000..f14bf74 --- /dev/null +++ b/.tern-port @@ -0,0 +1 @@ +46275 \ No newline at end of file diff --git a/arrowcounter/settings.py b/arrowcounter/settings.py index a91905f..a5fd9fb 100644 --- a/arrowcounter/settings.py +++ b/arrowcounter/settings.py @@ -54,6 +54,7 @@ INSTALLED_APPS = [ MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', @@ -118,7 +119,7 @@ AUTH_PASSWORD_VALIDATORS = [ # Internationalization # https://docs.djangoproject.com/en/2.1/topics/i18n/ -LANGUAGE_CODE = 'en-us' +LANGUAGE_CODE = 'it' TIME_ZONE = 'Europe/Rome' diff --git a/arrowcounter/urls.py b/arrowcounter/urls.py index 2e06b78..e54bf7f 100644 --- a/arrowcounter/urls.py +++ b/arrowcounter/urls.py @@ -15,11 +15,14 @@ Including another URLconf """ from django.contrib import admin from django.urls import path, include +from django.conf.urls.i18n import i18n_patterns +from django.views.i18n import JavaScriptCatalog -urlpatterns = [ +urlpatterns = i18n_patterns( path('', include('counter.urls')), path('admin/', admin.site.urls), path('accounts/', include('user.urls')), path('accounts/', include('django.contrib.auth.urls')), -] + path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'), +) diff --git a/counter/forms.py b/counter/forms.py new file mode 100644 index 0000000..aadd33f --- /dev/null +++ b/counter/forms.py @@ -0,0 +1,12 @@ +from django import forms +from django.conf import settings +from .models import ArrowCount + +class ArrowCountForm(forms.ModelForm): + date = forms.DateField(widget=forms.DateInput( + format='%Y-%m-%d', + attrs={'class': 'datepicker'})) + + class Meta: + model = ArrowCount + fields = ['date', 'count'] diff --git a/counter/models.py b/counter/models.py index 0d1be47..b403f72 100644 --- a/counter/models.py +++ b/counter/models.py @@ -7,7 +7,7 @@ class ArrowCount(models.Model): settings.AUTH_USER_MODEL, on_delete=models.CASCADE ) - date = models.DateField('Training date', auto_now = True) + date = models.DateField('Training date') count = models.PositiveIntegerField('Arrow count for the day') def __str__(self): diff --git a/counter/static/css/main.css b/counter/static/css/main.css index ff3ac44..4c0712b 100644 --- a/counter/static/css/main.css +++ b/counter/static/css/main.css @@ -34,3 +34,39 @@ form ul { form ul.errorlist { background: #ffcdd2; } + +form .card-action button[type=submit] { + background: none !important; + border: none; + cursor: pointer; + padding: 0 !important; + color: inherit; + text-transform: uppercase; +} + +.col .card-content .row { + margin-left: auto; + margin-right: auto; +} + +.count-up, .count-down { + width: 100%; +} + +.count-up { + height: 25vh; +} + +.count-down { + height: 12.5vh; +} + +.count-up .material-icons { + font-size: 20vh; + line-height: 25vh; +} + +.count-down .material-icons { + font-size: 10vh; + line-height: 12.5vh; +} diff --git a/counter/static/js/count_edit.js b/counter/static/js/count_edit.js new file mode 100644 index 0000000..eb4b026 --- /dev/null +++ b/counter/static/js/count_edit.js @@ -0,0 +1,15 @@ +"use strict"; + +var input = $('#id_count'); + +$('.count-up').click(function() { + var count = parseInt(input.val(), 10); + if(!isNaN(count)) + input.val(count + 1); +}); + +$('.count-down').click(function() { + var count = parseInt(input.val(), 10); + if(!isNaN(count) && count > 0) + input.val(count - 1); +}); diff --git a/counter/static/js/main.js b/counter/static/js/main.js index 7db18e8..555eabe 100644 --- a/counter/static/js/main.js +++ b/counter/static/js/main.js @@ -1,3 +1,52 @@ +var i18n = { + cancel: gettext('Cancel'), + clear: gettext('Clear'), + done: gettext('Ok'), + previousMonth: '‹', + nextMonth: '›', + months: [ + 'January', + 'February', + 'March', + 'April', + 'May', + 'June', + 'July', + 'August', + 'September', + 'October', + 'November', + 'December' + ], + monthsShort: [], + weekdays: [ + 'Sunday', + 'Monday', + 'Tuesday', + 'Wednesday', + 'Thursday', + 'Friday', + 'Saturday'], + weekdaysShort: [], + weekdaysAbbrev: [] +}; + +i18n.months.forEach(function(val, index) { + i18n.months[index] = gettext(val); + i18n.monthsShort[index] = i18n.months[index].substring(0,3); +}); + +i18n.weekdays.forEach(function(val, index) { + i18n.weekdays[index] = gettext(val); + i18n.weekdaysShort[index] = i18n.weekdays[index].substring(0,3); + i18n.weekdaysAbbrev[index] = i18n.weekdays[index][0]; +}); + $(document).ready(function() { $('.sidenav').sidenav(); + $('.fixed-action-btn').floatingActionButton(); + $('.datepicker').datepicker({ + format: 'yyyy-mm-dd', + i18n: i18n + }); }); diff --git a/counter/templates/base.html b/counter/templates/base.html index 5f6d363..718d07a 100644 --- a/counter/templates/base.html +++ b/counter/templates/base.html @@ -1,9 +1,9 @@ {% load static %} +{% load i18n %} -