Browse Source

add monthly sheet

Rene 9 months ago
parent
commit
7472f12da8
7 changed files with 147 additions and 113 deletions
  1. 71 109
      .gitignore
  2. 4 2
      .idea/AD.iml
  3. 1 1
      .idea/misc.xml
  4. BIN
      db.sqlite3
  5. 2 1
      main/urls.py
  6. 23 0
      main/views.py
  7. 46 0
      templates/main/ma_month.html

+ 71 - 109
.gitignore

@@ -1,30 +1,54 @@
-# Created by https://www.toptal.com/developers/gitignore/api/django
-# Edit at https://www.toptal.com/developers/gitignore?templates=django
-
-### Django ###
+# Django #
 *.log
 *.log
 *.pot
 *.pot
 *.pyc
 *.pyc
-__pycache__/
-local_settings.py
+__pycache__
+
+# Backup files #
+*.bak
+
+# If you are using PyCharm #
+# User-specific stuff
+.idea/**/workspace.xml
+.idea/**/tasks.xml
+.idea/**/usage.statistics.xml
+.idea/**/dictionaries
+.idea/**/shelf
+
+# AWS User-specific
+.idea/**/aws.xml
+
+# Generated files
+.idea/**/contentModel.xml
+
+# Sensitive or high-churn files
+.idea/**/dataSources/
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/sqlDataSources.xml
+.idea/**/dynamic.xml
+.idea/**/uiDesigner.xml
+.idea/**/dbnavigator.xml
+
+# Gradle
+.idea/**/gradle.xml
+.idea/**/libraries
 
 
-media
+# File-based project format
+*.iws
 
 
-# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
-# in your Git repository. Update and uncomment the following line accordingly.
-# <django-project-name>/staticfiles/
+# IntelliJ
+out/
 
 
-### Django.Python Stack ###
-# Byte-compiled / optimized / DLL files
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Python #
 *.py[cod]
 *.py[cod]
 *$py.class
 *$py.class
 
 
-# C extensions
-*.so
-
 # Distribution / packaging
 # Distribution / packaging
-.Python
-build/
+.Python build/
 develop-eggs/
 develop-eggs/
 dist/
 dist/
 downloads/
 downloads/
@@ -36,15 +60,10 @@ parts/
 sdist/
 sdist/
 var/
 var/
 wheels/
 wheels/
-share/python-wheels/
+*.whl
 *.egg-info/
 *.egg-info/
 .installed.cfg
 .installed.cfg
 *.egg
 *.egg
-MANIFEST
-
-# PyInstaller
-#  Usually these files are written by a python script from a template
-#  before PyInstaller builds the exe, so as to inject date/other infos into it.
 *.manifest
 *.manifest
 *.spec
 *.spec
 
 
@@ -55,77 +74,23 @@ pip-delete-this-directory.txt
 # Unit test / coverage reports
 # Unit test / coverage reports
 htmlcov/
 htmlcov/
 .tox/
 .tox/
-.nox/
 .coverage
 .coverage
 .coverage.*
 .coverage.*
 .cache
 .cache
+.pytest_cache/
 nosetests.xml
 nosetests.xml
 coverage.xml
 coverage.xml
 *.cover
 *.cover
-*.py,cover
 .hypothesis/
 .hypothesis/
-.pytest_cache/
-cover/
-
-# Translations
-*.mo
-
-# Django stuff:
-
-# Flask stuff:
-instance/
-.webassets-cache
-
-# Scrapy stuff:
-.scrapy
-
-# Sphinx documentation
-docs/_build/
-
-# PyBuilder
-.pybuilder/
-target/
 
 
 # Jupyter Notebook
 # Jupyter Notebook
 .ipynb_checkpoints
 .ipynb_checkpoints
 
 
-# IPython
-profile_default/
-ipython_config.py
-
 # pyenv
 # pyenv
