• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.License类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tardis.tardis_portal.models.License的典型用法代码示例。如果您正苦于以下问题:Python License类的具体用法?Python License怎么用?Python License使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了License类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _create_test_data

def _create_test_data():
    user = User(username='tom',
                first_name='Thomas',
                last_name='Atkins',
                email='[email protected]')
    user.save()
    license_ = License(name='Creative Commons Attribution-NoDerivs 2.5 Australia',
                       url='http://creativecommons.org/licenses/by-nd/2.5/au/',
                       internal_description='CC BY 2.5 AU',
                       allows_distribution=True)
    license_.save()
    experiment = Experiment(title='Norwegian Blue',
                            description='Parrot + 40kV',
                            created_by=user)
    experiment.public_access = Experiment.PUBLIC_ACCESS_FULL
    experiment.license = license_
    experiment.save()
    experiment.experimentauthor_set.create(order=0,
                                           author="John Cleese",
                                           url="http://nla.gov.au/nla.party-1")
    experiment.experimentauthor_set.create(order=1,
                                           author="Michael Palin",
                                           url="http://nla.gov.au/nla.party-2")
    acl = ObjectACL(content_object=experiment,
                    pluginId='django_user',
                    entityId=str(user.id),
                    isOwner=True,
                    canRead=True,
                    canWrite=True,
                    canDelete=True,
                    aclOwnershipType=ObjectACL.OWNER_OWNED)
    acl.save()
    return user, experiment
开发者ID:mytardis,项目名称:mytardis,代码行数:33,代码来源:test_oai.py


示例2: testListRecords

 def testListRecords(self):
     results = self._getProvider().listRecords('rif')
     # Iterate through headers
     for header, metadata, _ in results:
         if header.identifier().startswith('experiment'):
             expect(header.identifier()).to_contain(str(self._experiment.id))
             expect(header.datestamp().replace(tzinfo=pytz.utc))\
                 .to_equal(get_local_time(self._experiment.update_time))
             expect(metadata.getField('title'))\
                 .to_equal(str(self._experiment.title))
             expect(metadata.getField('description'))\
                 .to_equal(str(self._experiment.description))
             expect(metadata.getField('licence_uri'))\
                 .to_equal(License.get_none_option_license().url)
             expect(metadata.getField('licence_name'))\
                 .to_equal(License.get_none_option_license().name)
         else:
             expect(header.identifier()).to_contain(str(self._user.id))
             expect(header.datestamp().replace(tzinfo=pytz.utc))\
                 .to_equal(get_local_time(self._user.last_login))
             expect(metadata.getField('id')).to_equal(self._user.id)
             expect(metadata.getField('email'))\
                 .to_equal(str(self._user.email))
             expect(metadata.getField('given_name'))\
                 .to_equal(str(self._user.first_name))
             expect(metadata.getField('family_name'))\
                 .to_equal(str(self._user.last_name))
     # There should only have been one
     expect(len(results)).to_equal(2)
     # Remove public flag
     self._experiment.public_access = Experiment.PUBLIC_ACCESS_NONE
     self._experiment.save()
     headers = self._getProvider().listRecords('rif')
     # Not public, so should not appear
     expect(len(headers)).to_equal(0)
开发者ID:conkiztador,项目名称:mytardis,代码行数:35,代码来源:test_experiment.py


示例3: _create_license

def _create_license():
    license_ = License(name='Creative Commons Attribution-NoDerivs 2.5 Australia',
                       url='http://creativecommons.org/licenses/by-nd/2.5/au/',
                       internal_description='CC BY 2.5 AU',
                       allows_distribution=True)
    license_.save()
    return license_
开发者ID:bioscience-data-platform,项目名称:mytardis-app-hrmcoutput,代码行数:7,代码来源:test_view.py


示例4: retrieve_licenses

def retrieve_licenses(request):
    try:
        type_ = int(request.REQUEST['public_access'])
        licenses = License.get_suitable_licenses(type_)
    except KeyError:
        licenses = License.get_suitable_licenses()
    return HttpResponse(json.dumps([model_to_dict(x) for x in licenses]))
