Exemplo n.º 1
0
 def put(self, request):
     try:
         current_user = request.user
         widgets = request.data['widgets']
         dcs = DashboardConfig.objects.filter(user__pk=current_user.id)
         if len(dcs) > 0:
             dc = dcs[0]
             dc.widgets = widgets
         else:
             dc = DashboardConfig(widgets=widgets)
             dc.user_id = current_user.id
         dc.save()
         return Response(DashboardConfigSerializer(dc).data)
     except Exception as e:
         handle_exception(e, request)
Exemplo n.º 2
0
 def put(self, request):
     try:
         current_user = request.user
         widgets = request.data['widgets']
         dcs = DashboardConfig.objects.filter(user__pk=current_user.id)
         if len(dcs) > 0:
             dc = dcs[0]
             dc.widgets = widgets
         else:
             dc = DashboardConfig(widgets = widgets)
             dc.user_id = current_user.id
         dc.save()
         return Response(DashboardConfigSerializer(dc).data)
     except Exception, e:
         handle_exception(e, request)