Эх сурвалжийг харах

HUE-8530 [organization] Tweak older migration to pass make_migration command

Romain 6 жил өмнө
parent
commit
22ecd2d2b3

+ 1 - 1
apps/useradmin/src/useradmin/forms.py

@@ -93,7 +93,7 @@ class UserChangeForm(django.contrib.auth.forms.UserChangeForm):
   username = forms.RegexField(
       label=_t("Username"),
       max_length=30,
-      regex='^%s$' % (get_username_re_rule(),),
+      regex='^%s$' % (get_username_re_rule(),), # Could use UnicodeUsernameValidator()
       help_text = _t("Required. 30 characters or fewer. No whitespaces or colons."),
       error_messages = {'invalid': _t("Whitespaces and ':' not allowed") })
 

+ 28 - 20
desktop/core/src/desktop/migrations/0004_initial.py

@@ -5,27 +5,35 @@ from __future__ import unicode_literals
 import django.contrib.auth.models
 from django.db import migrations, models
 
+from desktop.conf import ENABLE_ORGANIZATIONS
 
-class Migration(migrations.Migration):
 
-    initial = True
+if ENABLE_ORGANIZATIONS.get():
+  class Migration(migrations.Migration):
+      dependencies = [
+          ('desktop', '0003_initial'),
+      ]
+else:
+  class Migration(migrations.Migration):
 
-    dependencies = [
-        ('desktop', '0003_initial'),
-    ]
+      initial = True
 
-    operations = [
-        migrations.CreateModel(
-            name='HueUser',
-            fields=[
-            ],
-            options={
-                'proxy': True,
-                'indexes': [],
-            },
-            bases=('auth.user',),
-            managers=[
-                ('objects', django.contrib.auth.models.UserManager()),
-            ],
-        ),
-    ]
+      dependencies = [
+          ('desktop', '0003_initial'),
+      ]
+
+      operations = [
+          migrations.CreateModel(
+              name='HueUser',
+              fields=[
+              ],
+              options={
+                  'proxy': True,
+                  'indexes': [],
+              },
+              bases=('auth.user',),
+              managers=[
+                  ('objects', django.contrib.auth.models.UserManager()),
+              ],
+          ),
+      ]