Commits

sirex  committed e764253

Some improvements inspyred by idea from #4 proposal.

  • Participants
  • Parent commits da52bcc

Comments (0)

Files changed (2)

File djangoplugins/point.py

 
 
     @classmethod
-    def get_model(cls, name=None):
+    def get_model(cls, name=None, status=ENABLED):
         """
         Returns model instance of plugin point or plugin, depending from which
         class this methos is called.
         ppath = cls.get_pythonpath()
         if is_plugin_point(cls):
             if name is not None:
+                kwargs = {}
+                if status is not None:
+                    kwargs['status'] = status
                 return Plugin.objects.get(point__pythonpath=ppath,
-                                          name=name)
+                                          name=name, **kwargs)
             else:
                 return PluginPointModel.objects.get(pythonpath=ppath)
         else:

File djangoplugins/tests.py

         self.assertFalse(MyPluginFull.is_active())
         self.assertEqual(2, MyPluginPoint.get_plugins_qs().count())
         self.assertEqual(2, len(list(MyPluginPoint.get_plugins())))
+        self.assertRaises(Plugin.DoesNotExist,
+                          lambda: MyPluginPoint.get_model('my-plugin-full'))
+
+        plugin_model = MyPluginPoint.get_model('my-plugin-full', status=None)
+        self.assertEqual('my-plugin-full', plugin_model.name)
 
     def test_get_meta(self):
         self.assertEqual('my-plugin-full', MyPluginFull.get_name())