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]))
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]))
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
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