blob: 2c399eb4b6e72e99fec2073428b21733fe5bddb0 [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
Sapan Bhatia6bfa2ca2014-11-11 21:47:45 -050015 request.user.userdashboardviews.all().delete()
Scott Bakerc7325a42014-05-30 16:06:46 -070016
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