当前位置: 首页>>代码示例>>Python>>正文


Python License.save方法代码示例

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


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

示例1: _create_test_data

# 需要导入模块: from tardis.tardis_portal.models import License [as 别名]
# 或者: from tardis.tardis_portal.models.License import save [as 别名]
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,代码行数:35,代码来源:test_oai.py

示例2: _create_test_data

# 需要导入模块: from tardis.tardis_portal.models import License [as 别名]
# 或者: from tardis.tardis_portal.models.License import save [as 别名]
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,代码行数:32,代码来源:test_oai.py

示例3: _create_license

# 需要导入模块: from tardis.tardis_portal.models import License [as 别名]
# 或者: from tardis.tardis_portal.models.License import save [as 别名]
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,代码行数:9,代码来源:test_view.py

示例4: _create_test_data

# 需要导入模块: from tardis.tardis_portal.models import License [as 别名]
# 或者: from tardis.tardis_portal.models.License import save [as 别名]
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,代码行数:60,代码来源:test_ingest.py

示例5: setUp

# 需要导入模块: from tardis.tardis_portal.models import License [as 别名]
# 或者: from tardis.tardis_portal.models.License import save [as 别名]
    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,代码行数:48,代码来源:test_oaipmh.py

示例6: setUp

# 需要导入模块: from tardis.tardis_portal.models import License [as 别名]
# 或者: from tardis.tardis_portal.models.License import save [as 别名]
    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,代码行数:47,代码来源:test_oaipmh.py

示例7: RightsFormTestCase

# 需要导入模块: from tardis.tardis_portal.models import License [as 别名]
# 或者: from tardis.tardis_portal.models.License import save [as 别名]
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,代码行数:58,代码来源:test_forms.py


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