diff --git a/adm/templates/adm/adm_agencys.html b/adm/templates/adm/adm_agencys.html index d8772b3..4cd5e12 100644 --- a/adm/templates/adm/adm_agencys.html +++ b/adm/templates/adm/adm_agencys.html @@ -3,6 +3,8 @@ {% load adm_tags %}

Agenturübersicht

+{% loadAboCount as abocount %} +Aktive Abos: {{abocount}}
diff --git a/adm/templates/adm/adm_user_single.html b/adm/templates/adm/adm_user_single.html index 89ea8b5..517a344 100644 --- a/adm/templates/adm/adm_user_single.html +++ b/adm/templates/adm/adm_user_single.html @@ -67,5 +67,10 @@ }); }) +
+
Logins (letzten 50)
+{% for ele in logdata %} + {{forloop.counter}}. {{ele|date:"d.m.Y, H:i"}}
+{% endfor %} {% endblock content %} \ No newline at end of file diff --git a/adm/templatetags/__pycache__/adm_tags.cpython-38.pyc b/adm/templatetags/__pycache__/adm_tags.cpython-38.pyc index 977a0a0..a85673e 100644 Binary files a/adm/templatetags/__pycache__/adm_tags.cpython-38.pyc and b/adm/templatetags/__pycache__/adm_tags.cpython-38.pyc differ diff --git a/adm/templatetags/adm_tags.py b/adm/templatetags/adm_tags.py index 7a34e84..9aabd28 100644 --- a/adm/templatetags/adm_tags.py +++ b/adm/templatetags/adm_tags.py @@ -37,3 +37,6 @@ def getlaststat(): def getAgencyGroupName(group): return AgencyGroup.objects.get(group=group) +@register.simple_tag +def loadAboCount(): + return len(Agency.objects.filter(paymentplan=1)) diff --git a/adm/views.py b/adm/views.py index e298410..dcc6f2a 100644 --- a/adm/views.py +++ b/adm/views.py @@ -10,7 +10,10 @@ from chat.models import ChatMessage from users.models import Agency, AgencyBills, RegNotfallhilfe from standards.models import Standards import csv -from datetime import date +from auditlog.models import LogEntry +from datetime import date, datetime +import json + ''' Prüfung, ob angemeldeter User Mitarbeiterstatus hat. IMMER PER DISPATCH EINBAUEN! ''' @@ -195,6 +198,21 @@ class AdmUserSingle(TemplateView): context = super().get_context_data(**kwargs) context.update({'active_link' : "adm-users"}) context.update({'userdata' : User.objects.get(pk=kwargs['uspk'])}) + + # Loading Logindata + logdata = LogEntry.objects.filter(object_pk=kwargs['uspk'])[:50] + + logdata_logins = [] + + for ele in logdata: + + datestring = json.loads(ele.changes)["last_login"][1] + + datestring = datestring.split(".")[0] + logdata_logins.append(datetime.strptime(datestring, '%Y-%m-%d %H:%M:%S')) + + context.update({'logdata' : logdata_logins}) + return context diff --git a/digitaleagentur/__pycache__/settings.cpython-38.pyc b/digitaleagentur/__pycache__/settings.cpython-38.pyc index 9936dda..bdd1625 100644 Binary files a/digitaleagentur/__pycache__/settings.cpython-38.pyc and b/digitaleagentur/__pycache__/settings.cpython-38.pyc differ diff --git a/digitaleagentur/settings.py b/digitaleagentur/settings.py index c1de0ad..e33f049 100644 --- a/digitaleagentur/settings.py +++ b/digitaleagentur/settings.py @@ -93,10 +93,9 @@ INSTALLED_APPS = [ 'channels_presence', 'simple_history', 'captcha', + 'auditlog', ] - - MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', @@ -107,6 +106,7 @@ MIDDLEWARE = [ 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django_user_agents.middleware.UserAgentMiddleware', 'simple_history.middleware.HistoryRequestMiddleware', + 'auditlog.middleware.AuditlogMiddleware' ] ROOT_URLCONF = 'digitaleagentur.urls' diff --git a/dump.rdb b/dump.rdb index 458189a..2515db9 100644 Binary files a/dump.rdb and b/dump.rdb differ diff --git a/standards/templates/standards/standards_single.html b/standards/templates/standards/standards_single.html index 85b8647..65de2dd 100644 --- a/standards/templates/standards/standards_single.html +++ b/standards/templates/standards/standards_single.html @@ -14,6 +14,9 @@

