Просмотр исходного кода

- Made loadfixtures smart and renamed it to loaddata, making it compatibile with south. #16
- Removed updatefixtures as obsolote
- Updated readme to cover new installation process

Ralfp 12 лет назад
Родитель
Сommit
fc712a4b12

+ 0 - 1
README.md

@@ -40,7 +40,6 @@ Misago comes with "deployment" python module that contains empty Misago configur
 After you set low-level configuration of Misago, fire following commands on manage.py:
 
 * __syncdb__ - this will create database structure for Misago
-* __loadfixtures__ - this will populate Misago database with default data
 * __adduser Admin admin@example.com password --admin__ - this will create first admin user
 * __genavatars__ - this will rebuild avatars gallery thumbnails
 

+ 32 - 0
misago/setup/management/commands/loaddata.py

@@ -0,0 +1,32 @@
+from django.conf import settings
+from django.core.management.base import BaseCommand, CommandError
+from django.db import (connections, router, transaction, DEFAULT_DB_ALIAS,
+      IntegrityError, DatabaseError)
+from django.utils import timezone
+from misago.setup.fixtures import load_app_fixtures, update_app_fixtures
+from misago.setup.models import Fixture
+from optparse import make_option
+
+class Command(BaseCommand):
+    """
+    Loads Misago fixtures
+    """
+    help = 'Load Misago fixtures'
+    
+    def handle(self, *args, **options):
+        fixture_data = {}
+        for fixture in Fixture.objects.all():
+            fixture_data[fixture.app_name] = fixture
+        loaded = 0
+        updated = 0
+        for app in settings.INSTALLED_APPS:
+            if app in fixture_data:
+                if update_app_fixtures(app):
+                    updated += 1
+                    print 'Updating fixtures from %s' % app
+            else:
+                if load_app_fixtures(app):
+                    loaded += 1
+                    print 'Loading fixtures from %s' % app
+                    Fixture.objects.create(app_name=app)
+        self.stdout.write('Loaded %s fixtures and updated %s fixtures.\n' % (loaded, updated))

+ 0 - 22
misago/setup/management/commands/loadfixtures.py

@@ -1,22 +0,0 @@
-from django.conf import settings
-from django.core.management.base import BaseCommand, CommandError
-from django.utils import timezone
-from misago.setup.fixtures import load_app_fixtures
-from misago.monitor.models import Item
-from optparse import make_option
-
-class Command(BaseCommand):
-    """
-    Loads Misago fixtures
-    """
-    help = 'Load Misago fixtures'
-    def handle(self, *args, **options):
-        if Item.objects.count() > 0:
-            self.stdout.write("\nIt appears that fixters have been loaded already. Use updatefixtures if you want to update database data.\n")
-        else:
-            fixtures = 0
-            for app in settings.INSTALLED_APPS:
-                if load_app_fixtures(app):
-                    fixtures += 1
-                    print 'Loading fixtures from %s' % app
-            self.stdout.write('\nLoaded fixtures from %s applications.\n' % fixtures)

+ 0 - 18
misago/setup/management/commands/updatefixtures.py

@@ -1,18 +0,0 @@
-from django.conf import settings
-from django.core.management.base import BaseCommand, CommandError
-from django.utils import timezone
-from misago.setup.fixtures import update_app_fixtures
-from optparse import make_option
-
-class Command(BaseCommand):
-    """
-    Updates Misago fixtures
-    """
-    help = 'Update Misago fixtures'
-    def handle(self, *args, **options):
-        fixtures = 0
-        for app in settings.INSTALLED_APPS:
-            if update_app_fixtures(app):
-                fixtures += 1
-                print 'Updating fixtures from %s' % app
-        self.stdout.write('\nUpdated fixtures from %s applications.\n' % fixtures)

+ 4 - 0
misago/setup/models.py

@@ -0,0 +1,4 @@
+from django.db import models
+
+class Fixture(models.Model):
+    app_name = models.CharField(max_length=255)