code cleanup

This commit is contained in:
Alicja Cięciwa
2020-11-13 17:43:06 +01:00
parent 8512818192
commit 68337fcf66
11 changed files with 14 additions and 75 deletions

3
.idea/workspace.xml generated
View File

@@ -3,8 +3,11 @@
<component name="ChangeListManager">
<list default="true" id="15f590a5-5017-44f1-a85e-17dfe3fc5379" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/urls.py" beforeDir="false" afterPath="$PROJECT_DIR$/config/urls.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/base.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/base.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/inputhours.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/inputhours.html" afterDir="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>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />

View File

@@ -15,19 +15,14 @@ Including another URLconf
"""
from django.contrib import admin
from django.urls import path, include
from django.views.generic.base import TemplateView
from work import views
from accounts import views as accounts_views
from django.conf.urls import url
urlpatterns = [
path('admin/', admin.site.urls),
path('accounts/', include('django.contrib.auth.urls')),
# path('', TemplateView.as_view(template_name='home.html'), name='home'),
path('', views.get_basic_workdata, name='home'),
path('register/', accounts_views.register, name='register'),
# url(r'^signup/$', accounts_views.signup, name='signup'),
]

View File

@@ -59,7 +59,14 @@
</nav>
</header>
</div>
<div class = "container">
<div class="row">
{% if user.is_authenticated %}
Zalogowany: {{ user.username }} &nbsp;
<p><a href="{% url 'login' %}">Wyloguj</a></p> <br>
{% endif %}
</div>
<div class="row">
{% block content %}
{% endblock %}
@@ -68,9 +75,8 @@
<footer><p class="mt-5 mb-3 text-muted">
&copy; Alicja Cięciwa</p></footer>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
</div>
</body>
</html>

View File

@@ -4,13 +4,6 @@
{% load crispy_forms_tags %}
<div class="container">
<div class="row">
{% if user.is_authenticated %}
Zalogowany: {{ user.username }} &nbsp;
<p><a href="{% url 'login' %}">Wyloguj</a></p> <br>
{% endif %}
</div>
<!-- form to input working hours-->
<div class="row">
<div class="form-hours">

View File

@@ -1,42 +1,6 @@
from django import forms
from work.models import HoursInput
# from django.forms import extras
from django.forms.widgets import SelectDateWidget
from datetime import datetime, date
from django.forms import ModelForm
# from work.models import HoursInput
WORKPLACE_CHOICE =(
("1", "oNE"),
("2", "TWO")
)
# base form to input the number of hours
# class HoursInputForm(forms.Form):
# date = forms.DateField(
# # input_formats=['%d.%m.%Y'],
# widget=forms.DateInput(attrs={
# 'class': 'form-control',
# 'type': 'date',
# # '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
# )
from datetime import datetime
class HoursInputForm(forms.ModelForm):
@@ -48,13 +12,12 @@ class HoursInputForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(HoursInputForm, self).__init__(*args, **kwargs)
self.fields['date'] = forms.DateField(
initial=datetime.now(),
widget=forms.DateInput(attrs={
'placeholder': 'Data',
'type': 'date',
}),
error_messages={
'required': 'Podaj właściwą datę',
})
)
self.fields['hours_number'] = forms.IntegerField(
widget=forms.NumberInput(attrs={
'placeholder': 'Liczba godzin'
@@ -74,10 +37,3 @@ class HoursInputForm(forms.ModelForm):
self.fields[field].help_text = None
self.fields[field].label = ''
# class HoursInputForm(ModelForm):
# class Meta:
# model = HoursInput
# fields = ['date', 'hours_number']
# date = forms.DateField()
# hours_number = forms.IntegerField(min_value=0, max_value=15, required=True)
# workplace = forms.ChoiceField(choices=WORKPLACE_CHOICE)

View File

@@ -2,12 +2,6 @@ from django.db import models
import datetime
# TITLE_CHOICES = [
# ('MR', 'Mr.'),
# ('MRS', 'Mrs.'),
# ('MS', 'Ms.'),
# ]
#
class HoursInput(models.Model):
date = models.DateField(default=datetime.date.today)
hours_number = models.IntegerField()

View File

@@ -1,8 +1,6 @@
from django.http import HttpResponseRedirect
from django.shortcuts import render
from work.models import HoursInput
from work.forms import HoursInputForm
import psycopg2
def get_basic_workdata(request):
@@ -11,12 +9,6 @@ def get_basic_workdata(request):
form = HoursInputForm(request.POST)
if form.is_valid():
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:
form = HoursInputForm()