本文整理匯總了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