form to input working hours

This commit is contained in:
Alicja Cięciwa
2020-11-11 00:46:00 +01:00
parent 4573ad43da
commit 212b0008af
21 changed files with 240 additions and 61 deletions

22
.idea/workspace.xml generated
View File

@@ -2,10 +2,21 @@
<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$/templates/inputhours.html" afterDir="false" />
<change afterPath="$PROJECT_DIR$/work/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/work/admin.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/work/apps.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/work/forms.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/work/migrations/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/work/models.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/work/tests.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/work/views.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/urls.py" beforeDir="false" afterPath="$PROJECT_DIR$/config/urls.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/db.sqlite3" beforeDir="false" afterPath="$PROJECT_DIR$/db.sqlite3" afterDir="false" /> <change beforePath="$PROJECT_DIR$/db.sqlite3" beforeDir="false" afterPath="$PROJECT_DIR$/db.sqlite3" afterDir="false" />
<change beforePath="$PROJECT_DIR$/static/css/main.css" beforeDir="false" afterPath="$PROJECT_DIR$/static/css/main.css" afterDir="false" /> <change beforePath="$PROJECT_DIR$/static/css/main.css" beforeDir="false" afterPath="$PROJECT_DIR$/static/css/main.css" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/base.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/base.html" afterDir="false" /> <change beforePath="$PROJECT_DIR$/templates/base.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/base.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/home.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/home.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/registration/login.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/registration/login.html" afterDir="false" /> <change beforePath="$PROJECT_DIR$/templates/registration/login.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/registration/login.html" afterDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -18,12 +29,16 @@
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component> </component>
<component name="ProjectId" id="1j71bSwhqpUMSNPYaQQ9lvdeSR6" /> <component name="ProjectId" id="1j71bSwhqpUMSNPYaQQ9lvdeSR6" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" /> <component name="ProjectLevelVcsManager" settingsEditedManually="true">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="last_opened_file_path" value="$PROJECT_DIR$/accounts" /> <property name="ASKED_ADD_EXTERNAL_FILES" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/templates" />
</component> </component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS"> <key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\Alicja\Dev\firma-system\templates" />
<recent name="C:\Users\Alicja\Dev\firma-system\accounts" /> <recent name="C:\Users\Alicja\Dev\firma-system\accounts" />
</key> </key>
</component> </component>
@@ -63,4 +78,7 @@
</map> </map>
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration">
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
</component>
</project> </project>

View File

@@ -16,14 +16,15 @@ Including another URLconf
from django.contrib import admin from django.contrib import admin
from django.urls import path, include from django.urls import path, include
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from django.contrib.auth import views from work import views
# from accounts.forms import LoginForm
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('accounts/', include('django.contrib.auth.urls')), path('accounts/', include('django.contrib.auth.urls')),
path('', TemplateView.as_view(template_name='home.html'), name='home'), # path('', TemplateView.as_view(template_name='home.html'), name='home'),
# path('login/', views.LoginView, {'authentication_form':LoginForm}), path('', views.get_basic_workdata, name='home'),
] ]

Binary file not shown.

View File