开发者ID:keithschulze,项目名称:mytardis,代码行数:7,代码来源:ajax_json.py


示例5: testGetRecord

 def testGetRecord(self):
     header, metadata, about = self._getProvider().getRecord('rif',
                                                  _get_first_exp_id())
     self.assertIn(str(self._experiment.id), header.identifier())
     self.assertEqual(
         header.datestamp().replace(tzinfo=pytz.utc),
         get_local_time(self._experiment.update_time))
     ns = 'http://ands.org.au/standards/rif-cs/registryObjects#relatedInfo'
     ps_id = ExperimentParameterSet.objects\
             .filter(experiment=self._experiment,schema__namespace=ns).first().id
     self.assertEqual(
         metadata.getField('id'), self._experiment.id)
     self.assertEqual(
         metadata.getField('title'), str(self._experiment.title))
     self.assertEqual(
         metadata.getField('description'),
         str(self._experiment.description))
     self.assertEqual(
         metadata.getField('licence_uri'),
         License.get_none_option_license().url)
     self.assertEqual(
         metadata.getField('licence_name'),
         License.get_none_option_license().name)
     self.assertEqual(
         metadata.getField('related_info'),
         [{'notes': 'This is a note.', \
                    'identifier': 'https://www.example.com/', \
                    'type': 'website', \
                    'id': ps_id, \
                    'title': 'Google'}])
     self.assertEqual(
         len(metadata.getField('collectors')), 2)
     self.assertIsNone(about)
开发者ID:mytardis,项目名称:mytardis,代码行数:33,代码来源:test_experiment.py


示例6: _create_test_data

def _create_test_data():
    user = User(username='tom',
                first_name='Thomas',
                last_name='Atkins',
                email='[email protected]')
    user.save()
    user2 = User(username='otheradmin', email='[email protected]')
    user2.save()
    map(lambda u: UserProfile(user=u).save(), [user, user2])
    license_ = License(name='Creative Commons Attribution-NoDerivs 2.5 Australia',
                       url='http://creativecommons.org/licenses/by-nd/2.5/au/',
                       internal_description='CC BY 2.5 AU',
                       allows_distribution=True)
    license_.save()
    experiment = Experiment(title='Norwegian Blue',
                            description='Parrot + 40kV',
                            created_by=user)
    experiment.public_access = Experiment.PUBLIC_ACCESS_FULL
    experiment.license = license_
    experiment.save()
    acl = ExperimentACL(experiment=experiment,
                    pluginId='django_user',
                    entityId=str(user2.id),
                    isOwner=True,
                    canRead=True,
                    canWrite=True,
                    canDelete=True,
                    aclOwnershipType=ExperimentACL.OWNER_OWNED)
    acl.save()
    return (user, experiment)
开发者ID:conkiztador,项目名称:mytardis,代码行数:30,代码来源:test_oai.py


示例7: _create_test_data

def _create_test_data():
    """
    Create Single experiment with two owners
    """
    user1 = User(username='tom',
                first_name='Thomas',
                last_name='Atkins',
                email='[email protected]')
    user1.save()
    UserProfile(user=user1).save()

    user2 = User(username='joe',
                first_name='Joe',
                last_name='Bloggs',
                email='[email protected]')
    user2.save()
    UserProfile(user=user2).save()

    license_ = License(name='Creative Commons Attribution-NoDerivs '
                            + '2.5 Australia',
                       url='http://creativecommons.org/licenses/by-nd/2.5/au/',
                       internal_description='CC BY 2.5 AU',
                       allows_distribution=True)
    license_.save()
    experiment = Experiment(title='Norwegian Blue',
                            description='Parrot + 40kV',
                            created_by=user1)
    experiment.public_access = Experiment.PUBLIC_ACCESS_FULL
    experiment.license = license_
    experiment.save()
    experiment.author_experiment_set.create(order=0,
                                        author="John Cleese",
                                        url="http://nla.gov.au/nla.party-1")
    experiment.author_experiment_set.create(order=1,
                                        author="Michael Palin",
                                        url="http://nla.gov.au/nla.party-2")

    acl1 = ExperimentACL(experiment=experiment,
                    pluginId='django_user',
                    entityId=str(user1.id),
                    isOwner=True,
                    canRead=True,
                    canWrite=True,
                    canDelete=True,
                    aclOwnershipType=ExperimentACL.OWNER_OWNED)
    acl1.save()

    acl2 = ExperimentACL(experiment=experiment,
                    pluginId='django_user',
                    entityId=str(user2.id),
                    isOwner=True,
                    canRead=True,
                    canWrite=True,
                    canDelete=True,
                    aclOwnershipType=ExperimentACL.OWNER_OWNED)
    acl2.save()

    return (user1, user2, experiment)
