Bugfixing und updates
This commit is contained in:
parent
b5d938a2d5
commit
f8b21c8f8d
|
|
@ -0,0 +1,20 @@
|
||||||
|
{% extends "users/base.html" %}
|
||||||
|
{% load crispy_forms_tags %}
|
||||||
|
{% block content %}
|
||||||
|
{% if request.user.profile.agency.module_timemanagement %}
|
||||||
|
<div class="content-section col-6">
|
||||||
|
<h3>Feiertage anlegen</h3>
|
||||||
|
<hr>
|
||||||
|
<form method="POST" enctype="multipart/form-data">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{form.media}}
|
||||||
|
{{ form|crispy }}
|
||||||
|
<hr>
|
||||||
|
<button type="submit" class="btn btn-primary">Feiertage anlegen</button>
|
||||||
|
<a class="btn" href="{% url 'tm-managemenetfreedays' %} ">Abbrechen</a>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<h3>Das Modul Abwesenheitsplanung wurden in ihrer Agentur deaktiviert.</h3>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock content %}
|
||||||
|
|
@ -4,7 +4,8 @@
|
||||||
<div class="content-section col-12">
|
<div class="content-section col-12">
|
||||||
|
|
||||||
<h3>Feiertage und Schließtage</i></b>{% if request.user.profile.showtooltips %} <small><i data-toggle="tooltip" data-placement="top" title="Erstellen Sie hier Feiertage und Tage, an denen Ihre Agentur generell geschlossen hat." class="far fa-question-circle"></i></small>{% endif %}
|
<h3>Feiertage und Schließtage</i></b>{% if request.user.profile.showtooltips %} <small><i data-toggle="tooltip" data-placement="top" title="Erstellen Sie hier Feiertage und Tage, an denen Ihre Agentur generell geschlossen hat." class="far fa-question-circle"></i></small>{% endif %}
|
||||||
<a class="btn btn-primary btn-sm" href="{% url 'tm-freedayadd' %}" style="float: right;"><i class="fas fa-plus"></i> Freier Tag</a>
|
<a class="btn btn-primary btn-sm" href="#/" onclick="javascript:$('#addMulitpleFreeDays').modal('toggle')" style="float: right;"><i class="fas fa-plus"></i> Feiertage</a>
|
||||||
|
<a class="btn btn-primary btn-sm mr-2" href="{% url 'tm-freedayadd' %}" style="float: right;"><i class="fas fa-plus"></i> Freier Tag</a>
|
||||||
</h3>
|
</h3>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="content-section col-12">
|
<div class="content-section col-12">
|
||||||
|
|
@ -59,6 +60,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- PLZ MODAL -->
|
||||||
<div class="modal fade" tabindex="-1" role="dialog" id="plz_error" data-backdrop="static">
|
<div class="modal fade" tabindex="-1" role="dialog" id="plz_error" data-backdrop="static">
|
||||||
<div class="modal-dialog" role="document">
|
<div class="modal-dialog" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
|
@ -78,6 +80,52 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Load freedays by year -->
|
||||||
|
<div class="modal fade" tabindex="-1" role="dialog" id="addMulitpleFreeDays" data-backdrop="static">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Feiertage laden</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
Laden Sie Feiertage für entsprechende Jahre nach. <br />
|
||||||
|
<small>Es werden immer automatisch die Feiertage für die nächsten zwei Jahre geladen. </small>
|
||||||
|
<hr>
|
||||||
|
<div class="form-group">
|
||||||
|
|
||||||
|
<label for="">Jahr:</label>
|
||||||
|
{% getsomeyears 2023 as years %}
|
||||||
|
<select class="form-control" id="yearvalue">
|
||||||
|
{% for y in years %}
|
||||||
|
<option val="{{y}}" {% if y == yearvalue %} selected{% endif%}>{{y}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
<hr>
|
||||||
|
<p>Wählen Sie aus, ob nur Feiertage für das Bundesland nach Ihrer PLZ geladen werden oder bundesweite Feiertage.</p>
|
||||||
|
<div class="custom-control custom-radio">
|
||||||
|
<input type="radio" class="custom-control-input" id="freedays_plz" name="landchoice" checked>
|
||||||
|
<label class="custom-control-label" for="freedays_plz">Feiertage für meine PLZ ({{user.profile.agency.plz}})</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="custom-control custom-radio">
|
||||||
|
<input type="radio" class="custom-control-input" id="freedays_land" name="landchoice" >
|
||||||
|
<label class="custom-control-label" for="freedays_land">Deutschlandweite Feiertage</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-primary" onclick="javascript:loadCustomFreeDays()" >Feiertage laden</button>
|
||||||
|
<button type="button" class="btn" data-dismiss="modal">Abbrechen</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
|
@ -127,6 +175,34 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function loadCustomFreeDays(){
|
||||||
|
year = $("#yearvalue").val();
|
||||||
|
agencyplz = $("#freedays_plz").prop("checked");
|
||||||
|
land = $("#freedays_land").prop("checked");
|
||||||
|
$('#addMulitpleFreeDays').modal('toggle');
|
||||||
|
$.ajax(
|
||||||
|
{
|
||||||
|
type: "GET",
|
||||||
|
url: "{% url 'dasettings-ajax' %}",
|
||||||
|
data:{
|
||||||
|
action : "initloadfreedaysmulti",
|
||||||
|
year : year,
|
||||||
|
agencyplz : agencyplz,
|
||||||
|
land : land
|
||||||
|
},
|
||||||
|
success: function( data )
|
||||||
|
{
|
||||||
|
if(data["success"]){
|
||||||
|
window.location.href = "{% url 'tm-managemenetfreedays' %}";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$("#plz_error").modal("toggle");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
/* DATATABLES */
|
/* DATATABLES */
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@
|
||||||
<table class="table hover" id="usertableall">
|
<table class="table hover" id="usertableall">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Name</th>
|
<th scope="col">Vorname</th>
|
||||||
|
<th scope="col">Nachname</th>
|
||||||
<th scope="col">E-Mail</th>
|
<th scope="col">E-Mail</th>
|
||||||
<th scope="col">Agenturfunktion</th>
|
<th scope="col">Agenturfunktion</th>
|
||||||
<th scope="col">Letzter Login</th>
|
<th scope="col">Letzter Login</th>
|
||||||
|
|
@ -19,7 +20,8 @@
|
||||||
<tbody id="tableresults">
|
<tbody id="tableresults">
|
||||||
{% for item in usersofagency %}
|
{% for item in usersofagency %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{% url 'user_updateprofile' item.pk 0 %}">{{item.first_name }} {{ item.last_name }}</a></td>
|
<td><a href="{% url 'user_updateprofile' item.pk 0 %}">{{item.first_name }}</a></td>
|
||||||
|
<td><a href="{% url 'user_updateprofile' item.pk 0 %}">{{ item.last_name }}</a></td>
|
||||||
<td>{{ item.email }}</td>
|
<td>{{ item.email }}</td>
|
||||||
<td>{% if item.profile.func == None %}-{%else%}{{ item.profile.func }}{%endif%}</td>
|
<td>{% if item.profile.func == None %}-{%else%}{{ item.profile.func }}{%endif%}</td>
|
||||||
<td>{% if item.last_login != Nonte %}{{ item.last_login }}{% endif %}</td>
|
<td>{% if item.last_login != Nonte %}{{ item.last_login }}{% endif %}</td>
|
||||||
|
|
@ -48,11 +50,10 @@
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
|
||||||
$('#usertableall').DataTable({
|
$('#usertableall').DataTable({
|
||||||
|
"order" : [],
|
||||||
"language": {
|
"language": {
|
||||||
"search" : "Suche",
|
"search" : "Suche",
|
||||||
"info": "Zeige _START_ bis _END_ von _TOTAL_ Einträgen",
|
"info": "Zeige _START_ bis _END_ von _TOTAL_ Einträgen",
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@ from django.views.generic import DeleteView, UpdateView
|
||||||
from timemanagement.forms import AddFreeDayForm
|
from timemanagement.forms import AddFreeDayForm
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
import re
|
import re
|
||||||
|
import json
|
||||||
|
|
||||||
def randomString(stringLength=10):
|
def randomString(stringLength=10):
|
||||||
"""Generate a random string of fixed length """
|
"""Generate a random string of fixed length """
|
||||||
letters = string.ascii_lowercase
|
letters = string.ascii_lowercase
|
||||||
|
|
@ -82,7 +84,7 @@ def getAllForms(request, context):
|
||||||
|
|
||||||
|
|
||||||
# USER FOR USERTABLE
|
# USER FOR USERTABLE
|
||||||
users = User.objects.filter(profile__agency__pk=request.user.profile.agency.pk)
|
users = User.objects.filter(profile__agency__pk=request.user.profile.agency.pk).order_by("last_name")
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -91,6 +93,30 @@ def getAllForms(request, context):
|
||||||
'''
|
'''
|
||||||
@login_required
|
@login_required
|
||||||
def DASettings(request):
|
def DASettings(request):
|
||||||
|
|
||||||
|
|
||||||
|
# CHECK FOR EVERY USER YEAR-DATA
|
||||||
|
uina = User.objects.filter(profile__agency=request.user.profile.agency)
|
||||||
|
today = date.today()
|
||||||
|
for u in uina:
|
||||||
|
|
||||||
|
# NO YEARS FOUND
|
||||||
|
if len(UserYearAbsenceInfo.objects.filter(agency=request.user.profile.agency, user=u)) == 0:
|
||||||
|
# CREATE DATA FOR EVERY USER
|
||||||
|
UserYearAbsenceInfo(agency=request.user.profile.agency, user=u, year=today.year).save()
|
||||||
|
UserYearAbsenceInfo(agency=request.user.profile.agency, user=u, year=today.year+1).save()
|
||||||
|
UserYearAbsenceInfo(agency=request.user.profile.agency, user=u, year=today.year+2).save()
|
||||||
|
|
||||||
|
# CREATE DATE FOR YEAR PLUS 2
|
||||||
|
#elif len(UserYearAbsenceInfo.objects.filter(agency=user.profile.agency, year=today.year+2)) == 0:
|
||||||
|
# uina = User.objects.filter(profile__agency=user.profile.agency)
|
||||||
|
#
|
||||||
|
# for u in uina:
|
||||||
|
# UserYearAbsenceInfo(agency=user.profile.agency, user=u, year=today.year+2).save()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'active_link' : 'dasettings',
|
'active_link' : 'dasettings',
|
||||||
'baseurl' : settings.BASE_URL
|
'baseurl' : settings.BASE_URL
|
||||||
|
|
@ -223,6 +249,7 @@ def FreeDayAdd(request):
|
||||||
}
|
}
|
||||||
return render(request, 'dasettings/freedays_add.html', context)
|
return render(request, 'dasettings/freedays_add.html', context)
|
||||||
|
|
||||||
|
|
||||||
class FreeDayDeleteView(LoginRequiredMixin, DeleteView):
|
class FreeDayDeleteView(LoginRequiredMixin, DeleteView):
|
||||||
model = FreeDays
|
model = FreeDays
|
||||||
success_url = reverse_lazy('tm-managemenetfreedays')
|
success_url = reverse_lazy('tm-managemenetfreedays')
|
||||||
|
|
@ -672,6 +699,44 @@ def SettingsAjaxRouter(request):
|
||||||
else:
|
else:
|
||||||
data = {"userfullname" : tempuser.first_name + " " + tempuser.last_name}
|
data = {"userfullname" : tempuser.first_name + " " + tempuser.last_name}
|
||||||
success = False
|
success = False
|
||||||
|
|
||||||
|
# LOAD MULTIPLE FREEDAYS
|
||||||
|
elif request.method == 'GET' and request.GET['action'] == "initloadfreedaysmulti" :
|
||||||
|
if(request.user.has_perm('users.modulesconfig')):
|
||||||
|
|
||||||
|
#tempdays_year = False
|
||||||
|
if(request.GET["land"] == "true"):
|
||||||
|
tempdays_year = loadingFreeDaysMulti(request.user.profile.agency.plz, request.GET["year"], True)
|
||||||
|
|
||||||
|
|
||||||
|
if(tempdays_year != False):
|
||||||
|
#for k in tempdays_year:
|
||||||
|
# tempdate = tempdays_year[k][1].split("-")
|
||||||
|
# FreeDays(agency=request.user.profile.agency, name=k, day=datetime.datetime(int(tempdate[0]),int(tempdate[1]),int(tempdate[2])), year=int(request.GET["year"])).save()
|
||||||
|
|
||||||
|
#messages.success(request, f'Feiertage erfolgreich gespeichert!')
|
||||||
|
tempdays_year = json.loads(tempdays_year)
|
||||||
|
print(tempdays_year)
|
||||||
|
|
||||||
|
success = True
|
||||||
|
else:
|
||||||
|
success = False
|
||||||
|
|
||||||
|
else:
|
||||||
|
tempdays_year = loadingFreeDaysMulti(request.user.profile.agency.plz, request.GET["year"], False)
|
||||||
|
|
||||||
|
if(tempdays_year != False):
|
||||||
|
for k in tempdays_year.keys():
|
||||||
|
tempdate = tempdays_year[k]["datum"].split("-")
|
||||||
|
FreeDays(agency=request.user.profile.agency, name=k, day=datetime.datetime(int(tempdate[0]),int(tempdate[1]),int(tempdate[2])), year=int(request.GET["year"])).save()
|
||||||
|
|
||||||
|
messages.success(request, f'Feiertage erfolgreich gespeichert!')
|
||||||
|
success = True
|
||||||
|
else:
|
||||||
|
success = False
|
||||||
|
else:
|
||||||
|
data = {"userfullname" : tempuser.first_name + " " + tempuser.last_name}
|
||||||
|
success = False
|
||||||
elif request.method == 'GET' and request.GET['action'] == "update_holidays" :
|
elif request.method == 'GET' and request.GET['action'] == "update_holidays" :
|
||||||
context = {
|
context = {
|
||||||
"user_years" : UserYearAbsenceInfo.objects.filter(user=User.objects.get(pk=request.GET["userid"])),
|
"user_years" : UserYearAbsenceInfo.objects.filter(user=User.objects.get(pk=request.GET["userid"])),
|
||||||
|
|
@ -728,6 +793,35 @@ def loadingFreeDays(plz, year):
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def loadingFreeDaysMulti(plz, year, onlyland):
|
||||||
|
# Getting land
|
||||||
|
file_path = os.path.join(settings.STATIC_ROOT, 'users/extra/plz_short.csv')
|
||||||
|
|
||||||
|
if(onlyland == False):
|
||||||
|
|
||||||
|
land = False
|
||||||
|
|
||||||
|
with open(file_path, 'rt') as csvfile:
|
||||||
|
filecsv = csv.reader(csvfile, delimiter=';')
|
||||||
|
for row in filecsv:
|
||||||
|
|
||||||
|
if str(row[1]) == str(plz):
|
||||||
|
land = row[6]
|
||||||
|
break;
|
||||||
|
|
||||||
|
URL = "https://feiertage-api.de/api/"
|
||||||
|
PARAMS = {'jahr':year,'nur_land':land}
|
||||||
|
r = requests.get(url = URL, params = PARAMS)
|
||||||
|
return r.json()
|
||||||
|
elif(onlyland == True):
|
||||||
|
URL = "https://feiertage-api.de/api/"
|
||||||
|
PARAMS = {'jahr':year,'nur_daten':1}
|
||||||
|
r = requests.get(url = URL, params = PARAMS)
|
||||||
|
return r.json()
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
'''
|
'''
|
||||||
UserProfileUpdate
|
UserProfileUpdate
|
||||||
|
|
||||||
|
|
@ -934,6 +1028,11 @@ def NewUserFirstStep(request):
|
||||||
newuser.save()
|
newuser.save()
|
||||||
newuser_id = newuser.id
|
newuser_id = newuser.id
|
||||||
messages.success(request, f'Benutzer angelegt!')
|
messages.success(request, f'Benutzer angelegt!')
|
||||||
|
today = date.today()
|
||||||
|
UserYearAbsenceInfo(agency=request.user.profile.agency, user=newuser, year=today.year).save()
|
||||||
|
UserYearAbsenceInfo(agency=request.user.profile.agency, user=newuser, year=today.year+1).save()
|
||||||
|
UserYearAbsenceInfo(agency=request.user.profile.agency, user=newuser, year=today.year+2).save()
|
||||||
|
|
||||||
getadmingroup = AgencyGroup.objects.filter(savefordel=True, is_admin=False, agency=request.user.profile.agency)
|
getadmingroup = AgencyGroup.objects.filter(savefordel=True, is_admin=False, agency=request.user.profile.agency)
|
||||||
for g in getadmingroup:
|
for g in getadmingroup:
|
||||||
g.group.user_set.add(newuser)
|
g.group.user_set.add(newuser)
|
||||||
|
|
@ -1181,3 +1280,4 @@ def ModSettingsTm(request):
|
||||||
return JsonResponse({})
|
return JsonResponse({})
|
||||||
else:
|
else:
|
||||||
return JsonResponse({})
|
return JsonResponse({})
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -17,10 +17,6 @@ from datetime import datetime, timedelta
|
||||||
|
|
||||||
sec muss auf dem Server alle Account-Daten haben!!!
|
sec muss auf dem Server alle Account-Daten haben!!!
|
||||||
|
|
||||||
wenn fehlt dann anlegen!
|
|
||||||
|
|
||||||
Sonst klappt import nicht...
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
from digitaleagentur.sec import *
|
from digitaleagentur.sec import *
|
||||||
|
|
||||||
|
|
@ -176,7 +172,7 @@ LOGIN_URL = 'login'
|
||||||
# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
||||||
#SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
|
#SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
|
||||||
#SITE_ROOT = '/var/www/digitale-agentur.com/digitaleagentur/digitaleagentur/../'
|
#SITE_ROOT = '/var/www/digitale-agentur.com/digitaleagentur/digitaleagentur/../'
|
||||||
#STATIC_ROOT = (os.path.join(SITE_ROOT, 'static/'))
|
#STATIC_ROOT = (os.path.join(SITE_ROOT, 'static'))
|
||||||
|
|
||||||
#DEV-UMBGEUNG
|
#DEV-UMBGEUNG
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ from django import forms
|
||||||
from django.forms import ModelForm
|
from django.forms import ModelForm
|
||||||
from .models import Absence, AbsenceReason, FreeDays
|
from .models import Absence, AbsenceReason, FreeDays
|
||||||
from users.models import UserFullName
|
from users.models import UserFullName
|
||||||
|
from django.forms import HiddenInput
|
||||||
|
|
||||||
class AddAbsence(forms.ModelForm):
|
class AddAbsence(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,8 @@ def checkDefaultAbsenceReasons(sender, user, request, **kwargs):
|
||||||
for u in uina:
|
for u in uina:
|
||||||
UserYearAbsenceInfo(agency=user.profile.agency, user=u, year=today.year+2).save()
|
UserYearAbsenceInfo(agency=user.profile.agency, user=u, year=today.year+2).save()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
class UserYearAbsenceInfo(models.Model):
|
class UserYearAbsenceInfo(models.Model):
|
||||||
agency = models.ForeignKey(Agency, on_delete=models.PROTECT, default=None)
|
agency = models.ForeignKey(Agency, on_delete=models.PROTECT, default=None)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
/home/pi/vpython/lib/python3.7/site-packages/django/contrib/admin/static/admin/
|
||||||
Loading…
Reference in New Issue