本文整理汇总了Python中tardis.tardis_portal.models.License.get_suitable_licenses方法的典型用法代码示例。如果您正苦于以下问题:Python License.get_suitable_licenses方法的具体用法?Python License.get_suitable_licenses怎么用?Python License.get_suitable_licenses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tardis.tardis_portal.models.License
的用法示例。
在下文中一共展示了License.get_suitable_licenses方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: retrieve_licenses
# 需要导入模块: from tardis.tardis_portal.models import License [as 别名]
# 或者: from tardis.tardis_portal.models.License import get_suitable_licenses [as 别名]
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]))
示例2: clean
# 需要导入模块: from tardis.tardis_portal.models import License [as 别名]
# 或者: from tardis.tardis_portal.models.License import get_suitable_licenses [as 别名]
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