开发者ID:ianedwardthomas,项目名称:mytardis-app-repos-consumer,代码行数:58,代码来源:test_ingest.py


示例8: testListRecords

 def testListRecords(self):
     results = self._getProvider().listRecords('rif')
     # Iterate through headers
     for header, metadata, _ in results:
         if header.identifier().startswith('experiment'):
             e = self._experiment if header.identifier() == _get_first_exp_id() \
                 else self._experiment2
             self.assertIn(str(e.id), header.identifier())
             self.assertEqual(
                 header.datestamp().replace(tzinfo=pytz.utc),
                 get_local_time(e.update_time))
             self.assertEqual(
                 metadata.getField('title'), str(e.title))
             self.assertEqual(
                 metadata.getField('description'), str(e.description))
             self.assertEqual(
                 metadata.getField('licence_uri'),
                 License.get_none_option_license().url)
             self.assertEqual(
                 metadata.getField('licence_name'),
                 License.get_none_option_license().name)
             if e == self._experiment:
                 ns = 'http://ands.org.au/standards/rif-cs/registryObjects#relatedInfo'
                 ps_id = ExperimentParameterSet.objects\
                   .filter(experiment=self._experiment,schema__namespace=ns).first().id
                 self.assertEqual(
                     metadata.getField('related_info'),
                     [{'notes': 'This is a note.', \
                                'identifier': 'https://www.example.com/', \
                                'type': 'website', \
                                'id': ps_id, \
                                'title': 'Google'}])
             else:
                 self.assertEqual(
                     metadata.getField('related_info'), [{}])
         else:
             self.assertIn(str(self._user.id), header.identifier())
             self.assertEqual(
                 header.datestamp().replace(tzinfo=pytz.utc),
                 get_local_time(self._user.last_login))
             self.assertEqual(metadata.getField('id'), self._user.id)
             self.assertEqual(
                 metadata.getField('email'), str(self._user.email))
             self.assertEqual(
                 metadata.getField('given_name'),
                 str(self._user.first_name))
             self.assertEqual(
                 metadata.getField('family_name'),
                 str(self._user.last_name))
     # There should have been two
     self.assertEqual(len(results), 2)
     # Remove public flag on first experiment
     self._experiment.public_access = Experiment.PUBLIC_ACCESS_NONE
     self._experiment.save()
     headers = self._getProvider().listRecords('rif')
     # Should now be one
     self.assertEqual(len(headers), 1)
开发者ID:mytardis,项目名称:mytardis,代码行数:57,代码来源:test_experiment.py


