Example #1
0
def view_rifcs(request, experiment_id):
    """View the rif-cs of an existing experiment.

    :param request: a HTTP Request instance
    :type request: :class:`django.http.HttpRequest`
    :param experiment_id: the ID of the experiment to be viewed
    :type experiment_id: string
    :rtype: :class:`django.http.HttpResponse`

    """
    try:
        experiment = Experiment.safe.get(request.user, experiment_id)
    except PermissionDenied:
        return return_response_error(request)
    except Experiment.DoesNotExist:
        return return_response_not_found(request)

    try:
        rifcs_provs = settings.RIFCS_PROVIDERS
    except AttributeError:
        rifcs_provs = ()

    from tardis.tardis_portal.publish.publishservice import PublishService
    pservice = PublishService(rifcs_provs, experiment)
    context = pservice.get_context()
    if context is None:
        # return error page or something
        return return_response_error(request)

    template = pservice.get_template()
    return HttpResponse(render_response_index(request,
                        template, context), content_type="text/xml")
Example #2
0
def _publish_public_expt_rifcs(experiment):
    try:
        providers = settings.RIFCS_PROVIDERS
    except:
        providers = None
    from tardis.tardis_portal.publish.publishservice import PublishService
    pservice = PublishService(providers, experiment)
    pservice.manage_rifcs(settings.OAI_DOCS_PATH)
Example #3
0
def _publish_public_expt_rifcs(experiment):
    try:
        providers = settings.RIFCS_PROVIDERS
    except:
        providers = None
    from tardis.tardis_portal.publish.publishservice import PublishService
    pservice = PublishService(providers, experiment)
    pservice.manage_rifcs(settings.OAI_DOCS_PATH)
Example #4
0
def publish_public_expt_rifcs(experiment):
    try:
        providers = settings.RIFCS_PROVIDERS
    except:
        providers = None
    from tardis.tardis_portal.publish.publishservice import PublishService
    pservice = PublishService(providers, experiment)
    try:
        pservice.manage_rifcs(settings.OAI_DOCS_PATH)
    except:
        logger.error('RIF-CS publish hook failed for experiment %d.'\
                     % experiment.id)
Example #5
0
def publish_public_expt_rifcs(experiment):
    try:
        providers = settings.RIFCS_PROVIDERS
    except:
        providers = None
    from tardis.tardis_portal.publish.publishservice import PublishService
    pservice = PublishService(providers, experiment)
    try:
        pservice.manage_rifcs(settings.OAI_DOCS_PATH)
    except:
        logger.error('RIF-CS publish hook failed for experiment %d.'\
                     % experiment.id)
Example #6
0
    def testManageRifCsCreateAndRemove(self):
        service = PublishService(self.settings, self.e1)
        self.assertFalse(service.provider.can_publish(self.e1))
        import os
        service.manage_rifcs(settings.OAI_DOCS_PATH)
        rifcs_output_dir = os.path.join(settings.OAI_DOCS_PATH)
        rifcs_file = os.path.join(rifcs_output_dir, "MyTARDIS-1.xml")
        self.assertFalse(os.path.exists(rifcs_file))

        self.e1.public_access = Experiment.PUBLIC_ACCESS_FULL
        service.manage_rifcs(settings.OAI_DOCS_PATH)
        self.assertTrue(os.path.exists(rifcs_file))

        # Set to false again and see if it deletes it
        self.e1.public_access = Experiment.PUBLIC_ACCESS_NONE
        service.manage_rifcs(settings.OAI_DOCS_PATH)
        self.assertFalse(os.path.exists(rifcs_file))
Example #7
0
    def testManageRifCsCheckContent(self):
        service = PublishService(self.settings, self.e1)
        self.e1.public_access = Experiment.PUBLIC_ACCESS_FULL
        service.manage_rifcs(settings.OAI_DOCS_PATH)
        import os
        rifcs_output_dir = os.path.join(settings.OAI_DOCS_PATH)
        rifcs_file = os.path.join(rifcs_output_dir, "MyTARDIS-1.xml")
        self.assertTrue(os.path.exists(rifcs_file))
        output = open(rifcs_file)
        lines = output.readlines()
        self.assertTrue("experiment title: Experiment 1\n" in lines)
        self.assertTrue("experiment id: 1\n" in lines)
        self.assertTrue("experiment description: This is my description.\n" in lines)
        self.assertTrue("beamline: %s\n" % BEAMLINE_VALUE in lines)
        self.assertTrue("license uri: %s\n" % LICENSE_URL_VALUE in lines)

        # Set to false again and see if it deletes it
        self.e1.public_access = Experiment.PUBLIC_ACCESS_NONE
        service.manage_rifcs(settings.OAI_DOCS_PATH)
        self.assertFalse(os.path.exists(rifcs_file))
Example #8
0
 def testContext(self):
     service = PublishService(self.settings, self.e1)
     c = service.get_context()
     self.assertEquals(c['experiment'], self.e1)
     self.assertEquals(c['beamline'], BEAMLINE_VALUE)
     self.assertEquals(c['license_url'], LICENSE_URL_VALUE)
Example #9
0
 def testInitialisationNoProvider(self):
     service = PublishService(None, self.e1)
     self.assertIsNone(service.rc_providers)
     from tardis.tardis_portal.publish.provider.rifcsprovider import RifCsProvider
     self.assertTrue(isinstance(service.provider, RifCsProvider))
     self.assertFalse(isinstance(service.provider, MockRifCsProvider))
Example #10
0
 def testInitialisation(self):
     service = PublishService(self.settings, self.e1)
     self.assertEquals(self.e1, service.experiment)
     self.assertTrue(isinstance(service.provider, MockRifCsProvider))