blob: f081cfb6c1d49f331f32e489fb94fd1f84f2fb36 [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
21 return HttpResponse(json.dumps("Success"), mimetype='application/javascript')
22