depleater avatar depleater committed e31a1a4

Fixed (most of) the outstanding Pylint violations.

Comments (0)

Files changed (3)

 sys.path.append(os.path.abspath("../../../parts/permissions"))
 sys.path.append(os.path.abspath("../../../parts/workflows"))
 
-from permissions import utils
-
 # -- General configuration -----------------------------------------------------
 
 # Add any Sphinx extension module names here, as strings. They can be extensions

workflows/models.py

 
     """
     name = models.CharField(_(u"Name"), max_length=100, unique=True)
-    initial_state = models.ForeignKey("State", verbose_name=_(u"Initial state"), related_name="workflow_state", blank=True, null=True)
-    permissions = models.ManyToManyField(Permission, verbose_name=_(u"Permissions"), symmetrical=False, through="WorkflowPermissionRelation")
+    initial_state = models.ForeignKey(
+            "State",
+            verbose_name=_(u"Initial state"),
+            related_name="workflow_state",
+            blank=True,
+            null=True,
+            )
+    permissions = models.ManyToManyField(
+            Permission,
+            verbose_name=_(u"Permissions"),
+            symmetrical=False,
+            through="WorkflowPermissionRelation",
+            )
 
     def __unicode__(self):
         return self.name
             if wor.workflow != self:
                 wor.workflow = self
                 wor.save()
-                workflows.utils.set_state(self.initial_state)
+                workflows.utils.set_state(obj, self.initial_state)
 
 
 class State(models.Model):
     """
     name = models.CharField(_(u"Name"), max_length=100)
     workflow = models.ForeignKey(Workflow, verbose_name=_(u"Workflow"), related_name="states")
-    transitions = models.ManyToManyField("Transition", verbose_name=_(u"Transitions"), blank=True, null=True, related_name="states")
+    transitions = models.ManyToManyField(
+            "Transition",
+            verbose_name=_(u"Transitions"),
+            blank=True,
+            null=True,
+            related_name="states",
+            )
 
     class Meta:
         ordering = ("name", )
     """
     name = models.CharField(_(u"Name"), max_length=100)
     workflow = models.ForeignKey(Workflow, verbose_name=_(u"Workflow"), related_name="transitions")
-    destination = models.ForeignKey(State, verbose_name=_(u"Destination"), null=True, blank=True, related_name="destination_state")
+    destination = models.ForeignKey(
+            State,
+            verbose_name=_(u"Destination"),
+            null=True,
+            blank=True,
+            related_name="destination_state",
+            )
     condition = models.CharField(_(u"Condition"), blank=True, max_length=100)
     permission = models.ForeignKey(Permission, verbose_name=_(u"Permission"), blank=True, null=True)
 
     state
         The state of content. This must be a State instance.
     """
-    content_type = models.ForeignKey(ContentType, verbose_name=_(u"Content type"), related_name="state_object", blank=True, null=True)
+    content_type = models.ForeignKey(
+            ContentType,
+            verbose_name=_(u"Content type"),
+            related_name="state_object",
+            blank=True,
+            null=True,
+            )
     content_id = models.PositiveIntegerField(_(u"Content id"), blank=True, null=True)
     content = generic.GenericForeignKey(ct_field="content_type", fk_field="content_id")
     state = models.ForeignKey(State, verbose_name=_(u"State"))
         The workflow which is assigned to an object. This needs to be a workflow
         instance.
     """
-    content_type = models.ForeignKey(ContentType, verbose_name=_(u"Content type"), related_name="workflow_object", blank=True, null=True)
+    content_type = models.ForeignKey(
+            ContentType,
+            verbose_name=_(u"Content type"),
+            related_name="workflow_object",
+            blank=True,
+            null=True,
+            )
     content_id = models.PositiveIntegerField(_(u"Content id"), blank=True, null=True)
     content = generic.GenericForeignKey(ct_field="content_type", fk_field="content_id")
     workflow = models.ForeignKey(Workflow, verbose_name=_(u"Workflow"), related_name="wors")

workflows/tests.py

         result = workflows.utils.get_workflow(self.user)
         self.assertEqual(result, self.w)
 
-        result = workflows.utils.remove_workflow_from_object(self.user)
+        # Verify that the workflow is gone again after removing it
+        # from the object (ie. user).
+        workflows.utils.remove_workflow_from_object(self.user)
+        result = workflows.utils.get_workflow(self.user)
         self.assertEqual(result, None)
 
     def test_remove_workflow_1(self):
         result = workflows.utils.get_workflow(self.user)
         self.assertEqual(result, self.w)
 
-        result = workflows.utils.remove_workflow(self.user)
+        # Check that the user no longer has a workflow after calling
+        # remove_workflow on the user.
+        workflows.utils.remove_workflow(self.user)
+        result = workflows.utils.get_workflow(self.user)
         self.assertEqual(result, None)
 
     def test_get_allowed_transitions(self):
         self.role_1 = permissions.utils.register_role("Role 1")
         permissions.utils.add_role(self.user, self.role_1)
         self.page_1 = FlatPage.objects.create(url="/page-1/", title="Page 1")
+        self.view = None
 
     def test_unicode(self):
         """
         """
         create_workflow(self)
         self.page_1 = FlatPage.objects.create(url="/page-1/", title="Page 1", id=1)
+        self.owner = None
+        self.view = None
 
     def test_unicode(self):
         """
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 ProjectModifiedEvent.java.
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.