blob: 212cc4de7a856106984e8086be3cd5d3cb04ce80 [file] [log] [blame]
Scott Bakerc7325a42014-05-30 16:06:46 -07001from view_common import *
2
3class DashboardCustomize(View):
4 def post(self, request, *args, **kwargs):
5 if request.user.isReadOnlyUser():
6 return HttpResponseForbidden("User is in read-only mode")
7
8 dashboards = request.POST.get("dashboards", None)
9 if not dashboards:
10 dashboards=[]
11 else:
12 dashboards = [x.strip() for x in dashboards.split(",")]
13 dashboards = [DashboardView.objects.get(name=x) for x in dashboards]
14
15 request.user.dashboardViews.all().delete()
16
17 for i,dashboard in enumerate(dashboards):
18 udbv = UserDashboardView(user=request.user, dashboardView=dashboard, order=i)
19 udbv.save()
20
Scott Baker823b7212014-06-16 10:25:39 -070021 return HttpResponse(json.dumps("Success"), content_type='application/javascript')
Scott Bakerc7325a42014-05-30 16:06:46 -070022