示例9: _get_experiment_metadata

    def _get_experiment_metadata(self, experiment, metadataPrefix):
        license_ = experiment.license or License.get_none_option_license()
        # Access Rights statement
        if experiment.public_access == Experiment.PUBLIC_ACCESS_METADATA:
            access = "Only metadata is publicly available online."+\
                    " Requests for further access should be directed to a"+\
                    " listed data manager."
        else:
            access = "All data is publicly available online."

        def get_related_info(ps):
            psm = ParameterSetManager(ps)
            parameter_names = ['type','identifier','title','notes']
            return dict([('id', ps.id)]+ # Use set ID
                    zip(parameter_names,
                        (psm.get_param(k, True) for k in parameter_names)))
        ns = 'http://ands.org.au/standards/rif-cs/registryObjects#relatedInfo'
        related_info = map(get_related_info, ExperimentParameterSet.objects\
                                                .filter(experiment=experiment,
                                                        schema__namespace=ns))
        return Metadata({
            '_writeMetadata': self._get_experiment_writer_func(),
            'id': experiment.id,
            'title': experiment.title,
            'description': experiment.description,
            # Note: Property names are US-spelling, but RIF-CS is Australian
            'licence_name': license_.name,
            'licence_uri': license_.url,
            'access': access,
            'collectors': [experiment.created_by],
            'managers': experiment.get_owners(),
            'related_info': related_info
        })
开发者ID:conkiztador,项目名称:mytardis,代码行数:33,代码来源:experiment.py


示例10: testListRecords

 def testListRecords(self):
     results = self._getProvider().listRecords('rif')
     # Iterate through headers
     for header, metadata, _ in results:
         if header.identifier().startswith('experiment'):
             e = self._experiment if header.identifier() == 'experiment/1' \
                 else self._experiment2
             expect(header.identifier()).to_contain(str(e.id))
             expect(header.datestamp().replace(tzinfo=pytz.utc))\
                 .to_equal(get_local_time(e.update_time))
             expect(metadata.getField('title'))\
                 .to_equal(str(e.title))
             expect(metadata.getField('description'))\
                 .to_equal(str(e.description))
             expect(metadata.getField('licence_uri'))\
                 .to_equal(License.get_none_option_license().url)
             expect(metadata.getField('licence_name'))\
                 .to_equal(License.get_none_option_license().name)
             if e == self._experiment:
                 expect(metadata.getField('related_info'))\
                     .to_equal([{'notes': 'This is a note.', \
                                     'identifier': 'https://www.example.com/', \
                                     'type': 'website', \
                                     'id': 1, \
                                     'title': 'Google'}])
             else:
                 expect(metadata.getField('related_info')).to_equal([{}])
         else:
             expect(header.identifier()).to_contain(str(self._user.id))
             expect(header.datestamp().replace(tzinfo=pytz.utc))\
                 .to_equal(get_local_time(self._user.last_login))
             expect(metadata.getField('id')).to_equal(self._user.id)
             expect(metadata.getField('email'))\
                 .to_equal(str(self._user.email))
             expect(metadata.getField('given_name'))\
                 .to_equal(str(self._user.first_name))
             expect(metadata.getField('family_name'))\
                 .to_equal(str(self._user.last_name))
     # There should have been two
     expect(len(results)).to_equal(2)
     # Remove public flag on first experiment
     self._experiment.public_access = Experiment.PUBLIC_ACCESS_NONE
     self._experiment.save()
     headers = self._getProvider().listRecords('rif')
     # Should now be one
     expect(len(headers)).to_equal(1)
开发者ID:jasonrig,项目名称:mytardis,代码行数:46,代码来源:test_experiment.py


示例11: setUp

    def setUp(self):
        self.ns = {'r': 'http://ands.org.au/standards/rif-cs/registryObjects',
                   'o': 'http://www.openarchives.org/OAI/2.0/'}
        user, client = _create_user_and_login()

        license_ = License(name='Creative Commons Attribution-NoDerivs 2.5 Australia',
                           url='http://creativecommons.org/licenses/by-nd/2.5/au/',
                           internal_description='CC BY 2.5 AU',
                           allows_distribution=True)
        license_.save()
        experiment = Experiment(title='Norwegian Blue',
                                description='Parrot + 40kV',
                                created_by=user)
        experiment.public_access = Experiment.PUBLIC_ACCESS_FULL
        experiment.license = license_
        experiment.save()
        acl = ObjectACL(content_object=experiment,
                        pluginId='django_user',
                        entityId=str(user.id),
                        isOwner=False,
                        canRead=True,
                        canWrite=True,
                        canDelete=False,
                        aclOwnershipType=ObjectACL.OWNER_OWNED)
        acl.save()

        params = {'code': '010107',
                  'name': 'Mathematical Logic, Set Theory, Lattices and Universal Algebra',
                  'uri': 'http://purl.org/asc/1297.0/2008/for/010107'}
        try:
            response = client.post(\
                        reverse('tardis.apps.anzsrc_codes.views.'\
                                +'list_or_create_for_code',
                                args=[experiment.id]),
                        data=json.dumps(params),
                        content_type='application/json')
        except:  # no internet most likely
            from nose.plugins.skip import SkipTest
            raise SkipTest
        # Check related info was created
        expect(response.status_code).to_equal(201)

        self.acl = acl
        self.client = client
        self.experiment = experiment
        self.params = params
