def add_permission_by_name(self, code, save=False):
        """
        Adds a permission with given name.

        Args:
            code (str): Code name of the permission.
            save (bool): If False, does nothing.
        """
        if not save:
            return ["%s | %s" % (p.name, p.code) for p in
                    Permission.objects.filter(code__contains=code)]
        for p in Permission.objects.filter(code__contains=code):
            if p not in self.Permissions:
                self.Permissions(permission=p)
        if p:
            self.save()
def add_permission_by_name ( self , code , save = False ) : if not save : return [ "%s | %s" % ( p . name , p . code ) for p in Permission . objects . filter ( code__contains = code ) ] for p in Permission . objects . filter ( code__contains = code ) : if p not in self . Permissions : self . Permissions ( permission = p ) if p : self . save ( )
Adds a permission with given name.

        Args:
            code (str): Code name of the permission.
            save (bool): If False, does nothing.