-#   For a library or package, you might want to ignore these files since the code is
-#   intended to run in multiple environments; otherwise, check them in:
-# .python-version
-
-# pipenv
-#   According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
-#   However, in case of collaboration, if having platform-specific dependencies or dependencies
-#   having no cross-platform support, pipenv may install dependencies that don't work, or not
-#   install all needed dependencies.
-#Pipfile.lock
-
-# poetry
-#   Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
-#   This is especially recommended for binary packages to ensure reproducibility, and is more
-#   commonly ignored for libraries.
-#   https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
-#poetry.lock
-
-# pdm
-#   Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
-#pdm.lock
-#   pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
-#   in version control.
-#   https://pdm.fming.dev/#use-with-ide
-.pdm.toml
-
-# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
-__pypackages__/
-
-# Celery stuff
-celerybeat-schedule
-celerybeat.pid
+.python-version
+
+# celery
+celerybeat-schedule.*
 
 
 # SageMath parsed files
 # SageMath parsed files
 *.sage.py
 *.sage.py
@@ -139,36 +104,33 @@ ENV/
 env.bak/
 env.bak/
 venv.bak/
 venv.bak/
 
 
-# Spyder project settings
-.spyderproject
-.spyproject
-
-# Rope project settings
-.ropeproject
-
 # mkdocs documentation
 # mkdocs documentation
 /site
 /site
 
 
 # mypy
 # mypy
 .mypy_cache/
 .mypy_cache/
-.dmypy.json
-dmypy.json
-
-# Pyre type checker
-.pyre/
-
-# pytype static type analyzer
-.pytype/
-
-# Cython debug symbols
-cython_debug/
-
-# PyCharm
-#  JetBrains specific template is maintained in a separate JetBrains.gitignore that can
-#  be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
-#  and can be added to the global gitignore or merged into this file.  For a more nuclear
-#  option (not recommended) you can uncomment the following to ignore the entire idea folder.
-#.idea/
 
 
-# End of https://www.toptal.com/developers/gitignore/api/django
-gunicorn.pid
+# Sublime Text #
+*.tmlanguage.cache
+*.tmPreferences.cache
+*.stTheme.cache
+*.sublime-workspace
+*.sublime-project
+
+# sftp configuration file
+sftp-config.json
+
+# Package control specific files Package
+Control.last-run
+Control.ca-list
+Control.ca-bundle
+Control.system-ca-bundle
+GitHub.sublime-settings
+
+# Visual Studio Code #
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+.history

+ 4 - 2
.idea/AD.iml

@@ -1,8 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <module type="PYTHON_MODULE" version="4">
 <module type="PYTHON_MODULE" version="4">
   <component name="NewModuleRootManager">
   <component name="NewModuleRootManager">
-    <content url="file://$MODULE_DIR$" />
-    <orderEntry type="jdk" jdkName="Remote Python 3.11.2 (sftp://root@192.168.1.120:22/opt/pycharm/AD/.venv/bin/python)" jdkType="Python SDK" />
+    <content url="file://$MODULE_DIR$">
+      <excludeFolder url="file://$MODULE_DIR$/.venv" />
+    </content>
+    <orderEntry type="jdk" jdkName="Python 3.12 (AD)" jdkType="Python SDK" />
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="sourceFolder" forTests="false" />
   </component>
   </component>
 </module>
 </module>

+ 1 - 1
.idea/misc.xml

@@ -3,5 +3,5 @@
   <component name="Black">
   <component name="Black">
     <option name="sdkName" value="Python 3.11 (AD)" />
     <option name="sdkName" value="Python 3.11 (AD)" />
   </component>
   </component>
-  <component name="ProjectRootManager" version="2" project-jdk-name="Remote Python 3.11.2 (sftp://root@192.168.1.120:22/opt/pycharm/AD/.venv/bin/python)" project-jdk-type="Python SDK" />
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (AD)" project-jdk-type="Python SDK" />
 </project>
 </project>

BIN
db.sqlite3


+ 2 - 1
main/urls.py

