Browse Source

default user

Juan Carlos 5 years ago
parent
commit
dfca6e3a0f
3 changed files with 12 additions and 43 deletions
  1. BIN
      db.sqlite3.old
  2. 10 42
      project_base/apps.py
  3. 2 1
      project_base/settings.py

BIN
db.sqlite3.old


+ 10 - 42
project_base/apps.py

@@ -1,6 +1,7 @@
 from django.apps import AppConfig
 from constance.apps import ConstanceConfig
 from post_office.apps import PostOfficeConfig
+from django.contrib.auth.apps import AuthConfig
 
 
 from django.db import connection
@@ -18,6 +19,7 @@ def create_admin(sender=None, **kwargs):
 
     from django.contrib.auth.models import User
 
+    print("user post migrations")
     user = User.objects.update_or_create(username='admin',
                             defaults={
                              'email':'admin@server.com',
@@ -32,10 +34,17 @@ def create_admin(sender=None, **kwargs):
 class project_base(AppConfig):
     name = 'project_base'
     def ready(self):
+        print("base ready")
         super().ready()
         post_migrate.connect(create_admin, sender=self)
 
 
+class AuthConfigBase(AuthConfig):
+
+    def ready(self):
+        print("base ready")
+        super().ready()
+        post_migrate.connect(create_admin, sender=self)
 
 
 def create_emails(sender=None, **kwargs):
@@ -52,50 +61,9 @@ def create_emails(sender=None, **kwargs):
         )
     pass
 
-class PostOfficeBase(PostOfficeConfig):
 
+class PostOfficeBase(PostOfficeConfig):
 
     def ready(self):
-
-        # def db_table_exists(table_name):
-        #     return table_name in connection.introspection.table_names()
-        #
-        # if db_table_exists(  'post_office_emailtemplate' ):
-        #
-        #     from post_office.models import EmailTemplate
-        #     EmailTemplate.objects.update_or_create(
-        #         name='generic',
-        #         defaults={
-        #         'subject'      :  'Neue Nachricht von gemeinschaffen.at',
-        #         'description'  :  'Generic template',
-        #         'html_content' :  "content html",
-        #         'content'      :  "content"}
-        #         )
-
         super().ready()
-
         post_migrate.connect(create_emails, sender=self)
-
-
-
-#
-#
-# def db_table_exists(table_name):
-#     return table_name in connection.introspection.table_names()
-#
-# if db_table_exists(  'post_office_emailtemplate' ):
-#
-#
-#     tFile =  get_template('streets/email/generic.html')
-#     with open( str(tFile.template.origin), 'r') as file:
-#         tContentHTML = file.read()
-#         tContent =  strip_tags(tContentHTML)
-#
-#     EmailTemplate.objects.update_or_create(
-#         name='generic',
-#         defaults={
-#         'subject'      :  _('Message from pop-up.wien'),
-#         'description'  :  'Generic template',
-#         'html_content' :  tContentHTML,
-#         'content'      :  tContent}
-#         )

+ 2 - 1
project_base/settings.py

@@ -205,7 +205,8 @@ CONSTANCE_CONFIG = {
 
 INSTALLED_APPS = [
     'django.contrib.admin',
-    'django.contrib.auth',
+    # 'django.contrib.auth',
+    'project_base.apps.AuthConfigBase',
     'django.contrib.contenttypes',
     'django.contrib.sessions',
     'django.contrib.messages',