Commits

David Jean Louis committed 8bcc0fb

Fixed issue #77 (dashboard_id not being submitted)

  • Participants
  • Parent commits 732ba2c

Comments (0)

Files changed (2)

File admin_tools/dashboard/forms.py

     the user field. It expects the user to be passed in from the view.
     """
 
-    def __init__(self, user, *args, **kwargs):
+    def __init__(self, *args, **kwargs):
+        self.user = kwargs.pop('user', None)
+        self.dashboard_id = kwargs.pop('dashboard_id', None)
         super(DashboardPreferencesForm, self).__init__(*args, **kwargs)
-        self.user = user
 
     def save(self, *args, **kwargs):
         preferences = super(DashboardPreferencesForm, self).save(
             **kwargs
         )
         preferences.user = self.user
+        preferences.dashboard_id = self.dashboard_id
         preferences.save()
         return preferences
 
     class Meta:
-        fields = ('data', 'dashboard_id',)
+        fields = ('data',)
         model = DashboardPreferences

File admin_tools/dashboard/views.py

     if request.method == "POST":
         form = DashboardPreferencesForm(
             user=request.user,
+            dashboard_id=dashboard_id,
             data=request.POST,
             instance=preferences
         )
     else:
         form = DashboardPreferencesForm(
             user=request.user,
+            dashboard_id=dashboard_id,
             instance=preferences
         )
     return direct_to_template(request, 'admin_tools/dashboard/preferences_form.html', {