Scott Baker | c7325a4 | 2014-05-30 16:06:46 -0700 | [diff] [blame] | 1 | from view_common import * |
| 2 | |
| 3 | class 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 | |