+
Abwesenheiten{% if request.user.profile.showtooltips %} {% endif %}
+
+
+
+ Lade Kalenderdaten...
+
+
+
+
+
+
+
diff --git a/timemanagement/urls.py b/timemanagement/urls.py
index 0138381..9b1cf57 100644
--- a/timemanagement/urls.py
+++ b/timemanagement/urls.py
@@ -8,6 +8,7 @@ Permissions definiert in models.py bei USERS und dann hier vor die View geschrie
urlpatterns = [
path('', TimeManagement, name='tm-management'),
path('abs/', AbsenceManagmenet, name='tma-management'),
+ path('abs/
/', AbsenceManagmenet, name='tma-management'),
path('ajax/', TimeAjax, name='tm-ajax'),
#path('newsadd/', permission_required('users.modulenews')(views.NewsAdd), name='news-add'),
#path('newsupdate//', permission_required('users.modulenews')(views.NewsUpdate), name='news-update'),
diff --git a/timemanagement/views.py b/timemanagement/views.py
index fa9a911..a72a7d6 100644
--- a/timemanagement/views.py
+++ b/timemanagement/views.py
@@ -1,12 +1,17 @@
from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from django.http import JsonResponse
-from .models import Workday, Breaks
+from .models import Workday, Breaks, FreeDays
from django.utils import timezone
import requests, csv, os
from django.templatetags.static import static
from django.conf import settings
from datetime import date
+from django.contrib.auth.models import User
+from calendar import monthrange
+import datetime
+import calendar
+from .forms import AddAbsence
def loadingFreeDays(plz):
# Getting land
@@ -34,16 +39,72 @@ def loadingFreeDays(plz):
else:
return False
+def get_datetime_range(year, month):
+ nb_days = monthrange(year, month)[1]
+ return [datetime.date(year, month, day) for day in range(1, nb_days+1)]
+
+
@login_required
-def AbsenceManagmenet(request):
-
+def AbsenceManagmenet(request, activemonth=False, activeyear=False):
+ prevmonth = ""
+ nextmonth = ""
+
+ #MONTH
+ if(not activemonth or activemonth > 12 or activemonth < 1):
+ activemonth = int(activemonth)
+ #Active month
+ activemonth=date.today().month
+
+ if(activemonth == 1):
+ prevmonth = 12
+ else:
+ prevmonth = activemonth-1
+ if(activemonth == 12):
+ nextmonth = 1
+ else:
+ nextmonth = activemonth + 1
+ else:
+
+ if(activemonth == 1):
+ prevmonth = 12
+ else:
+ prevmonth = activemonth-1
+ if(activemonth == 12):
+ nextmonth = 1
+ else:
+ nextmonth = activemonth + 1
+
+ #YEAR
+ nextyear = date.today().year
+ prevyear = date.today().year
+
+ if(not activeyear):
+ activeyear = date.today().year
+ else:
+ if(nextmonth == 1):
+ nextyear = activeyear + 1
+ else:
+ nextyear = activeyear
+ if(prevmonth == 12):
+ prevyear = activeyear - 1
+ else:
+ prevyear = activeyear
+
context = {
"active_link" : "abscence",
- "freedays" : loadingFreeDays(request.user.profile.agency.plz)
- }
+ "usersofagency" : User.objects.filter(profile__agency=request.user.profile.agency).order_by("-last_name"),
+ "days_this_month" : get_datetime_range(activeyear,activemonth),
+ "nextmonth" : nextmonth,
+ "prevmonth" : prevmonth,
+ "nextyear" : nextyear,
+ "prevyear" : prevyear,
+ "activemonth" : activemonth,
+ "activeyear" : activeyear,
+ "abscenceform" : AddAbsence()
+ }
return render(request, 'timemanagement/tm_ab_management.html', context)
@@ -126,6 +187,70 @@ def TimeAjax(request):
}
else:
data = { "success" : False}
+ # REMOVE WORKDAY
+ elif request.GET["action"] == "testdjango":
+ prevmonth = ""
+ nextmonth = ""
+ activemonth = int(request.GET["activemonth"])
+ activeyear = int(request.GET["activeyear"])
+
+ #MONTH
+ if(not activemonth or activemonth > 12 or activemonth < 1):
+ activemonth = int(activemonth)
+ #Active month
+ activemonth=date.today().month
+
+ if(activemonth == 1):
+ prevmonth = 12
+ else:
+ prevmonth = activemonth-1
+
+ if(activemonth == 12):
+ nextmonth = 1
+ else:
+ nextmonth = activemonth + 1
+ else:
+
+ if(activemonth == 1):
+ prevmonth = 12
+ else:
+ prevmonth = activemonth-1
+
+ if(activemonth == 12):
+ nextmonth = 1
+ else:
+ nextmonth = activemonth + 1
+
+ #YEAR
+ nextyear = date.today().year
+ prevyear = date.today().year
+
+ if(not activeyear):
+ activeyear = date.today().year
+ else:
+ if(nextmonth == 1):
+ nextyear = activeyear + 1
+ else:
+ nextyear = activeyear
+ if(prevmonth == 12):
+ prevyear = activeyear - 1
+ else:
+ prevyear = activeyear
+
+ context = {
+ "active_link" : "abscence",
+ "usersofagency" : User.objects.filter(profile__agency=request.user.profile.agency).order_by("-last_name"),
+ "days_this_month" : get_datetime_range(activeyear,activemonth),
+ "activemonth" : activemonth,
+ "activeyear" : activeyear,
+ "nextmonth" : nextmonth,
+ "prevmonth" : prevmonth,
+ "nextyear" : nextyear,
+ "prevyear" : prevyear
+ }
+
+
+ return render(request, "timemanagement/rendered_table.html", context)
else:
data = {
"success" : False
diff --git a/users/templates/users/base.html b/users/templates/users/base.html
index 61388da..5ef0e75 100644
--- a/users/templates/users/base.html
+++ b/users/templates/users/base.html
@@ -606,11 +606,7 @@ function removeNotification(notifyid){
}
$(document).ready(function(){
- console.log("{{root}}");
- console.log("{{url}}");
-
-
-
+
$("#notification_items").html("");
loadUnsendNotifications();
loadUnviewnNotifications();
diff --git a/users/templates/users/publicbase.html b/users/templates/users/publicbase.html
index 8bfc389..7371edd 100644
--- a/users/templates/users/publicbase.html
+++ b/users/templates/users/publicbase.html
@@ -7,7 +7,7 @@
-
+
Digitale Agentur
@@ -69,16 +69,26 @@
height: 100%;
filter: blur(8px);
}
+
+
+
diff --git a/users/views.py b/users/views.py
index 02087ac..ce36cae 100644
--- a/users/views.py
+++ b/users/views.py
@@ -262,8 +262,6 @@ class AgencyCreateView(CreateView):
@login_required
def dashboard(request):
- print("MEIDA ROOT:" + settings.MEDIA_ROOT)
- print("MEDIA URL:" + settings.MEDIA_URL)
# UPDATE FUNCTIONS BY NEW MODEL-CHANGES FOR COPIEN SOME DATA
toUpdate(request)
@@ -272,8 +270,6 @@ def dashboard(request):
context = {
'active_link' : 'dashboard',
- 'root' : settings.MEDIA_ROOT,
- 'url' : settings.MEDIA_URL
#"systemencode" : storageinfo
}
# Adding active_link