{{standard.name}} + + + {% if standard.created_standard_by != null and standard.created_standard_by == user or perms.users.standardmanager %} @@ -222,11 +225,6 @@ {% endif %}
- - - - - {% if not standard.created_standard_by %} Erstellt von gelöschtem Mitarbeiter {% else %} Erstellt durch {{standard.created_standard_by.first_name}} {{standard.created_standard_by.last_name}} {% endif %} am {{standard.created_standard_date}} | {% if not standard.last_modified_by %} Zuletzt bearbeitet von gelöschtem Benutzer {% else %} Zuletzt bearbeitet von {{ standard.last_modified_by.first_name}} {{ standard.last_modified_by.last_name}}{% endif %} am {{ standard.last_modified_on}} diff --git a/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc b/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc index 930949e..6e610c4 100644 Binary files a/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc and b/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc differ diff --git a/standards/templatetags/counter_tag.py b/standards/templatetags/counter_tag.py index 4dc9db4..d977cf6 100644 --- a/standards/templatetags/counter_tag.py +++ b/standards/templatetags/counter_tag.py @@ -75,6 +75,11 @@ def getWorkDayHistory(workday): workday = Workday.objects.get(pk=workday.pk) return workday.history.first() +# Last Absence +@register.simple_tag +def getLastEditedAbsence(absence): + return Absence.objects.get(pk=absence.pk).history.first() + # usergperm ''' diff --git a/timemanagement/models.py b/timemanagement/models.py index 5082d1f..b4a342f 100644 --- a/timemanagement/models.py +++ b/timemanagement/models.py @@ -68,7 +68,7 @@ class Absence(models.Model): holidays_rest = models.FloatField(default=0.0, max_length=9, blank=True) holidays_normal_next = models.FloatField(default=0.0, max_length=9, blank=True) holidays_rest_next = models.FloatField(default=0.0, max_length=9, blank=True) - + history = HistoricalRecords() class FreeDays(models.Model): agency = models.ForeignKey(Agency, on_delete=models.CASCADE) diff --git a/timemanagement/templates/timemanagement/tm_ab_all.html b/timemanagement/templates/timemanagement/tm_ab_all.html index b3ab1e9..a30e202 100644 --- a/timemanagement/templates/timemanagement/tm_ab_all.html +++ b/timemanagement/templates/timemanagement/tm_ab_all.html @@ -22,7 +22,7 @@

- + - + + @@ -69,8 +70,9 @@ - + + {% endfor %} diff --git a/users/models.py b/users/models.py index 8ae4bef..e273f2d 100644 --- a/users/models.py +++ b/users/models.py @@ -7,7 +7,7 @@ from django.utils import timezone from django.contrib.auth.models import User, Group, Permission from django.contrib.contenttypes.models import ContentType import datetime - +from simple_history.models import HistoricalRecords # UNIQUE and NO BLANK fields while user-registration User._meta.get_field('email')._unique = True User._meta.get_field('email').blank = False @@ -515,15 +515,26 @@ class RegNotfallhilfe(models.Model): wassend = models.BooleanField(default=False) orderdate = models.DateField(default=timezone.now, null=True) - - # SUBCLASS class UserFullName(User): - class Meta: - proxy = True - def __unicode__(self): - return "placeholder" + history = HistoricalRecords() + + class Meta: + proxy = True + + def __unicode__(self): + return "placeholder" + + def __str__(self): + return f'{self.first_name + " " + self.last_name}' + +# Hier Audit-Logeinträge einbauen für die versch. Models +from django.utils.six import python_2_unicode_compatible +from auditlog.registry import auditlog + +auditlog.register(User) +auditlog.register(Agency) + + - def __str__(self): - return f'{self.first_name + " " + self.last_name}' \ No newline at end of file diff --git a/users/templates/users/base.html b/users/templates/users/base.html index 7c3c90e..d548032 100644 --- a/users/templates/users/base.html +++ b/users/templates/users/base.html @@ -305,7 +305,7 @@ Impressum

- Version 1.0.2 + Version 1.0.3

