This change renamed a number of misnamed related fields (e.g. site_privileges->sitepr...
[plstackapi.git] / planetstack / core / dashboard / views / customize.py
1 from view_common import *
2
3 class DashboardCustomize(View):
4     def post(self, request, *args, **kwargs):\r
5         if request.user.isReadOnlyUser():\r
6             return HttpResponseForbidden("User is in read-only mode")\r
7 \r
8         dashboards = request.POST.get("dashboards", None)\r
9         if not dashboards:\r
10             dashboards=[]\r
11         else:\r
12             dashboards = [x.strip() for x in dashboards.split(",")]\r
13             dashboards = [DashboardView.objects.get(name=x) for x in dashboards]\r
14 \r
15         request.user.userdashboardviews.all().delete()\r
16 \r
17         for i,dashboard in enumerate(dashboards):\r
18             udbv = UserDashboardView(user=request.user, dashboardView=dashboard, order=i)\r
19             udbv.save()\r
20 \r
21         return HttpResponse(json.dumps("Success"), content_type='application/javascript')
22