开发者ID:IntersectAustralia,项目名称:mytardis,代码行数:46,代码来源:test_oaipmh.py


示例12: setUp

 def setUp(self):
     self.restrictiveLicense = License(name="Restrictive License",
                                       url="http://example.test/rl",
                                       internal_description="Description...",
                                       allows_distribution=False)
     self.restrictiveLicense.save()
     self.permissiveLicense  = License(name="Permissive License",
                                       url="http://example.test/pl",
                                       internal_description="Description...",
                                       allows_distribution=True)
     self.permissiveLicense.save()
     self.inactiveLicense  = License(name="Inactive License",
                                       url="http://example.test/ial",
                                       internal_description="Description...",
                                       allows_distribution=True,
                                       is_active=False)
     self.inactiveLicense.save()
开发者ID:conkiztador,项目名称:mytardis,代码行数:17,代码来源:test_forms.py


示例13: setUp

    def setUp(self):
        self.ns = {'r': 'http://ands.org.au/standards/rif-cs/registryObjects',
                   'o': 'http://www.openarchives.org/OAI/2.0/'}
        user, client = _create_user_and_login()

        license_ = License(name='Creative Commons Attribution-NoDerivs '
                                '2.5 Australia',
                           url='http://creativecommons.org/licenses/by-nd/'
                               '2.5/au/',
                           internal_description='CC BY 2.5 AU',
                           allows_distribution=True)
        license_.save()
        experiment = Experiment(title='Norwegian Blue',
                                description='Parrot + 40kV',
                                created_by=user)
        experiment.public_access = Experiment.PUBLIC_ACCESS_FULL
        experiment.license = license_
        experiment.save()
        acl = ObjectACL(content_object=experiment,
                        pluginId='django_user',
                        entityId=str(user.id),
                        isOwner=False,
                        canRead=True,
                        canWrite=True,
                        canDelete=False,
                        aclOwnershipType=ObjectACL.OWNER_OWNED)
        acl.save()

        params = {'type': 'website',
                  'identifier': 'https://www.google.com/',
                  'title': 'Google',
                  'notes': 'This is a note.'}
        response = client.post(\
                    reverse('tardis.apps.related_info.views.' +
                            'list_or_create_related_info',
                            args=[experiment.id]),
                    data=json.dumps(params),
                    content_type='application/json')
        # Check related info was created
        self.assertEqual(response.status_code, 201)

        self.acl = acl
        self.client = client
        self.experiment = experiment
        self.params = params
开发者ID:mytardis,项目名称:mytardis,代码行数:45,代码来源:test_oaipmh.py


示例14: testGetRecord

 def testGetRecord(self):
     header, metadata, about = self._getProvider().getRecord('rif',
                                                             'experiment/1')
     expect(header.identifier()).to_contain(str(self._experiment.id))
     expect(header.datestamp().replace(tzinfo=pytz.utc))\
         .to_equal(get_local_time(self._experiment.update_time))
     expect(metadata.getField('id')).to_equal(self._experiment.id)
     expect(metadata.getField('title'))\
         .to_equal(str(self._experiment.title))
     expect(metadata.getField('description'))\
         .to_equal(str(self._experiment.description))
     expect(metadata.getField('licence_uri'))\
         .to_equal(License.get_none_option_license().url)
     expect(metadata.getField('licence_name'))\
         .to_equal(License.get_none_option_license().name)
     expect(metadata.getField('related_info'))\
         .to_equal([])
     expect(about).to_equal(None)
