inputhoursform works with postresql db
This commit is contained in:
30
.idea/workspace.xml
generated
30
.idea/workspace.xml
generated
@@ -2,34 +2,10 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="15f590a5-5017-44f1-a85e-17dfe3fc5379" name="Default Changelist" comment="">
|
<list default="true" id="15f590a5-5017-44f1-a85e-17dfe3fc5379" name="Default Changelist" comment="">
|
||||||
<change afterPath="$PROJECT_DIR$/Lib/site-packages/psycopg2-2.8.6.dist-info/INSTALLER" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Lib/site-packages/psycopg2-2.8.6.dist-info/LICENSE" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Lib/site-packages/psycopg2-2.8.6.dist-info/METADATA" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Lib/site-packages/psycopg2-2.8.6.dist-info/RECORD" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Lib/site-packages/psycopg2-2.8.6.dist-info/REQUESTED" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Lib/site-packages/psycopg2-2.8.6.dist-info/WHEEL" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Lib/site-packages/psycopg2-2.8.6.dist-info/top_level.txt" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Lib/site-packages/psycopg2/__init__.py" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Lib/site-packages/psycopg2/_ipaddress.py" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Lib/site-packages/psycopg2/_json.py" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Lib/site-packages/psycopg2/_lru_cache.py" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Lib/site-packages/psycopg2/_psycopg.cp38-win32.pyd" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Lib/site-packages/psycopg2/_range.py" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Lib/site-packages/psycopg2/compat.py" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Lib/site-packages/psycopg2/errorcodes.py" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Lib/site-packages/psycopg2/errors.py" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Lib/site-packages/psycopg2/extensions.py" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Lib/site-packages/psycopg2/extras.py" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Lib/site-packages/psycopg2/pool.py" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Lib/site-packages/psycopg2/sql.py" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Lib/site-packages/psycopg2/tz.py" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/work/migrations/0001_initial.py" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/work/migrations/0002_hoursinput_date.py" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/work/migrations/__init__.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/config/settings.py" beforeDir="false" afterPath="$PROJECT_DIR$/config/settings.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/templates/inputhours.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/inputhours.html" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/db.sqlite3" beforeDir="false" />
|
<change beforePath="$PROJECT_DIR$/work/forms.py" beforeDir="false" afterPath="$PROJECT_DIR$/work/forms.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/work/models.py" beforeDir="false" afterPath="$PROJECT_DIR$/work/models.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/work/views.py" beforeDir="false" afterPath="$PROJECT_DIR$/work/views.py" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
{% load crispy_forms_tags %}
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -15,7 +16,7 @@
|
|||||||
<div class="form-hours">
|
<div class="form-hours">
|
||||||
<form method="post">
|
<form method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.as_p }}
|
{{ form | crispy}}
|
||||||
<button class="btn btn-lg btn-success btn-block" type="submit">Dodaj</button>
|
<button class="btn btn-lg btn-success btn-block" type="submit">Dodaj</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,5 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
|
from work.models import HoursInput
|
||||||
# from django.forms import extras
|
# from django.forms import extras
|
||||||
from django.forms.widgets import SelectDateWidget
|
from django.forms.widgets import SelectDateWidget
|
||||||
from datetime import datetime, date
|
from datetime import datetime, date
|
||||||
@@ -10,32 +11,69 @@ WORKPLACE_CHOICE =(
|
|||||||
("2", "TWO")
|
("2", "TWO")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# base form to input the number of hours
|
# base form to input the number of hours
|
||||||
class HoursInputForm(forms.Form):
|
# class HoursInputForm(forms.Form):
|
||||||
date = forms.DateTimeField(
|
# date = forms.DateField(
|
||||||
input_formats=['%d/%m/%Y'],
|
# # input_formats=['%d.%m.%Y'],
|
||||||
widget=forms.DateTimeInput(attrs={
|
# widget=forms.DateInput(attrs={
|
||||||
'class': 'form-control',
|
# 'class': 'form-control',
|
||||||
'type': 'date',
|
# 'type': 'date',
|
||||||
'value': datetime.now().strftime("%d-%m-%Y")
|
# # 'value': datetime.now().strftime("%d-%m-%Y")
|
||||||
|
# }),
|
||||||
|
# label="")
|
||||||
|
#
|
||||||
|
# hours_number = forms.IntegerField(
|
||||||
|
# label="",
|
||||||
|
# widget=forms.NumberInput(attrs={'required': True, 'type': 'number',
|
||||||
|
# 'placeholder': 'Liczba godzin', 'class': 'form-control'} ),
|
||||||
|
# min_value=0,
|
||||||
|
# max_value=15
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# workplace = forms.CharField(
|
||||||
|
# label="",
|
||||||
|
# widget=forms.TextInput(attrs={'autofocus': True, 'class': 'form-control',
|
||||||
|
# 'placeholder': 'Miejsce pracy'}),
|
||||||
|
# required=True
|
||||||
|
# )
|
||||||
|
|
||||||
|
|
||||||
|
class HoursInputForm(forms.ModelForm):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = HoursInput
|
||||||
|
fields = ['date', 'hours_number', 'workplace']
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(HoursInputForm, self).__init__(*args, **kwargs)
|
||||||
|
self.fields['date'] = forms.DateField(
|
||||||
|
widget=forms.DateInput(attrs={
|
||||||
|
'placeholder': 'Data',
|
||||||
|
'type': 'date',
|
||||||
}),
|
}),
|
||||||
label="",
|
error_messages={
|
||||||
)
|
'required': 'Podaj właściwą datę',
|
||||||
|
})
|
||||||
|
self.fields['hours_number'] = forms.IntegerField(
|
||||||
|
widget=forms.NumberInput(attrs={
|
||||||
|
'placeholder': 'Liczba godzin'
|
||||||
|
}),
|
||||||
|
error_messages={
|
||||||
|
'required': 'Wprowadź liczbę godzin',
|
||||||
|
})
|
||||||
|
self.fields['workplace'] = forms.CharField(
|
||||||
|
widget=forms.TextInput(attrs={
|
||||||
|
'placeholder': 'Miejsce pracy'
|
||||||
|
}),
|
||||||
|
error_messages={
|
||||||
|
'required': 'Wprowadź miejsce pracy',
|
||||||
|
})
|
||||||
|
|
||||||
hours_number = forms.IntegerField(
|
for field in ['date', 'hours_number', 'workplace']:
|
||||||
label="",
|
self.fields[field].help_text = None
|
||||||
widget=forms.NumberInput(attrs={'required': True, 'type': 'number',
|
self.fields[field].label = ''
|
||||||
'placeholder': 'Liczba godzin', 'class': 'form-control'} ),
|
|
||||||
min_value = 0,
|
|
||||||
max_value = 15
|
|
||||||
)
|
|
||||||
|
|
||||||
workplace = forms.CharField(
|
|
||||||
label="",
|
|
||||||
widget=forms.TextInput(attrs={'autofocus': True, 'class': 'form-control',
|
|
||||||
'placeholder': 'Miejsce pracy'}),
|
|
||||||
required=True
|
|
||||||
)
|
|
||||||
# class HoursInputForm(ModelForm):
|
# class HoursInputForm(ModelForm):
|
||||||
# class Meta:
|
# class Meta:
|
||||||
# model = HoursInput
|
# model = HoursInput
|
||||||
|
|||||||
@@ -1,14 +1,23 @@
|
|||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
from work.models import HoursInput
|
||||||
from work.forms import HoursInputForm
|
from work.forms import HoursInputForm
|
||||||
|
import psycopg2
|
||||||
|
|
||||||
|
|
||||||
def get_basic_workdata(request):
|
def get_basic_workdata(request):
|
||||||
title = 'Rejestracja'
|
title = None
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = HoursInputForm(request.POST)
|
form = HoursInputForm(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
return HttpResponseRedirect('/home/')
|
form.save()
|
||||||
|
# form.date = request.POST.get('date')
|
||||||
|
# form.hours_number = request.POST.get('hours_number')
|
||||||
|
# form.workplace = request.POST.get('workplace')
|
||||||
|
# date = form.cleaned_data['date']
|
||||||
|
# hours_number = form.cleaned_data['hours_number']
|
||||||
|
# workplace = form.cleaned_data['workplace']
|
||||||
|
return HttpResponseRedirect('/')
|
||||||
else:
|
else:
|
||||||
form = HoursInputForm()
|
form = HoursInputForm()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user