diff --git a/areas/__pycache__/__init__.cpython-38.pyc b/areas/__pycache__/__init__.cpython-38.pyc index 3ff9165..3fed716 100644 Binary files a/areas/__pycache__/__init__.cpython-38.pyc and b/areas/__pycache__/__init__.cpython-38.pyc differ diff --git a/areas/__pycache__/admin.cpython-38.pyc b/areas/__pycache__/admin.cpython-38.pyc index c67ec55..f4e758a 100644 Binary files a/areas/__pycache__/admin.cpython-38.pyc and b/areas/__pycache__/admin.cpython-38.pyc differ diff --git a/areas/__pycache__/apps.cpython-38.pyc b/areas/__pycache__/apps.cpython-38.pyc index e7a6b78..9290f60 100644 Binary files a/areas/__pycache__/apps.cpython-38.pyc and b/areas/__pycache__/apps.cpython-38.pyc differ diff --git a/areas/__pycache__/forms.cpython-38.pyc b/areas/__pycache__/forms.cpython-38.pyc index c9f46ac..b1a2c81 100644 Binary files a/areas/__pycache__/forms.cpython-38.pyc and b/areas/__pycache__/forms.cpython-38.pyc differ diff --git a/areas/__pycache__/models.cpython-38.pyc b/areas/__pycache__/models.cpython-38.pyc index 83d08a8..04f8d72 100644 Binary files a/areas/__pycache__/models.cpython-38.pyc and b/areas/__pycache__/models.cpython-38.pyc differ diff --git a/areas/__pycache__/urls.cpython-38.pyc b/areas/__pycache__/urls.cpython-38.pyc index ddff2d1..7683456 100644 Binary files a/areas/__pycache__/urls.cpython-38.pyc and b/areas/__pycache__/urls.cpython-38.pyc differ diff --git a/areas/__pycache__/views.cpython-38.pyc b/areas/__pycache__/views.cpython-38.pyc index aae0ee2..bf32680 100644 Binary files a/areas/__pycache__/views.cpython-38.pyc and b/areas/__pycache__/views.cpython-38.pyc differ diff --git a/areas/views.py b/areas/views.py index 7d40c1b..47a209d 100644 --- a/areas/views.py +++ b/areas/views.py @@ -53,6 +53,13 @@ class AreaDeleteView(LoginRequiredMixin, DeleteView): success_url = '/areas' template_name = 'areas/area_confirm_delete.html' + def delete(self, request, *args, **kwargs): + area = Areas.objects.get(pk=kwargs['pk']) + response = super(AreaDeleteView, self).delete(request, *args, **kwargs) + name = area.name + messages.success(request, f'Bereich ' +name+ ' wurde gelöscht!') + return response + def get_context_data(self, **kwargs): context = super(AreaDeleteView, self).get_context_data(**kwargs) context['active_link'] = 'areasmanagement' diff --git a/digitaleagentur/__pycache__/__init__.cpython-38.pyc b/digitaleagentur/__pycache__/__init__.cpython-38.pyc index f932871..1ffa496 100644 Binary files a/digitaleagentur/__pycache__/__init__.cpython-38.pyc and b/digitaleagentur/__pycache__/__init__.cpython-38.pyc differ diff --git a/digitaleagentur/__pycache__/settings.cpython-38.pyc b/digitaleagentur/__pycache__/settings.cpython-38.pyc index 274771a..301ecfc 100644 Binary files a/digitaleagentur/__pycache__/settings.cpython-38.pyc and b/digitaleagentur/__pycache__/settings.cpython-38.pyc differ diff --git a/digitaleagentur/__pycache__/urls.cpython-38.pyc b/digitaleagentur/__pycache__/urls.cpython-38.pyc index c4e18bc..654405b 100644 Binary files a/digitaleagentur/__pycache__/urls.cpython-38.pyc and b/digitaleagentur/__pycache__/urls.cpython-38.pyc differ diff --git a/digitaleagentur/__pycache__/views.cpython-38.pyc b/digitaleagentur/__pycache__/views.cpython-38.pyc index ecd32fe..268c51d 100644 Binary files a/digitaleagentur/__pycache__/views.cpython-38.pyc and b/digitaleagentur/__pycache__/views.cpython-38.pyc differ diff --git a/digitaleagentur/__pycache__/wsgi.cpython-38.pyc b/digitaleagentur/__pycache__/wsgi.cpython-38.pyc index 3e8074e..c66704f 100644 Binary files a/digitaleagentur/__pycache__/wsgi.cpython-38.pyc and b/digitaleagentur/__pycache__/wsgi.cpython-38.pyc differ diff --git a/news/__pycache__/__init__.cpython-38.pyc b/news/__pycache__/__init__.cpython-38.pyc index fe38ad1..50d4891 100644 Binary files a/news/__pycache__/__init__.cpython-38.pyc and b/news/__pycache__/__init__.cpython-38.pyc differ diff --git a/news/__pycache__/admin.cpython-38.pyc b/news/__pycache__/admin.cpython-38.pyc index 144b68c..8692976 100644 Binary files a/news/__pycache__/admin.cpython-38.pyc and b/news/__pycache__/admin.cpython-38.pyc differ diff --git a/news/__pycache__/apps.cpython-38.pyc b/news/__pycache__/apps.cpython-38.pyc index c643216..45a5cfe 100644 Binary files a/news/__pycache__/apps.cpython-38.pyc and b/news/__pycache__/apps.cpython-38.pyc differ diff --git a/news/__pycache__/forms.cpython-38.pyc b/news/__pycache__/forms.cpython-38.pyc index 2903330..4f2a036 100644 Binary files a/news/__pycache__/forms.cpython-38.pyc and b/news/__pycache__/forms.cpython-38.pyc differ diff --git a/news/__pycache__/models.cpython-38.pyc b/news/__pycache__/models.cpython-38.pyc index b32eaa5..bd27abd 100644 Binary files a/news/__pycache__/models.cpython-38.pyc and b/news/__pycache__/models.cpython-38.pyc differ diff --git a/news/__pycache__/urls.cpython-38.pyc b/news/__pycache__/urls.cpython-38.pyc index 329ef64..4f0ef46 100644 Binary files a/news/__pycache__/urls.cpython-38.pyc and b/news/__pycache__/urls.cpython-38.pyc differ diff --git a/news/__pycache__/views.cpython-38.pyc b/news/__pycache__/views.cpython-38.pyc index 069e8d5..f23ea34 100644 Binary files a/news/__pycache__/views.cpython-38.pyc and b/news/__pycache__/views.cpython-38.pyc differ diff --git a/orga/__pycache__/__init__.cpython-38.pyc b/orga/__pycache__/__init__.cpython-38.pyc index 496d807..5fbb46a 100644 Binary files a/orga/__pycache__/__init__.cpython-38.pyc and b/orga/__pycache__/__init__.cpython-38.pyc differ diff --git a/orga/__pycache__/admin.cpython-38.pyc b/orga/__pycache__/admin.cpython-38.pyc index 6513846..52eca0c 100644 Binary files a/orga/__pycache__/admin.cpython-38.pyc and b/orga/__pycache__/admin.cpython-38.pyc differ diff --git a/orga/__pycache__/apps.cpython-38.pyc b/orga/__pycache__/apps.cpython-38.pyc index 52f5b45..bad2d21 100644 Binary files a/orga/__pycache__/apps.cpython-38.pyc and b/orga/__pycache__/apps.cpython-38.pyc differ diff --git a/orga/__pycache__/models.cpython-38.pyc b/orga/__pycache__/models.cpython-38.pyc index 96f69e5..0ceedb8 100644 Binary files a/orga/__pycache__/models.cpython-38.pyc and b/orga/__pycache__/models.cpython-38.pyc differ diff --git a/orga/__pycache__/urls.cpython-38.pyc b/orga/__pycache__/urls.cpython-38.pyc index 442122f..dbd2557 100644 Binary files a/orga/__pycache__/urls.cpython-38.pyc and b/orga/__pycache__/urls.cpython-38.pyc differ diff --git a/orga/__pycache__/views.cpython-38.pyc b/orga/__pycache__/views.cpython-38.pyc index bdc046f..8f8bb8b 100644 Binary files a/orga/__pycache__/views.cpython-38.pyc and b/orga/__pycache__/views.cpython-38.pyc differ diff --git a/standards/__pycache__/__init__.cpython-38.pyc b/standards/__pycache__/__init__.cpython-38.pyc index 3efa48c..10c9914 100644 Binary files a/standards/__pycache__/__init__.cpython-38.pyc and b/standards/__pycache__/__init__.cpython-38.pyc differ diff --git a/standards/__pycache__/admin.cpython-38.pyc b/standards/__pycache__/admin.cpython-38.pyc index a4a2637..636f01b 100644 Binary files a/standards/__pycache__/admin.cpython-38.pyc and b/standards/__pycache__/admin.cpython-38.pyc differ diff --git a/standards/__pycache__/apps.cpython-38.pyc b/standards/__pycache__/apps.cpython-38.pyc index 4552384..4506211 100644 Binary files a/standards/__pycache__/apps.cpython-38.pyc and b/standards/__pycache__/apps.cpython-38.pyc differ diff --git a/standards/__pycache__/forms.cpython-38.pyc b/standards/__pycache__/forms.cpython-38.pyc index 26a019c..a2f4a40 100644 Binary files a/standards/__pycache__/forms.cpython-38.pyc and b/standards/__pycache__/forms.cpython-38.pyc differ diff --git a/standards/__pycache__/models.cpython-38.pyc b/standards/__pycache__/models.cpython-38.pyc index 49f2123..fdd798a 100644 Binary files a/standards/__pycache__/models.cpython-38.pyc and b/standards/__pycache__/models.cpython-38.pyc differ diff --git a/standards/__pycache__/urls.cpython-38.pyc b/standards/__pycache__/urls.cpython-38.pyc index 29e42d3..67f12f1 100644 Binary files a/standards/__pycache__/urls.cpython-38.pyc and b/standards/__pycache__/urls.cpython-38.pyc differ diff --git a/standards/__pycache__/views.cpython-38.pyc b/standards/__pycache__/views.cpython-38.pyc index c6ad04a..c208d1a 100644 Binary files a/standards/__pycache__/views.cpython-38.pyc and b/standards/__pycache__/views.cpython-38.pyc differ diff --git a/standards/templates/standards/standards_single.html b/standards/templates/standards/standards_single.html index a4277e4..df66ab3 100644 --- a/standards/templates/standards/standards_single.html +++ b/standards/templates/standards/standards_single.html @@ -12,6 +12,7 @@
+ Hallo {{username}},
+ für Sie wurde ein Account in der Agentur {{user.profile.agency.name}} erstellt. Bitte gehen Sie auf folgenden Link, um ein Passwort zu erstellen:
+
+ https://digitale-agentur.com/password-reset +
+ Weitere Informationen erhalten Sie von Ihrem Agenturleiter. + +
+ Vielen Dank, dass Sie die Plattform Digitale Agentur nutzen!
+
+ Mit freundlichen Grüßen
+
+ Ihr Team von Digitale Agentur
+
- Hallo {{user.first_name}} {{user.last_name}},
- Sie haben eine neues Passwort für den Zugang ihrer Agentur {{user.profile.agency.name}} angefordert. Bitte gehen Sie auf folgenden Link, um sich ein Passwort zu setzen:
+ Hallo {{user.first_name}} {{user.last_name}},
+ Sie haben eine neues Passwort für den Zugang ihrer Agentur {{user.profile.agency.name}} angefordert. Bitte gehen Sie auf folgenden Link, um ein Passwort zu erstellen:
+
{% block reset_link %} - {{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %} +
- Vielen Dank, dass Sie die Plattform Digitale Agentur nutzen!
-
+ Vielen Dank, dass Sie die Plattform Digitale Agentur nutzen!
+
Mit freundlichen Grüßen
Ihr Team von Digitale Agentur
Hallo {{username}},
- Ihre Agentur wurde erstellt. Sie können sich nun hier anmelden und ihre Agentur gestalten.
-
+ Ihre Agentur wurde erstellt. Sie können sich nun hier anmelden und ihre Agentur gestalten:
+
+ https://digitale-agentur.com +
+Vielen Dank, dass Sie die Plattform Digitale Agentur nutzen! diff --git a/users/views.py b/users/views.py index 74f8ebb..6184fa4 100644 --- a/users/views.py +++ b/users/views.py @@ -69,7 +69,7 @@ def dashboard(request): # Loading only user same agency # Change context and return for template-data # # Get all Users of the Same Agency as logged user - standards_of_agency = Standards.objects.filter(agency__pk=request.user.profile.agency.pk).order_by('-created_standard_date')[:10] + standards_of_agency = Standards.objects.filter(agency__pk=request.user.profile.agency.pk).filter(public=True).order_by('-created_standard_date')[:10] filterdate = datetime.now() news = News.objects.filter(agency__pk=request.user.profile.agency.pk).filter(go_online_on__lt=filterdate).filter(go_offline_on__gt=filterdate) @@ -114,16 +114,20 @@ class UsersCreateUser(LoginRequiredMixin, CreateView): messages.success(self.request, f'Benutzer angelegt!') # SAVE OBJECTS TO SIGNALE! form.instance.agency = self.request.user.profile.agency - + newuser_name = form.cleaned_data.get('first_name') + " " + form.cleaned_data.get('last_name') + msg_html = render_to_string('users/newusers_email.html', {'username': newuser_name}) # E-Mail für Passwort-Setzung! send_mail( - self.request.user.profile.agency.name + ' Anmeldung', + self.request.user.profile.agency.name + ' Account', 'Hallo ' + form.cleaned_data.get('first_name') + ' ' + form.cleaned_data.get('last_name') + '! Bitte setzen sie sich auf https://digitale-agentur.com/password-reset/ ein Passwort.', 'support@digitale-agentur.com', [form.cleaned_data.get('email')], + html_message=msg_html, fail_silently=False, ) + + return super().form_valid(form) # USER muss eingeloggt sein, um diese Seite zu sehen @@ -212,27 +216,61 @@ class ProfileUpdateView(LoginRequiredMixin, UpdateView): context['active_link'] = 'usersmanagement' return context -# Delete a user! +''' + + # DELETE A USER + + Hier wird das Profil gelöscht, aber damit auch der User. Zusätzlich werden + alle Standards, Bereiche und Tasks des zu löschenden Nutzers dem User + zugeschrieben, welcher eingeloggt ist. Das passiert VOR dem löschen! + +''' class ProfileDeleteView(LoginRequiredMixin, DeleteView): model = User success_url = '/dashboard/usersman' template_name = 'users/user_confirm_delete.html' - def test_func(self): - tempuser = self.get_object() - todel_name = self.get_object().first_name + " " + self.get_object().last_name - # self request user ist der aktuell user - messages.success(self.request, f'Benutzer {todel_name} entfernet!') - if self.request.user == tempuser: - return False - return True + + def delete(self, request, *args, **kwargs): + user = User.objects.get(pk=kwargs['pk']) + logged_user = request.user + areas_fs = Areas.objects.filter(created_area_by=user) + for a in areas_fs: + a.created_area_by = logged_user + a.save() + + # ACHTUNG! Bei Tasks heißt es leider auch created_area... + task_fs = Tasks.objects.filter(created_area_by=user) + for t in task_fs: + t.created_area_by = logged_user + t.save() + + standards_fs = Standards.objects.filter(created_standard_by=user) + print(standards_fs) + for a in standards_fs: + a.created_standard_by = logged_user + a.save() + + standards_fs = Standards.objects.filter(last_modified_by=user) + for a in standards_fs: + a.last_modified_by = logged_user + a.save() + + standards_fs = Standards.objects.filter(published_by=user) + for a in standards_fs: + a.published_by = logged_user + a.save() + + response = super(ProfileDeleteView, self).delete(request, *args, **kwargs) + name = user.first_name + " " + user.last_name + messages.success(request, f'Benutzer ' +name+ ' wurde gelöscht!') + return response @login_required def agency(request): context = { 'active_link' : 'agencyinfo' } - return render(request, 'users/agency.html', context)