开发者ID:conkiztador,项目名称:mytardis,代码行数:18,代码来源:test_experiment.py


示例15: _get_experiment_metadata

    def _get_experiment_metadata(self, experiment, metadataPrefix):
        license_ = experiment.license or License.get_none_option_license()
        # Access Rights statement
        access_type = None
        if experiment.public_access == Experiment.PUBLIC_ACCESS_METADATA:
            access = "Only metadata is publicly available online." + \
                    " Requests for further access should be directed to a" + \
                    " listed data manager."
            access_type = "restricted"
        else:
            access = "All data is publicly available online."
            access_type = "open"

        def get_related_info(ps):
            psm = ParameterSetManager(ps)
            parameter_names = ['type', 'identifier', 'title', 'notes']
            try:
                return dict([('id', ps.id)] +  # Use set ID
                            zip(parameter_names,
                                (psm.get_param(k, True) \
                                 for k in parameter_names)))
            except ExperimentParameter.DoesNotExist:
                return dict()  # drop Related_Info record with missing fields

        ns = 'http://ands.org.au/standards/rif-cs/registryObjects#relatedInfo'
        related_info = map(
            get_related_info,
            ExperimentParameterSet.objects.filter(experiment=experiment,
                                                  schema__namespace=ns))

        def get_subject(ps, type_):
            psm = ParameterSetManager(ps)
            return {'text': psm.get_param('code', True),
                    'type': type_}

        ns = 'http://purl.org/asc/1297.0/2008/for/'
        subjects = [get_subject(ps, 'anzsrc-for')
                    for ps in ExperimentParameterSet.objects.filter(
                        experiment=experiment, schema__namespace=ns)]
        collectors = experiment.experimentauthor_set.exclude(url='')
        return Metadata(
            experiment,
            {
                '_writeMetadata': self._get_experiment_writer_func(),
                'id': experiment.id,
                'title': experiment.title,
                'description': experiment.description,
                # Note: Property names are US-spelling, but RIF-CS is Australian
                'licence_name': license_.name,
                'licence_uri': license_.url,
                'access': access,
                'access_type': access_type,
                'collectors': collectors,
                'managers': experiment.get_owners(),
                'related_info': related_info,
                'subjects': subjects
            })
开发者ID:mytardis,项目名称:mytardis,代码行数:57,代码来源:experiment.py


示例16: _get_experiment_metadata

    def _get_experiment_metadata(self, experiment, metadataPrefix):
        license_ = experiment.license or License.get_none_option_license()
        # Access Rights statement
        if experiment.public_access == Experiment.PUBLIC_ACCESS_METADATA:
            access = (
                "Only metadata is publicly available online."
                + " Requests for further access should be directed to a"
                + " listed data manager."
            )
        else:
            access = "All data is publicly available online."

        def get_related_info(ps):
            psm = ParameterSetManager(ps)
            parameter_names = ["type", "identifier", "title", "notes"]
            try:
                return dict(
                    [("id", ps.id)]
                    + zip(parameter_names, (psm.get_param(k, True) for k in parameter_names))  # Use set ID
                )
            except ExperimentParameter.DoesNotExist:
                return dict()  # drop Related_Info record with missing fields

        ns = "http://ands.org.au/standards/rif-cs/registryObjects#relatedInfo"
        related_info = map(
            get_related_info, ExperimentParameterSet.objects.filter(experiment=experiment, schema__namespace=ns)
        )

        def get_subject(ps, type_):
            psm = ParameterSetManager(ps)
            return {"text": psm.get_param("code", True), "type": type_}

        ns = "http://purl.org/asc/1297.0/2008/for/"
        subjects = [
            get_subject(ps, "anzsrc-for")
            for ps in ExperimentParameterSet.objects.filter(experiment=experiment, schema__namespace=ns)
        ]
        collectors = experiment.author_experiment_set.exclude(url="")
        return Metadata(
            {
                "_writeMetadata": self._get_experiment_writer_func(),
                "id": experiment.id,
                "title": experiment.title,
                "description": experiment.description,
                # Note: Property names are US-spelling, but RIF-CS is Australian
                "licence_name": license_.name,
                "licence_uri": license_.url,
                "access": access,
                "collectors": collectors,
                "managers": experiment.get_owners(),
                "related_info": related_info,
                "subjects": subjects,
            }
        )
