def get_context_data(self, **kwargs): context = super(BaseManagerView, self).get_context_data(**kwargs) context[ "system_settings_graphid"] = settings.SYSTEM_SETTINGS_RESOURCE_MODEL_ID context["graph_models"] = [] context["graphs"] = "[]" context["plugins"] = [] for plugin in models.Plugin.objects.all().order_by("sortorder"): if self.request.user.has_perm("view_plugin", plugin): context["plugins"].append(plugin) createable = get_createable_resource_types(self.request.user) createable.sort(key=lambda x: x.name.lower()) context["createable_resources"] = JSONSerializer().serialize( createable, exclude=[ "functions", "ontology", "isactive", "isresource", "version", "deploymentdate", "deploymentfile", "author", ], ) context["notifications"] = models.UserXNotification.objects.filter( recipient=self.request.user, isread=False) context["nav"] = { "icon": "fa fa-chevron-circle-right", "title": "", "help": { # title:'',template:'' (leave this commented out) }, "menu": False, "search": True, "notifs": True, "res_edit": False, "login": True, "print": False, } context["user_is_reviewer"] = user_is_resource_reviewer( self.request.user) context["user_can_edit"] = len( get_editable_resource_types(self.request.user)) > 0 context["user_can_read"] = (len( get_resource_types_by_perm(self.request.user, [ "models.write_nodegroup", "models.delete_nodegroup", "models.read_nodegroup" ])) > 0) context["app_name"] = settings.APP_NAME context["show_language_swtich"] = settings.SHOW_LANGUAGE_SWITCH return context
def test(u): if u.is_authenticated(): return u.is_superuser or len(get_resource_types_by_perm(u, ['models.read_nodegroup'])) > 0 return False
def can_read_resource_instance(user): return len( get_resource_types_by_perm(user, [ 'models.write_nodegroup', 'models.delete_nodegroup', 'models.read_nodegroup' ])) > 0
def can_create_graph(user): return len( get_resource_types_by_perm( user, ["models.write_nodegroup", "models.delete_nodegroup"])) > 0