def _upload_manifest(request, is_standalone=False): form = forms.NewManifestForm(request.POST, is_standalone=is_standalone) if (not is_standalone and waffle.switch_is_active('webapps-unique-by-domain')): # Helpful error if user already submitted the same manifest. dup_msg = trap_duplicate(request, request.POST.get('manifest')) if dup_msg: return { 'validation': { 'errors': 1, 'success': False, 'messages': [{ 'type': 'error', 'message': dup_msg, 'tier': 1 }] } } if form.is_valid(): user = request.user if request.user.is_authenticated() else None upload = FileUpload.objects.create(user=user) fetch_manifest.delay(form.cleaned_data['manifest'], upload.pk) if is_standalone: return redirect('mkt.developers.standalone_upload_detail', 'hosted', upload.pk) else: return redirect('mkt.developers.upload_detail', upload.pk, 'json') else: error_text = _('There was an error with the submission.') if 'manifest' in form.errors: error_text = ' '.join(form.errors['manifest']) error_message = {'type': 'error', 'message': error_text, 'tier': 1} v = {'errors': 1, 'success': False, 'messages': [error_message]} return make_validation_result(dict(validation=v, error=error_text))
def _upload_manifest(request, is_standalone=False): form = forms.NewManifestForm(request.POST, is_standalone=is_standalone) if not is_standalone and waffle.switch_is_active("webapps-unique-by-domain"): # Helpful error if user already submitted the same manifest. dup_msg = trap_duplicate(request, request.POST.get("manifest")) if dup_msg: return { "validation": { "errors": 1, "success": False, "messages": [{"type": "error", "message": dup_msg, "tier": 1}], } } if form.is_valid(): upload = FileUpload.objects.create(user=request.user) fetch_manifest.delay(form.cleaned_data["manifest"], upload.pk) if is_standalone: return redirect("mkt.developers.standalone_upload_detail", "hosted", upload.pk) else: return redirect("mkt.developers.upload_detail", upload.pk, "json") else: error_text = _("There was an error with the submission.") if "manifest" in form.errors: error_text = " ".join(form.errors["manifest"]) error_message = {"type": "error", "message": error_text, "tier": 1} v = {"errors": 1, "success": False, "messages": [error_message]} return make_validation_result(dict(validation=v, error=error_text))
def _upload_manifest(request, is_standalone=False): form = forms.NewManifestForm(request.POST, is_standalone=is_standalone) if (not is_standalone and waffle.switch_is_active('webapps-unique-by-domain')): # Helpful error if user already submitted the same manifest. dup_msg = trap_duplicate(request, request.POST.get('manifest')) if dup_msg: return { 'validation': { 'errors': 1, 'success': False, 'messages': [{ 'type': 'error', 'message': dup_msg, 'tier': 1}] } } if form.is_valid(): user = request.user if request.user.is_authenticated() else None upload = FileUpload.objects.create(user=user) fetch_manifest.delay(form.cleaned_data['manifest'], upload.pk) if is_standalone: return redirect('mkt.developers.standalone_upload_detail', 'hosted', upload.pk) else: return redirect('mkt.developers.upload_detail', upload.pk, 'json') else: error_text = _('There was an error with the submission.') if 'manifest' in form.errors: error_text = ' '.join(form.errors['manifest']) error_message = {'type': 'error', 'message': error_text, 'tier': 1} v = {'errors': 1, 'success': False, 'messages': [error_message]} return make_validation_result(dict(validation=v, error=error_text))