开发者ID:JMSS-IT-11-2012,项目名称:mytardis,代码行数:54,代码来源:experiment.py


示例17: clean

    def clean(self):
        cleaned_data = super(RightsForm, self).clean()
        public_access = cleaned_data.get("public_access")
        license_ = cleaned_data.get("license")

        if license_ is None:
            # Only data which is not distributed can have no explicit licence
            suitable = not Experiment.public_access_implies_distribution(public_access)
        else:
            suitable = license_ in License.get_suitable_licenses(public_access)

        if not suitable:
            raise forms.ValidationError("Selected license it not suitable " + "for public access level.")

        return cleaned_data
开发者ID:JMSS-IT-11-2012,项目名称:mytardis,代码行数:15,代码来源:forms.py


示例18: testGetRecord

 def testGetRecord(self):
     header, metadata, about = self._getProvider().getRecord('rif',
                                                             'experiment/1')
     expect(header.identifier()).to_contain(str(self._experiment.id))
     expect(header.datestamp().replace(tzinfo=pytz.utc))\
         .to_equal(get_local_time(self._experiment.update_time))
     expect(metadata.getField('id')).to_equal(self._experiment.id)
     expect(metadata.getField('title'))\
         .to_equal(str(self._experiment.title))
     expect(metadata.getField('description'))\
         .to_equal(str(self._experiment.description))
     expect(metadata.getField('licence_uri'))\
         .to_equal(License.get_none_option_license().url)
     expect(metadata.getField('licence_name'))\
         .to_equal(License.get_none_option_license().name)
     expect(metadata.getField('related_info'))\
         .to_equal([{'notes': 'This is a note.', \
                     'identifier': 'https://www.example.com/', \
                     'type': 'website', \
                     'id': 1, \
                     'title': 'Google'}])
     expect(len(metadata.getField('collectors')))\
         .to_equal(2)
     expect(about).to_equal(None)
开发者ID:jasonrig,项目名称:mytardis,代码行数:24,代码来源:test_experiment.py


示例19: RightsFormTestCase

class RightsFormTestCase(TestCase):

    def setUp(self):
        self.restrictiveLicense = License(name="Restrictive License",
                                          url="http://example.test/rl",
                                          internal_description="Description...",
                                          allows_distribution=False)
        self.restrictiveLicense.save()
        self.permissiveLicense  = License(name="Permissive License",
                                          url="http://example.test/pl",
                                          internal_description="Description...",
                                          allows_distribution=True)
        self.permissiveLicense.save()
        self.inactiveLicense  = License(name="Inactive License",
                                          url="http://example.test/ial",
                                          internal_description="Description...",
                                          allows_distribution=True,
                                          is_active=False)
        self.inactiveLicense.save()

    def test_ensures_suitable_license(self):
        suitableCombinations = (
            (Experiment.PUBLIC_ACCESS_NONE, ''),
            (Experiment.PUBLIC_ACCESS_METADATA, ''),
            (Experiment.PUBLIC_ACCESS_NONE, self.restrictiveLicense.id),
            (Experiment.PUBLIC_ACCESS_METADATA, self.restrictiveLicense.id),
            (Experiment.PUBLIC_ACCESS_FULL, self.permissiveLicense.id),
        )
        unsuitableCombinations = (
            (Experiment.PUBLIC_ACCESS_NONE, self.permissiveLicense.id),
            (Experiment.PUBLIC_ACCESS_METADATA, self.permissiveLicense.id),
            (Experiment.PUBLIC_ACCESS_METADATA, self.inactiveLicense.id),
            (Experiment.PUBLIC_ACCESS_FULL, self.inactiveLicense.id),
            (Experiment.PUBLIC_ACCESS_FULL, ''),
            (Experiment.PUBLIC_ACCESS_FULL, self.restrictiveLicense.id),
        )

        # Check we accept valid input
        for public_access, license_id in suitableCombinations:
            print "Suitable combination: %d %s" % (public_access, license_id)
            data = {'public_access': str(public_access),
                    'license': license_id }
            form = RightsForm(data)
            ensure(form.is_valid(), True, form.errors);

        # Check we reject invalid input
        for public_access, license_id in unsuitableCombinations:
            print "Unsuitable combination: %d %s" % (public_access, license_id)
            data = {'public_access': str(public_access),
                    'license': license_id }
            form = RightsForm(data)
            ensure(form.is_valid(), False);

    def test_needs_confirmation(self):
        suitable_data = {'public_access': str(Experiment.PUBLIC_ACCESS_NONE),
                         'license': ''}