@@ -517,6 +517,10 @@ Benachrichtigungen + + + Anmeldevorgänge + @@ -672,9 +676,8 @@ $(document).ready(function(){ // Toggle the side navigation function toggleSidebar(){ - if(sidebar_hidden == false){ - $("#accordionSidebar").addClass("toggled"); + $("#accordionSidebar").removeClass("toggled"); $("#content-wrapper").css("margin-left" , "105px"); $("#topnavbarmain").css("margin-left" , "105px"); @@ -682,7 +685,7 @@ function toggleSidebar(){ sidebar_hidden = true; } else{ - $("#accordionSidebar").removeClass("toggled"); + $("#accordionSidebar").addClass("toggled"); $("#content-wrapper").css("margin-left" , "0px"); $("#topnavbarmain").css("margin-left" , "0px"); sidebar_hidden = false; diff --git a/users/templates/users/dashboard.html b/users/templates/users/dashboard.html index e4d45f1..20ad1c6 100644 --- a/users/templates/users/dashboard.html +++ b/users/templates/users/dashboard.html @@ -7,7 +7,7 @@ Letzter Login: {{ request.user.last_login }} {% getlocalweather request.user as weatherdata %} {% if request.user.profile.agency.city|length > 0 and weatherdata.0 != None %} - {{weatherdata.0}}{{weatherdata.2}} + {{weatherdata.0}}  {{weatherdata.2}} {% endif %}
Agentur: {{ request.user.profile.agency.name }}
diff --git a/users/templates/users/userlog.html b/users/templates/users/userlog.html new file mode 100644 index 0000000..6ce6b0e --- /dev/null +++ b/users/templates/users/userlog.html @@ -0,0 +1,12 @@ +{% extends "users/base.html" %} +{% load counter_tag %} +{% block content %} +
+

Anmeldelog

+Hier sehen Sie eine Auflistung Ihrer letzten 50 Anmeldevorgänge. +
+{% for ele in logdata %} + {{forloop.counter}}. Login am {{ele|date:"d.m.Y, H:i"}}
+{% endfor %} +
+{% endblock %} \ No newline at end of file diff --git a/users/urls.py b/users/urls.py index c7a0864..65302b3 100644 --- a/users/urls.py +++ b/users/urls.py @@ -24,6 +24,7 @@ urlpatterns = [ path('usersman//perms', permission_required('users.usermanager')(UsersPermUpdateView.as_view()), name='users-perm-update'), path('usersman//delete', permission_required('users.usermanager')(ProfileDeleteView.as_view()), name='users-delete'), path('usersman/gd/', views.getDataFromToDelUser, name="users-delete-getdata"), + path('userlog/', views.showUserLog, name="users-log"), #path('agencyinfo/', views.agency, name='agencyinfo'), #path('agencyinfo//', permission_required('users.agency_change')(AgencyUpdateView.as_view()), name='agency-manage'), path('usersman//prio', views.UsersPrio, name='users-prio'), diff --git a/users/views.py b/users/views.py index 426a424..4d7b33f 100644 --- a/users/views.py +++ b/users/views.py @@ -636,10 +636,50 @@ class AgencyCreateView(CreateView): return super().form_valid(form) +#from django.core.mail import EmailMessage +#from django.core.mail import EmailMultiAlternatives + +from auditlog.models import LogEntry + +@login_required +def showUserLog(request, pk): + + logdata = LogEntry.objects.filter(object_pk=request.user.pk)[:50] + + logdata_logins = [] + + for ele in logdata: + + datestring = json.loads(ele.changes)["last_login"][1] + + datestring = datestring.split(".")[0] + logdata_logins.append(datetime.strptime(datestring, '%Y-%m-%d %H:%M:%S')) + + context = { + 'logdata' : logdata_logins + } + return render(request, 'users/userlog.html', context) + @login_required def dashboard(request): # UPDATE FUNCTIONS BY NEW MODEL-CHANGES FOR COPIEN SOME DATA toUpdate(request) + ''' + # BCC Mail with Object - NICHT DEN IMPORT VERGESSEN!!! + email = EmailMultiAlternatives( + 'Subject', + 'Bitte aktivieren Sie HTML in Ihrem Mailprogramm.', + 'noreply@digitale-agentur.com', + ['mail@holgertrampe.de'], + ['htrampe@gmail.com'], + #reply_to=['noreply@digitale-agentur.com'], + headers={}, + ) + email.attach_alternative("

Lobbt der Shit!


", "text/html") + email.send() + ''' + + #storageinfo = sys.getfilesystemencoding()
{{abday.end|date:"d.M Y"}} {{abday.reason.name}} {{abday.info}}{% if abday.confirm_status == 0 %} Genehmigt {% elif abday.confirm_status == 1 %} Beantragt {% else %} Abgelehnt {% endif %}{% if abday.confirm_status == 0 %} {% elif abday.confirm_status == 1 %} Beantragt {% else %} {% endif %} diff --git a/timemanagement/templates/timemanagement/tm_ab_update.html b/timemanagement/templates/timemanagement/tm_ab_update.html index e30dfb2..64c9c38 100644 --- a/timemanagement/templates/timemanagement/tm_ab_update.html +++ b/timemanagement/templates/timemanagement/tm_ab_update.html @@ -8,6 +8,11 @@

Abwesenheit von {{absence.user.first_name}} {{absence.user.last_name}} Bearbeiten

+ {% getLastEditedAbsence absence as absencehistorie %} + + {% if absencehistorie.history_user != None %} + Zuletzt bearbeitet von {{absencehistorie.history_user.first_name}} {{absencehistorie.history_user.last_name}} am {{absencehistorie.history_date|date:"d.m.Y, H:i"}} + {% endif %}
diff --git a/timemanagement/templates/timemanagement/tm_ab_userown.html b/timemanagement/templates/timemanagement/tm_ab_userown.html index bf88b24..d82c3d6 100644 --- a/timemanagement/templates/timemanagement/tm_ab_userown.html +++ b/timemanagement/templates/timemanagement/tm_ab_userown.html @@ -59,8 +59,9 @@
Start Ende GrundStatusAntrag BegründungStatus
{{abday.start|date:"d.M Y"}} {{abday.end|date:"d.M Y"}} {{abday.reason.name}}{% if abday.confirm_status == 0 %} Genehmigt {% elif abday.confirm_status == 1 %} Beantragt {% else %} Abgelehnt {% endif %}{{abday.info}} {{abday.confirm_info}}{% if abday.confirm_status == 0 %} {% elif abday.confirm_status == 1 %} Beantragt {% else %} {% endif %}