Commits

Maciej Wiśniowski committed f14a4ca

fixed workflows updates for postgres - issue #15

  • Participants
  • Parent commits 684fbf2

Comments (0)

Files changed (2)

File lfc/manage/views.py

 
     for slot in Slot.objects.all():
         if str(slot.id) in blocked_slots:
-            try:
-                PortletBlocking.objects.create(
+            PortletBlocking.objects.get_or_create(
                     slot_id=slot.id, content_type_id=object_type_id, content_id=object_id)
-            except IntegrityError:
-                pass
-
         else:
             try:
                 pb = PortletBlocking.objects.get(
 
     for permission in Permission.objects.all():
         if str(permission.id) in selected:
-            try:
-                WorkflowPermissionRelation.objects.create(workflow=workflow, permission=permission)
-            except IntegrityError:
-                pass
+            WorkflowPermissionRelation.objects.get_or_create(workflow=workflow, permission=permission)
         else:
             try:
                 wpr = WorkflowPermissionRelation.objects.get(workflow=workflow, permission=permission)
     """
     import_module(name).uninstall()
     import_module(name).install()
-    try:
-        Application.objects.create(name=name)
-    except IntegrityError:
-        pass
+    Application.objects.get_or_create(name=name)
 
     url = reverse("lfc_applications")
     return HttpResponseRedirect(url)

File lfc/utils/registration.py

 from django.core.cache import cache
 from django.contrib.contenttypes.models import ContentType
 from django.core.exceptions import ObjectDoesNotExist
-from django.db import IntegrityError
 
 # lfc imports
 from lfc.models import BaseContent
         name = name._proxy____str_cast()
     except AttributeError:
         pass
-    try:
-        Template.objects.create(name = name, path=path,
+    
+    Template.objects.get_or_create(name = name, path=path,
             children_columns=children_columns, images_columns=images_columns)
-    except IntegrityError:
-        pass
 
 def unregister_template(name):
     """Unregisters the template with the given name.