开发者ID:conkiztador,项目名称:mytardis,代码行数:56,代码来源:test_forms.py


示例20: process_form


#.........这里部分代码省略.........
        # --- Get data for the next page --- #
        # Construct the disclipline-specific form based on the
        # selected datasets
        selected_forms = select_forms(datasets)
        if 'disciplineSpecificFormTemplates' in form_state:
            # clear extraInfo if the selected forms differ
            # (i.e. datasets have changed)
            if json.dumps(selected_forms) != json.dumps(
                    form_state['disciplineSpecificFormTemplates']):
                form_state['extraInfo'] = {}
        form_state['disciplineSpecificFormTemplates'] = selected_forms

    elif form_state['action'] == 'update-extra-info':
        # Clear any current parameter sets except for those belonging
        # to the publication draft schema or containing the form_state
        # parameter
        clear_publication_metadata(publication)

        # Loop through form data and create associates parameter sets
        # Any unrecognised fields or schemas are ignored!
        map_form_to_schemas(form_state['extraInfo'], publication)

        # *** Synchrotron specific ***
        # Search for beamline/EPN information associated with each dataset
        # and add to the publication.
        synchrotron_search_epn(publication)

        # --- Get data for the next page --- #
        licenses_json = get_licenses()
        form_state['licenses'] = licenses_json

        # Select the first license as default
        if licenses_json:
            if 'selectedLicenseId' not in form_state:
                form_state['selectedLicenseId'] = licenses_json[0]['id']
        else:  # No licenses configured...
            form_state['selectedLicenseId'] = -1

        # Set a default author (current user) if no previously saved data
        # By default, the form sends a list of authors of one element
        # with blank fields
        if len(form_state['authors']) == 1 and \
                not form_state['authors'][0]['name']:
            form_state['authors'] = [
                {'name': ' '.join([request.user.first_name,
                                   request.user.last_name]),
                 'institution': getattr(settings, 'DEFAULT_INSTITUTION', ''),
                 'email': request.user.email}]

    elif form_state['action'] == 'submit':
        # any final form validation should occur here
        # and specific error messages can be returned
        # to the browser before the publication's draft
        # status is removed.

        if 'acknowledge' not in form_state or not form_state['acknowledge']:
            return validation_error('You must confirm that you are '
                                    'authorised to submit this publication')

        set_publication_authors(form_state['authors'], publication)

        institutions = '; '.join(
            set([author['institution'] for author in form_state['authors']]))
        publication.institution_name = institutions

        # Attach the publication details schema
开发者ID:keithschulze,项目名称:mytardis,代码行数:67,代码来源:views.py



注:本文中的tardis.tardis_portal.models.License类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Location类代码示例发布时间:2022-05-27
下一篇:
Python models.ExperimentParameterSet类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap