Commits

Osiloke Emoekpere committed 9f67a5a

Allow any widget to be added by superuser

  • Participants
  • Parent commits 6b4e094
  • Branches enhancements

Comments (0)

Files changed (1)

File widget/forms.py

 class WidgetForm(forms.ModelForm):
 
     def __init__(self, *args, **kwargs):
-        restrict_list = kwargs.pop("restrict_list", settings.RESTRICTED_WIDGETS)
+        print kwargs
+        user = kwargs.get("initial").get("user")
+        if user.is_superuser:
+            restrict_list = None
+        else:
+            restrict_list = kwargs.pop("restrict_list", settings.RESTRICTED_WIDGETS)
         super(WidgetForm, self).__init__(*args, **kwargs)
+        print self.data
         self.uuid = str(uuid4())
         self.fields["page"].queryset = Page.objects.get_query_set()
         self.fields["widget_class"].choices = get_all_page_widgets(restrict_list)