def get_dashboard(context, location): dashboard_cls = get_current_dashboard(location, context['request'].user) resolver = resolve(context['request'].path) app_label = resolver.kwargs.get('app_label') return dashboard_cls(context, app_label=app_label)
def get_dashboard(context, location): dashboard_cls = get_current_dashboard(location) resolver = resolve(context['request'].path) app_label = resolver.kwargs.get('app_label') return dashboard_cls(context, app_label=app_label)
def clean(self): data = super(AddUserDashboardModuleForm, self).clean() if 'app_label' in data: index_dashboard_cls = get_current_dashboard('app_index' if data['app_label'] else 'index') index_dashboard = index_dashboard_cls({'request': self.request}, app_label=data['app_label']) if 'type' in data: if data['type'] == 'children': module = index_dashboard.children[data['module']] elif data['type'] == 'available_children': module = index_dashboard.available_children[data['module']]() else: raise ValidationError('error') self.module_cls = module return data
def clean(self): data = super(AddUserDashboardModuleForm, self).clean() if (not user_is_authenticated(self.request.user) or not self.request.user.is_staff): raise ValidationError("error") if "app_label" in data: index_dashboard_cls = get_current_dashboard( "app_index" if data["app_label"] else "index") index_dashboard = index_dashboard_cls({"request": self.request}, app_label=data["app_label"]) if "type" in data: if data["type"] == "children": module = index_dashboard.children[data["module"]] elif data["type"] == "available_children": module = index_dashboard.available_children[ data["module"]]() else: raise ValidationError("error") self.module_cls = module return data
def get_dashboard(context, location): dashboard_cls = get_current_dashboard(location) app_label = context['request'].resolver_match.kwargs.get('app_label') return dashboard_cls(context, app_label=app_label)
def get_dashboard(context, location): dashboard_cls = get_current_dashboard(location) dashboard = dashboard_cls(context) return dashboard