Löschabläufe gecheckt und fertig implementiert - BITTE CHECKEN!
E-Mail-Tempates Registrierung, Passwort vergessen und neue Nutzer drinnen
This commit is contained in:
parent
83ace952be
commit
eac471b504
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -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'
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -12,6 +12,7 @@
|
|||
<h2>{{standard.name}}</h2>
|
||||
Erstellt durch <a href="{% url 'orga-single' standard.created_standard_by.pk %}">{{standard.created_standard_by.first_name}} {{standard.created_standard_by.last_name}}</a> am {{standard.created_standard_date}} | Zuletzt bearbeitet von <a href="{% url 'orga-single' standard.last_modified_by.pk %}">{{ standard.last_modified_by.first_name}} {{ standard.last_modified_by.last_name}}</a> am {{ standard.last_modified_on}}
|
||||
{% if standard.created_standard_by == user or perms.users.standard_management %}
|
||||
| <a href="{% url 'standard-delete' standard.pk %}">Löschen</a>
|
||||
| <a href="{% url 'standard-update' standard.pk %}">Bearbeiten</a>
|
||||
{% endif%}
|
||||
</small>
|
||||
|
|
|
|||
|
|
@ -130,6 +130,13 @@ class StandardDeleteView(LoginRequiredMixin, DeleteView):
|
|||
success_url = '/standards'
|
||||
template_name = 'standards/standard_confirm_delete.html'
|
||||
|
||||
def delete(self, request, *args, **kwargs):
|
||||
standard = Standards.objects.get(pk=kwargs['pk'])
|
||||
response = super(StandardDeleteView, self).delete(request, *args, **kwargs)
|
||||
names = standard.name
|
||||
messages.success(request, f'Standard ' +names+ ' wurde gelöscht!')
|
||||
return response
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(StandardDeleteView, self).get_context_data(**kwargs)
|
||||
context['active_link'] = 'standards'
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -49,6 +49,13 @@ class TasksDeleteView(LoginRequiredMixin, DeleteView):
|
|||
model = Tasks
|
||||
success_url = '/tasks'
|
||||
template_name = 'tasks/tasks_confirm_delete.html'
|
||||
|
||||
def delete(self, request, *args, **kwargs):
|
||||
area = Tasks.objects.get(pk=kwargs['pk'])
|
||||
response = super(TasksDeleteView, self).delete(request, *args, **kwargs)
|
||||
name = area.name
|
||||
messages.success(request, f'Aufgabe ' +name+ ' wurde gelöscht!')
|
||||
return response
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(TasksDeleteView, self).get_context_data(**kwargs)
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,9 +1,10 @@
|
|||
from django.db.models.signals import post_save
|
||||
from django.db.models.signals import post_save, pre_delete
|
||||
from django.contrib.auth.models import User
|
||||
from django.dispatch import receiver
|
||||
from .models import Profile, Agency
|
||||
from django.contrib.auth.models import Permission
|
||||
|
||||
|
||||
@receiver(post_save, sender=User)
|
||||
def create_profile(sender, instance, created, **kwargs):
|
||||
if created:
|
||||
|
|
@ -25,4 +26,4 @@ def create_profile(sender, instance, created, **kwargs):
|
|||
|
||||
@receiver(post_save, sender=User)
|
||||
def save_profile(sender, instance, **kwargs):
|
||||
instance.profile.save()
|
||||
instance.profile.save()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
{% load i18n %}{% autoescape off %}
|
||||
<html>
|
||||
<head>
|
||||
<link href='https://fonts.googleapis.com/css?family=Roboto&display=swap' rel='stylesheet' type='text/css'>
|
||||
<style>
|
||||
html {font-family: 'Roboto' !important;}html h6 {font-family: 'Roboto' !important;font-size: 1.0em;}html h5 {font-family: 'Roboto' !important;font-size: 1.1em;}html h4 {font-family: 'Roboto' !important;font-size: 1.3em;}html h3 {font-family: 'Roboto' !important;font-size: 1.5em;}html h2 {font-family: 'Roboto' !important;font-size: 1.7em;}html h1 {font-family: 'Roboto' !important;font-size: 2em;}body p{font-family: 'Roboto' !important;font-size: 0.9; color: #000000;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h3>Digitale Agentur | Account</h3>
|
||||
<hr>
|
||||
<p>
|
||||
Hallo {{username}},<br /><br />
|
||||
für Sie wurde ein Account in der Agentur <b>{{user.profile.agency.name}}</b> erstellt. Bitte gehen Sie auf folgenden Link, um ein Passwort zu erstellen:
|
||||
<p>
|
||||
<a href="https://digitale-agentur.com/password-reset">https://digitale-agentur.com/password-reset</a>
|
||||
</p>
|
||||
Weitere Informationen erhalten Sie von Ihrem Agenturleiter.
|
||||
</p>
|
||||
<p>
|
||||
Vielen Dank, dass Sie die Plattform <b>Digitale Agentur</b> nutzen!
|
||||
<br /><br />
|
||||
Mit freundlichen Grüßen
|
||||
<br /><br />
|
||||
Ihr Team von Digitale Agentur
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
{% endautoescape %}
|
||||
|
|
@ -1,26 +1,32 @@
|
|||
{% load i18n %}{% autoescape off %}
|
||||
<html>
|
||||
<head>
|
||||
<link href='https://fonts.googleapis.com/css?family=Roboto&display=swap' rel='stylesheet' type='text/css'>
|
||||
<style>
|
||||
html {font-family: 'Roboto' !important;}html h6 {font-family: 'Roboto' !important;font-size: 1.0em;}html h5 {font-family: 'Roboto' !important;font-size: 1.1em;}html h4 {font-family: 'Roboto' !important;font-size: 1.3em;}html h3 {font-family: 'Roboto' !important;font-size: 1.5em;}html h2 {font-family: 'Roboto' !important;font-size: 1.7em;}html h1 {font-family: 'Roboto' !important;font-size: 2em;}body p{font-family: 'Roboto' !important;font-size: 0.9; color: #000000;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h3>Digitale Agentur Passwort</h3>
|
||||
<h3>Digitale Agentur | Passwort vergessen</h3>
|
||||
<hr>
|
||||
<p>
|
||||
Hallo {{user.first_name}} {{user.last_name}},<br />
|
||||
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}},<br /><br />
|
||||
Sie haben eine neues Passwort für den Zugang ihrer Agentur <b>{{user.profile.agency.name}}</b> angefordert. Bitte gehen Sie auf folgenden Link, um ein Passwort zu erstellen:
|
||||
<p>
|
||||
{% block reset_link %}
|
||||
{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}
|
||||
<h4>{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}</h4>
|
||||
{% endblock %}
|
||||
Ihr Benutzername: {{ user.get_username }}
|
||||
<br />
|
||||
<h4>Ihr Benutzername: {{ user.get_username }}</h4>
|
||||
</p>
|
||||
Sollten Sie kein Passwort angefordert haben, ignorieren Sie diese E-Mail.
|
||||
</p>
|
||||
<p>
|
||||
Vielen Dank, dass Sie die Plattform <i>Digitale Agentur</i> nutzen!
|
||||
<br />
|
||||
Vielen Dank, dass Sie die Plattform <b>Digitale Agentur</b> nutzen!
|
||||
<br /><br />
|
||||
Mit freundlichen Grüßen
|
||||
<br /><br />
|
||||
Ihr Team von Digitale Agentur
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
{% endautoescape %}
|
||||
{% endautoescape %}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,23 @@
|
|||
{% load i18n %}{% autoescape off %}
|
||||
<html>
|
||||
<head>
|
||||
<link href='https://fonts.googleapis.com/css?family=Roboto&display=swap' rel='stylesheet' type='text/css'>
|
||||
<style>
|
||||
html {font-family: 'Roboto' !important;}html h6 {font-family: 'Roboto' !important;font-size: 1.0em;}html h5 {font-family: 'Roboto' !important;font-size: 1.1em;}html h4 {font-family: 'Roboto' !important;font-size: 1.3em;}html h3 {font-family: 'Roboto' !important;font-size: 1.5em;}html h2 {font-family: 'Roboto' !important;font-size: 1.7em;}html h1 {font-family: 'Roboto' !important;font-size: 2em;}body p{font-family: 'Roboto' !important;font-size: 0.9; color: #000000;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h3>Digitale Agentur Registrierung</h3>
|
||||
<p>
|
||||
Hallo {{username}},<br />
|
||||
Ihre Agentur wurde erstellt. Sie können sich nun <a href="https://digitale-agentur.com">hier anmelden</a> und ihre Agentur gestalten.
|
||||
<br /><br />
|
||||
Ihre Agentur wurde erstellt. Sie können sich nun hier anmelden und ihre Agentur gestalten:
|
||||
<p>
|
||||
<a href="https://digitale-agentur.com">https://digitale-agentur.com</a>
|
||||
</p>
|
||||
<br />
|
||||
Ihr Benutzername: {{ username_log }}
|
||||
<br />
|
||||
Sollten Sie kein Passwort angefordert haben, ignorieren Sie diese E-Mail.
|
||||
Weitere Informationen erhalten Sie in unserem Wiki <a href="https://wiki.digitale-agentur.com/">https://wiki.digitale-agentur.com/</a> oder per E-Mail an support@digitale-agentur.com!
|
||||
</p>
|
||||
<p>
|
||||
Vielen Dank, dass Sie die Plattform <i>Digitale Agentur</i> nutzen!
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue