Jannis Leidel committed db0f5b2 Merge

Comments (0)

Files changed (1)


     Also has a default max_length so you don't have to worry about
     setting that.
+    Alos features a ``no_check_for_status`` argument to make sure
+    South can handle this field when it freezes a model.
     def __init__(self, *args, **kwargs):
         kwargs.setdefault('max_length', 100)
+        self.check_for_status = not kwargs.pop('no_check_for_status', False)
         super(StatusField, self).__init__(*args, **kwargs)
     def contribute_to_class(self, cls, name):
-        if not cls._meta.abstract:
+        if not cls._meta.abstract and self.check_for_status:
             assert hasattr(cls, 'STATUS'), \
                 "To use StatusField, the model '%s' must have a STATUS choices class attribute." \
                 % cls.__name__
     # For a normal MarkupField, the add_excerpt_field attribute is
     # always True, which means no_excerpt_field arg will always be
     # True in a frozen MarkupField, which is what we want.
-    add_introspection_rules(rules=[((SplitField,),
-                                    [],
-                                    {'no_excerpt_field': ('add_excerpt_field',
-                                                          {})})],
-                            patterns=['model_utils\.fields\.'])
+    add_introspection_rules(rules=[
+        (
+            (SplitField,),
+            [],
+            {'no_excerpt_field': ('add_excerpt_field', {})}
+        ),
+        (
+            (MonitorField,),
+            [],
+            {'monitor': ('monitor', {})}
+        ),
+        (
+            (StatusField,),
+            [],
+            {'no_check_for_status': ('check_for_status', {})}
+        ),
+    ], patterns=['model_utils\.fields\.'])
 except ImportError:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.