fix sprawdzania dat

This commit is contained in:
Hokan 2019-01-30 20:58:03 +01:00
parent bce5c78d35
commit a8e670c996
6 changed files with 22 additions and 12 deletions

View File

@ -12,6 +12,8 @@ https://docs.djangoproject.com/en/2.1/ref/settings/
import os import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@ -104,13 +106,13 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/ # https://docs.djangoproject.com/en/2.1/topics/i18n/
LANGUAGE_CODE = 'en-us' LANGUAGE_CODE = 'pl'
TIME_ZONE = 'UTC' TIME_ZONE = 'UTC'
USE_I18N = True USE_I18N = False
USE_L10N = True USE_L10N = False
USE_TZ = True USE_TZ = True
@ -119,3 +121,5 @@ USE_TZ = True
# https://docs.djangoproject.com/en/2.1/howto/static-files/ # https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL = '/static/' STATIC_URL = '/static/'

View File

@ -4,7 +4,9 @@ from .models import *
class ClientForm(ModelForm): class ClientForm(ModelForm):
class Meta: class Meta:
model = Client model = Client
fields = '__all__' fields = '__all__'
labels = { labels = {
@ -13,4 +15,9 @@ class ClientForm(ModelForm):
'surname': _('Nazwisko ') 'surname': _('Nazwisko ')
} }
def __init__(self, *args, **kwargs):
super(ClientForm, self).__init__(*args, **kwargs)
self.fields['id_number'].error_messages = {'required': 'custom required message'}

View File

@ -24,22 +24,21 @@
$( ".dateform" ).submit(function(event){ $( ".dateform" ).submit(function(event){
var begindate = $(this).find('input[name=begindate]').val(); var begindate = $(this).find('input[name=begindate]').val().split("-");
var enddate = $(this).find('input[name=enddate]').val(); var enddate = $(this).find('input[name=enddate]').val().split("-");
var beginpop = $(this).find('[name=beginPopup]');
var endpop = $(this).find('[name=endPopup]');
beginpop.addClass('popup')
var today = $.datepicker.formatDate('dd-mm-yy', new Date());
if (begindate.getDate() < today.getDate()){ var today = new Date();
begindate = new Date(begindate[2], begindate[1] - 1, begindate[0]);
enddate = new Date(enddate[2], enddate[1] - 1, enddate[0]);
if (begindate.getTime() < today.getTime()){
alert('Data początkowa jest z przeszłości'); alert('Data początkowa jest z przeszłości');
return false; return false;
} }
if (enddate.getDate() < today.getDate()){ if (enddate.getTime() < today.getTime()){
alert('Data końcowa jest z przeszłości'); alert('Data końcowa jest z przeszłości');
return false; return false;
} }
if (begindate.getDate() > enddate.getDate()){ if (begindate.getTime() > enddate.getTime()){
alert('Data końcowa jest przed początkową'); alert('Data końcowa jest przed początkową');
return false; return false;
} }