diff --git a/dasettings/forms.py b/dasettings/forms.py index 11bbe89..a42438c 100644 --- a/dasettings/forms.py +++ b/dasettings/forms.py @@ -115,6 +115,13 @@ class AgencyModulsForm(forms.ModelForm): } fields = ['module_news','module_organizer','module_files','module_organigramm', 'module_messages', 'module_timemanagement'] + # RAUSNHEMEN WENN DEV DONE + def __init__(self, *args, **kwargs): + super(AgencyModulsForm, self).__init__(*args, **kwargs) + self.fields['module_timemanagement'].widget.attrs['readonly'] = True + self.fields['module_timemanagement'].widget.attrs['disabled'] = True + + # NEW USER FORM class UserNewUserForm(forms.ModelForm): diff --git a/digitaleagentur/__pycache__/settings.cpython-38.pyc b/digitaleagentur/__pycache__/settings.cpython-38.pyc index f348433..3b3d210 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 8d3422d..e089b04 100644 --- a/digitaleagentur/settings.py +++ b/digitaleagentur/settings.py @@ -14,13 +14,12 @@ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - - ############################################## DEV ##################################### BASE_URL = "https://dev01.digitale-agentur.com/" CRONAPIKEY = "gCddsaz6NOnE9QbXZM5LasdEk122D" +MAILINFOKEY = "jka7sd8iukashdna78skduJAHDsu6dilaksdjba65a68iadbhjak" # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False # MAIL DEV EMAIL_HOST = 'smtp.strato.de' @@ -43,6 +42,7 @@ DATABASES = { ############################################## DEV ##################################### + # Nach zehn Stunden läuft der Cookie ab! SESSION_COOKIE_AGE = 8*60*60 diff --git a/users/models.py b/users/models.py index 415d28e..7c6f541 100644 --- a/users/models.py +++ b/users/models.py @@ -95,7 +95,11 @@ class Agency(models.Model): module_news = models.BooleanField(default=True) module_organizer = models.BooleanField(default=True) module_files = models.BooleanField(default=True) + module_organigramm = models.BooleanField(default=True) + # Steckbrief dynamisch aus Standard + dynamicprofile = models.BooleanField(default=True) + module_messages = models.BooleanField(default=True) # KOSTENPFLICHTIGE MODULE @@ -106,11 +110,7 @@ class Agency(models.Model): module_timemanagement_price = models.FloatField(default=10.0, max_length=9, blank=True) # Zeiterfassung Ja/Nein module_timemanagement_ze = models.BooleanField(default=False) - - - # Steckbrief dynamisch aus Standard - dynamicprofile = models.BooleanField(default=True) - + vve = models.CharField(default="", max_length=200, blank=True) def __str__(self): diff --git a/users/templates/users/password_to_username_mail.html b/users/templates/users/password_to_username_mail.html new file mode 100644 index 0000000..f6f2d4c --- /dev/null +++ b/users/templates/users/password_to_username_mail.html @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + +
+ +
+ + + + + + + + + + + + + +
+

+ +
+
+

Digitale Agentur | Accountinformation

+
+
+
+

Hallo {{user.first_name}} {{user.last_name}},

+

ab sofort können Sie sich nur noch mit Ihrer E-Mailadresse als Benutzernamen in der Digitalen Agentur anmelden. Ihre hinterlegte Adresse lautet: {{user.email}}.

+

Weitere Informationen erhalten Sie von Ihrem Agenturleiter. +

Mit freundlichen Grüßen

+

Ihr Team von Digitale Agentur

+
+
+

+ +
+
+ +
+
+ +
+ + + \ No newline at end of file diff --git a/users/views.py b/users/views.py index 47a62b9..46d9e38 100644 --- a/users/views.py +++ b/users/views.py @@ -793,7 +793,8 @@ def impressum(request): ''' def cronactions(request, code): - if(code == settings.CRONAPIKEY): + data = {} + if(code == settings.CRONAPIKEY): # NEWS CHECKING all_unnotifc_news = News.objects.filter(agnotify=False, go_online_on__lt=timezone.now()) @@ -802,7 +803,7 @@ def cronactions(request, code): usersofagency = User.objects.filter(profile__agency=news.agency) news.agnotify = True news.save() - + for user in usersofagency: if(user.profile.news_mail): notificationtext = "Neue Agenturnews: " + news.name @@ -823,7 +824,34 @@ def cronactions(request, code): if(user.profile.news_push): newnotification = UserNotification(touser=user, notificationtext="Neue Agenturnews: " + news.name, notificationtype="agencynews", elementid=news.pk) newnotification.save() + data.update({"status" : "ok"}) + elif(code == settings.MAILINFOKEY): + + # GET ALL USERS + users = User.objects.all().exclude(username="root") + + for u in users: + u.username = u.email + try: + u.save() + notificationtext = "ab sofort können Sie sich nur noch mit Ihrer E-Mailadresse anmelden. Diese lautet " + u.email + "!" + msg_html = render_to_string('users/password_to_username_mail.html', {'user': u, 'notificationtext' : notificationtext}) + send_mail( + 'Agentur-Benachrichtigung', + 'Hallo ' + u.first_name + ' ' + u.last_name + '! ' + notificationtext, + 'support@digitale-agentur.com', + [u.email], + html_message=msg_html, + fail_silently=True + ) + data.update({"user_" + str(u.pk) : u.email}) + except: + data.update({"ERROR_user_" + str(u.pk) : u.email}) else: - print("API CODE FAILED") - return JsonResponse({}) \ No newline at end of file + print("API CODE FAILED") + data.update({"status" : "failed"}) + return JsonResponse(data) + + +