
from catalogue.utils import add_resource_from_template
from wirecloud.workspace.mashupTemplateGenerator import build_template_from_workspace
from wirecloud.markets.utils import MarketManager
from wirecloudcommons.utils.template import TemplateParser


class WirecloudCatalogueManager(MarketManager):

    def __init__(self, options):
        pass

    def publish_mashup(self, endpoint, published_workspace, user, publish_options, request=None):

        template = TemplateParser(build_template_from_workspace(publish_options, published_workspace.workspace, user))
        resource = add_resource_from_template(published_workspace.get_template_url(request), template, user)
        resource.users.add(user)


from catalogue.utils import add_resource_from_template
from wirecloud.workspace.mashupTemplateGenerator import build_template_from_workspace
from wirecloud.markets.utils import MarketManager
from wirecloudcommons.utils.template import TemplateParser


class WirecloudCatalogueManager(MarketManager):

    def __init__(self, options):
        pass

    def publish_mashup(self, endpoint, published_workspace, user, publish_options, request=None):

        template = TemplateParser(build_template_from_workspace(publish_options, published_workspace.workspace, user))
        resource = add_resource_from_template(published_workspace.get_template_url(request), template, user)
        resource.publish = True
        resource.save()

Make published mashups visibles to all users
Make published mashups visibles to all users

  
  from catalogue.utils import add_resource_from_template
  from wirecloud.workspace.mashupTemplateGenerator import build_template_from_workspace
  from wirecloud.markets.utils import MarketManager
  from wirecloudcommons.utils.template import TemplateParser
  
  
  class WirecloudCatalogueManager(MarketManager):
  
      def __init__(self, options):
          pass
  
      def publish_mashup(self, endpoint, published_workspace, user, publish_options, request=None):
  
          template = TemplateParser(build_template_from_workspace(publish_options, published_workspace.workspace, user))
          resource = add_resource_from_template(published_workspace.get_template_url(request), template, user)
+         resource.publish = True
-         resource.users.add(user)
+         resource.save()
  
Make published mashups visibles to all users
## Code Before:

from catalogue.utils import add_resource_from_template
from wirecloud.workspace.mashupTemplateGenerator import build_template_from_workspace
from wirecloud.markets.utils import MarketManager
from wirecloudcommons.utils.template import TemplateParser


class WirecloudCatalogueManager(MarketManager):

    def __init__(self, options):
        pass

    def publish_mashup(self, endpoint, published_workspace, user, publish_options, request=None):

        template = TemplateParser(build_template_from_workspace(publish_options, published_workspace.workspace, user))
        resource = add_resource_from_template(published_workspace.get_template_url(request), template, user)
        resource.users.add(user)

## Instruction:
Make published mashups visibles to all users
## Code After:

from catalogue.utils import add_resource_from_template
from wirecloud.workspace.mashupTemplateGenerator import build_template_from_workspace
from wirecloud.markets.utils import MarketManager
from wirecloudcommons.utils.template import TemplateParser


class WirecloudCatalogueManager(MarketManager):

    def __init__(self, options):
        pass

    def publish_mashup(self, endpoint, published_workspace, user, publish_options, request=None):

        template = TemplateParser(build_template_from_workspace(publish_options, published_workspace.workspace, user))
        resource = add_resource_from_template(published_workspace.get_template_url(request), template, user)
        resource.publish = True
        resource.save()
