Benachrichtigungen und Abwesenheitsinfo korrigiert
This commit is contained in:
parent
9179e97be7
commit
7f0d46bba8
|
|
@ -19,7 +19,6 @@
|
|||
</thead>
|
||||
<tbody >
|
||||
{% for ele in bills %}
|
||||
|
||||
<tr>
|
||||
<td><a href="{% url 'adm-agency-single' ele.agency.pk %}">{{ele.agency.name}}</a></td>
|
||||
<td><a href="{% url 'ag-getbillpdf' ele.pk %}" target="_blank">{{ele.billnumber}}</a></td>
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ class UpdateAbsence(forms.ModelForm):
|
|||
"reason" : "Abwesenheitsgrund",
|
||||
"representator" : "Vertreter",
|
||||
"info" : "Begründung",
|
||||
"confirm_info" : "Begründung zur An- oder Ablehnung",
|
||||
"startday_info" : "",
|
||||
"endday_info" : ""
|
||||
}
|
||||
|
|
@ -69,13 +70,14 @@ class UpdateAbsence(forms.ModelForm):
|
|||
|
||||
|
||||
#fields = ['start', 'start_ishalf', 'end','end_ishalf', 'reason', "representator", 'info']
|
||||
fields = ['start', 'startday_info', 'end','endday_info', 'reason', "representator", 'info', 'holidays_normal', 'holidays_rest', 'holidays_normal_next', 'holidays_rest_next' ]
|
||||
fields = ['start', 'startday_info', 'end','endday_info', 'reason', "representator", 'info', 'holidays_normal', 'holidays_rest', 'holidays_normal_next', 'holidays_rest_next', 'confirm_info' ]
|
||||
|
||||
def __init__(self, *arg, **kwargs):
|
||||
super(UpdateAbsence, self).__init__(*arg, **kwargs)
|
||||
self.fields['reason'].queryset = AbsenceReason.objects.filter(agency=kwargs['instance'].profile.agency).order_by('-name')
|
||||
self.fields['representator'].queryset = UserFullName.objects.filter(profile__agency=kwargs['instance'].profile.agency, )
|
||||
self.fields['info'].widget.attrs['rows'] = 3
|
||||
self.fields['confirm_info'].widget.attrs['rows'] = 3
|
||||
self.fields['start'].required = True
|
||||
self.fields['end'].required = True
|
||||
self.fields['reason'].required = True
|
||||
|
|
|
|||
|
|
@ -35,7 +35,15 @@
|
|||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
{{form.info|as_crispy_field}}
|
||||
<h5>Begründung</h5>
|
||||
<p>{{absence.info}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h5>An- oder Ablehnung</h5>
|
||||
<p>{{absence.confirm_info}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -108,6 +116,11 @@
|
|||
|
||||
$(document).ready(function(){
|
||||
|
||||
$("#id_info").val("{{absence.info}}");
|
||||
$("#id_info").prop("disabled", true);
|
||||
$("#id_confirm_info").val("{{absence.confirm_info}}");
|
||||
$("#id_confirm_info").prop("disabled", true);
|
||||
|
||||
date_start = "{{start}}";
|
||||
date_end = "{{end}}";
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ from datetime import timedelta
|
|||
from django.db.models.signals import post_save
|
||||
from users.signals import save_newabsence
|
||||
import locale
|
||||
from django.template.loader import render_to_string
|
||||
from django.core.mail import send_mail
|
||||
|
||||
# Load freedays
|
||||
def loadingFreeDays(plz):
|
||||
|
|
@ -107,13 +109,14 @@ def AbsenceUpdate(request, pk):
|
|||
absence.startday_info = str(formtocheck.cleaned_data["startday_info"])
|
||||
absence.endday_info = str(formtocheck.cleaned_data["endday_info"])
|
||||
absence.reason = formtocheck.cleaned_data["reason"]
|
||||
absence.info = formtocheck.cleaned_data["info"]
|
||||
absence.confirm_info = formtocheck.cleaned_data["confirm_info"]
|
||||
|
||||
rep = None
|
||||
if(formtocheck.cleaned_data["representator"] != None):
|
||||
rep = User.objects.get(pk=formtocheck.cleaned_data["representator"].pk)
|
||||
absence.representator = rep
|
||||
absence.info = formtocheck.cleaned_data["info"]
|
||||
|
||||
absence.representator = rep
|
||||
absence.holidays_normal = 0.0
|
||||
absence.holidays_rest = 0.0
|
||||
absence.holidays_normal_next = 0.0
|
||||
|
|
@ -883,6 +886,21 @@ def TimeAjax(request):
|
|||
absence.save()
|
||||
post_save.connect(save_newabsence, sender=Absence)
|
||||
messages.success(request, f'Abwesenheit gespeichert!')
|
||||
|
||||
if(absence.user.usernotifications.absence_created_mail):
|
||||
notificationtext = " es wurde eine Abwesenheit bearbeitet!"
|
||||
|
||||
msg_html = render_to_string('notificsys/notification_mail.html', {'username': absence.user.first_name + " " + absence.user.last_name, 'notificationtext' : notificationtext, 'linktarget' : ""})
|
||||
|
||||
send_mail(
|
||||
'Agentur-Benachrichtigung',
|
||||
'Hallo ' + absence.user.first_name + " " + absence.user.last_name + '! ' + notificationtext,
|
||||
'noreply@digitale-agentur.com',
|
||||
[absence.user.email],
|
||||
html_message=msg_html,
|
||||
fail_silently=True
|
||||
)
|
||||
|
||||
else:
|
||||
messages.success(request, f'Das dürfen Sie nicht!')
|
||||
|
||||
|
|
|
|||
|
|
@ -646,6 +646,11 @@ def save_newabsence(sender, instance, **kwargs):
|
|||
usersofagency = User.objects.filter(profile__agency=instance.user.profile.agency)
|
||||
|
||||
for user in usersofagency:
|
||||
|
||||
if(user == instance.user and user.usernotifications.time_data_changed_mail):
|
||||
sendMailNoti(" es wurde eine Abwesenheit erstellt!", user)
|
||||
|
||||
|
||||
# Benutzer erhält Benachrichtigung bei Abwesenheit, wenn er Rechte hat
|
||||
if(user.has_perm("users.absencemanager")):
|
||||
if(user.usernotifications.absence_created_mail):
|
||||
|
|
@ -674,6 +679,11 @@ def save_newabsence(sender, instance, **kwargs):
|
|||
usersofagency = User.objects.filter(profile__agency=instance.user.profile.agency)
|
||||
|
||||
for user in usersofagency:
|
||||
# TASK: Hier die Signals eintragen, damit die Mails verschickt werden
|
||||
if(user == instance.user and user.usernotifications.time_data_changed_mail):
|
||||
sendMailNoti(" es wurde eine Abwesenheit verändert!", user)
|
||||
|
||||
|
||||
# Benutzer erhält Benachrichtigung bei Abwesenheit, wenn er Rechte hat
|
||||
if(user.has_perm("users.absencemanager")):
|
||||
if(user.usernotifications.time_data_changed_mail):
|
||||
|
|
@ -741,6 +751,9 @@ def delete_absence(sender, instance, **kwargs):
|
|||
if(instance.reason.is_holiday):
|
||||
newdata = getFinalHolidayData(instance)
|
||||
|
||||
if(instance.user.usernotifications.time_data_changed_mail):
|
||||
sendMailNoti(" die Abwesenheit vom " + str(instance.start) + " bis " + str(instance.start) + " wurde gelöscht.", instance.user)
|
||||
|
||||
abinfo = list(UserYearAbsenceInfo.objects.filter(user=instance.user, year=instance.start.year))[0]
|
||||
abinfo_lastyear = ""
|
||||
abinfo_nextyear = ""
|
||||
|
|
|
|||
Loading…
Reference in New Issue