@@ -1,7 +1,7 @@
 from django.urls import path
 from django.urls import path
 from .views import (create_multiple_shifts, edit_shift, delete_shift, delete_event, edit_event,
 from .views import (create_multiple_shifts, edit_shift, delete_shift, delete_event, edit_event,
                     create_event, public, create_helper, edit_helper, delete_helper, create_reinigung, edit_reinigung,
                     create_event, public, create_helper, edit_helper, delete_helper, create_reinigung, edit_reinigung,
-                    delete_reinigung)
+                    delete_reinigung, ma_month)
 from django.contrib.auth import views as auth_views
 from django.contrib.auth import views as auth_views
 
 
 urlpatterns = [
 urlpatterns = [
@@ -17,6 +17,7 @@ urlpatterns = [
     path('delete-reinigung/<int:pk>/', delete_reinigung, name='delete_reinigung'),
     path('delete-reinigung/<int:pk>/', delete_reinigung, name='delete_reinigung'),
     path('edit-event/<int:pk>/', edit_event, name='edit_event'),
     path('edit-event/<int:pk>/', edit_event, name='edit_event'),
     path('delete-event/<int:pk>/', delete_event, name='delete_event'),
     path('delete-event/<int:pk>/', delete_event, name='delete_event'),
+    path('ma-month/<int:mitarbeiter_id>/<int:monat>/<int:jahr>/', ma_month, name='ma_month'),
     path('login/', auth_views.LoginView.as_view(template_name='registration/login.html'), name='login'),
     path('login/', auth_views.LoginView.as_view(template_name='registration/login.html'), name='login'),
     path('logout/', auth_views.LogoutView.as_view(next_page='/'), name='logout'),
     path('logout/', auth_views.LogoutView.as_view(next_page='/'), name='logout'),
     path('', public, name='public'),
     path('', public, name='public'),

+ 23 - 0
main/views.py

@@ -1,3 +1,5 @@
+from datetime import date
+
 from django.shortcuts import render, redirect, get_object_or_404
 from django.shortcuts import render, redirect, get_object_or_404
 from .forms import MultipleShiftForm, ShiftForm, EventForm, HelperForm, ReinigungForm
 from .forms import MultipleShiftForm, ShiftForm, EventForm, HelperForm, ReinigungForm
 from .models import Shift, Employee, Location, Event, Helper, Reinigung
 from .models import Shift, Employee, Location, Event, Helper, Reinigung
@@ -6,6 +8,27 @@ from django.utils import timezone
 from django.contrib.auth.decorators import user_passes_test
 from django.contrib.auth.decorators import user_passes_test
 import calendar
 import calendar
 
 
+def ma_month(request, mitarbeiter_id, monat, jahr):
+    start_date = date(jahr, monat, 1)
+    end_date = date(jahr, monat, calendar.monthrange(jahr, monat)[1])
+
+    schichten = Shift.objects.filter(employee=mitarbeiter_id , date__range=(start_date, end_date)).order_by('date')
+    mitarbeiter = Employee.objects.get(id=mitarbeiter_id)
+    print (mitarbeiter)
+
+    for schicht in schichten:
+        print(schicht)
+
+    context = {
+        'schichten': schichten,
+        'monat': monat,
+        'jahr': jahr,
+        'mitarbeiter_id': mitarbeiter_id,
+        'mitarbeiter': mitarbeiter,
+    }
+
+    return render(request, 'main/ma_month.html', context)
+
 
 
 def create_multiple_shifts(request):
 def create_multiple_shifts(request):
     date_str = request.GET.get('date')
     date_str = request.GET.get('date')

+ 46 - 0
templates/main/ma_month.html

@@ -0,0 +1,46 @@
+{% load bootstrap5 %}
+<!DOCTYPE html>
+<html lang="de">
+<head>
+    <meta charset="UTF-8">
+    <title>Dienstplan</title>
+    {% bootstrap_css %}
+</head>
+<body>
+    <div class="container">
+        <h2>Dienstplan für {{ monat }} - {{ jahr }}
+</h2>
+        <h3>Mitarbeiter: {{ mitarbeiter.name }}
+</h3>
+        {% if schichten %}
+        <table class="table table-striped">
+            <thead>
+                <tr>
+                    <th scope="col" width="150">Tag</th>
+                    <th scope="col" width="50">Typ</th>
+                    <th scope="col" width="50">Beginn</th>
+                    <th scope="col" width="50">Ende</th>
+                    <th scope="col">Kommentar</th>
+                </tr>
+            </thead>
+            <tbody>
+                {% for schicht in schichten %}
+                <tr>
+                    <td>{{ schicht.date }}</td>
+                    <td>{{ schicht.shifttype }}</td>
+                    <td>{{ schicht.start }}</td>
+                    <td>{{ schicht.end }}</td>
+                    <td>{{ schicht.info }}</td>
+                </tr>
+                {% endfor %}
+            </tbody>
+        </table>
+        {% else %}
+        <p>Keine Schichten für diesen Zeitraum gefunden.</p>
+
+        {% endif %}
+
+    </div>
+    {% bootstrap_javascript %}
+</body>
+</html>