@@ -1,51 +1,21 @@
body, html body,html {
{
height: 100%;
position: absolute;
margin: 0px;
overflow: hidden;
top: 0px;
bottom: 0px;
width: 100%;
}
.bg
{
/* The image used */
background-image: url("../img/background.jpg");
/* Full height */
height: 100%;
/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
}
body {
display: -ms-flexbox; display: -ms-flexbox;
display: flex; display: flex;
-ms-flex-align: center; -ms-flex-align: center;
align-items: center; align-items: center;
padding-top: 40px;
background-color: #f5f5f5; background-color: #f5f5f5;
background-image: url("../img/background.jpg"); background-image: url("../img/background.jpg");
/* Center and scale the image nicely */ /* Center and scale the image nicely */
background-position: center; background-position: center;
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: cover; background-size: cover;
background-attachment: fixed; background-attachment: fixed;
height: 100%;
position: absolute;
margin: 0px;
overflow: hidden;
width: 100%;
padding-top: 90px;
} }
.form-signin { .form-signin {
@@ -54,7 +24,7 @@ body {
padding: 20px; padding: 20px;
margin: auto; margin: auto;
background-color: rgba(255,255,255,0.7); background-color: rgba(255,255,255,0.7);
margin-top: 10px; margin-top: 30px;
} }
.form-signin .checkbox { .form-signin .checkbox {
@@ -99,9 +69,16 @@ a:active {
.container { .container {
height: 100%; height: 100%;
width: 100%;
align-content: center; align-content: center;
overflow: scroll; overflow: scroll;
} }
/*
@media (max-width: 979px) {
.container {
padding-top: 0px;
}
}*/
/* Hide scrollbar for Chrome, Safari and Opera */ /* Hide scrollbar for Chrome, Safari and Opera */
.container::-webkit-scrollbar { .container::-webkit-scrollbar {
@@ -112,4 +89,36 @@ a:active {
.container { .container {
-ms-overflow-style: none; /* IE and Edge */ -ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */ scrollbar-width: none; /* Firefox */
} }
/* navigation */
.bg-nav{
background-color: rgba(255,255,255,0.7);
}
.navbar-wrapper {
position: absolute;
top: 0;
right: 0;
width: 100% !important;
left: 0;
z-index: 20;
margin-top: 0px; !important;
}
.form-hours {
width: 100%;
max-width: 420px;
padding: 20px;
margin: auto;
background-color: rgba(255,255,255,0.7);
margin-top: 10px;
}
.form-hours .form-control {
position: relative;
box-sizing: border-box;
height: auto;
padding: 10px;
font-size: 16px;
}

View File

@@ -14,11 +14,13 @@
<title>Aussen- und Innenausbau</title> <title>Aussen- und Innenausbau</title>
{% endif %} {% endif %}
</head> </head>
<body> <body class="text-center">
<div class="navbar-wrapper">
<header> <header>
<nav class="navbar navbar-light bg-nav navbar-expand-md"> <nav class="navbar fixed-top navbar-light bg-nav navbar-expand-md">
<!--Logo--> <!--Logo-->
<a class="navbar-brand" href="#"><img src="{% static "img/logo.png" %} width="300" " id="logo" alt="logo" {% load static %}
<a class="navbar-brand" href="#"><img src="{% static 'img/logo.png' %}" width="150" alt="logo"
class="d-inline-block mr-1 align-center"></a> class="d-inline-block mr-1 align-center"></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#mainmenu"> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#mainmenu">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
@@ -40,13 +42,14 @@
</div> </div>
</nav> </nav>
</header> </header>
</div>
{% block content %} {% block content %}
{% endblock %} {% endblock %}
<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://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> <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>
</body> </body>
</html> </html>

View File

@@ -1,13 +1,51 @@
{% extends 'base.html' %} {% extends "base.html" %}
{% block title %}Home{% endblock %}
{% block content %} {% block content %}
{% if user.is_authenticated %}
Hi {{ user.username }}! <div class="container">
<p><a href="{% url 'logout' %}">Log Out</a></p> <div class="row">
{% else %} {% if user.is_authenticated %}
<p>You are not logged in</p> Zalogowany: {{ user.username }} &nbsp;
<a href="{% url 'login' %}">Log In</a> <p><a href="{% url 'logout' %}">Wyloguj</a></p>
{% endif %}
<div class="form-hours">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="OK">
</form>
</div>
{% else %}
<p>Nie jesteś zalogowany &nbsp;</p>
<a href="{% url 'login' %}">Zaloguj</a>
{% endif %}
</div>
</div>
{% endblock %} {% endblock %}

24
templates/inputhours.html Normal file
View File

@@ -0,0 +1,24 @@
{% extends "base.html" %}
{% block content %}
<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">
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button class="btn btn-lg btn-success btn-block" type="submit">Dodaj</button>
</form>
</div>
</div>
</div>
{% endblock %}

View File

@@ -27,7 +27,7 @@
</head> </head>
<body class="text-center"> <body class="text-center">
<div class="container"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="form-signin"> <div class="form-signin">
{% load static %} {% load static %}

0
work/__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
work/admin.py Normal file
View File

@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

5
work/apps.py Normal file
View File

@@ -0,0 +1,5 @@
from django.apps import AppConfig
class WorkConfig(AppConfig):
name = 'work'

45
work/forms.py Normal file
View File

@@ -0,0 +1,45 @@
from django import forms
# 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.DateTimeField(
input_formats=['%d/%m/%Y'],
widget=forms.DateTimeInput(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
)
# 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

15
work/models.py Normal file
View File

@@ -0,0 +1,15 @@
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()
# # workplace = models.CharField(required=True, max_length=100, choices=TITLE_CHOICES)
#

3
work/tests.py Normal file
View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

15
work/views.py Normal file
View File

@@ -0,0 +1,15 @@
from django.http import HttpResponseRedirect
from django.shortcuts import render
from work.forms import HoursInputForm
def get_basic_workdata(request):
if request.method == 'POST':
form = HoursInputForm(request.POST)
if form.is_valid():
return HttpResponseRedirect('/home/')
else:
form = HoursInputForm()
return render(request, 'inputhours.html', {'form': form})