'Generate a dict that can be serialized to a GXP layer configuration
suitable for loading this layer.
The "source" property will be left unset; the layer is not aware of the
name assigned to its source plugin.  See
geonode.maps.models.Map.viewer_json for an example of
generating a full map configuration.'

def layer_config(self, user=None):

    try:
        cfg = json.loads(self.layer_params)
    except Exception:
        cfg = dict()
    if self.format:
        cfg['format'] = self.format
    if self.name:
        cfg['name'] = self.name
    if self.opacity:
        cfg['opacity'] = self.opacity
    if self.styles:
        cfg['styles'] = self.styles
    if self.transparent:
        cfg['transparent'] = True
    cfg['fixed'] = self.fixed
    if self.group:
        cfg['group'] = self.group
    cfg['visibility'] = self.visibility
    return cfg
