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

View File

@ -4,7 +4,9 @@ from .models import *
class ClientForm(ModelForm):
class Meta:
model = Client
fields = '__all__'
labels = {
@ -13,4 +15,9 @@ class ClientForm(ModelForm):
'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){
var begindate = $(this).find('input[name=begindate]').val();
var enddate = $(this).find('input[name=enddate]').val();
var beginpop = $(this).find('[name=beginPopup]');
var endpop = $(this).find('[name=endPopup]');
beginpop.addClass('popup')
var today = $.datepicker.formatDate('dd-mm-yy', new Date());
var begindate = $(this).find('input[name=begindate]').val().split("-");
var enddate = $(this).find('input[name=enddate]').val().split("-");
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');
return false;
}
if (enddate.getDate() < today.getDate()){
if (enddate.getTime() < today.getTime()){
alert('Data końcowa jest z przeszłości');
return false;
}
if (begindate.getDate() > enddate.getDate()){
if (begindate.getTime() > enddate.getTime()){
alert('Data końcowa jest przed początkową');
return false;
}