def form_valid(self, form): package = InternalPackage.objects.get(id=self.kwargs['package_id']) form.instance.package = package assert form.instance.package.owner.user == self.request.user form.instance.added_by = get_workbench_user(self.request.user) response = super(InternalPackageVersionCreateView, self).form_valid(form) create_tag_for_package_version(form.instance.id) if 'Python' in package.language.language: update_setup_py_with_new_version(form.instance.id) task_publish_update_package.delay(package.pk) return response
def get(self, request, *args, **kwargs): package_id = self.kwargs['package_id'] package = Package.objects.get(id=package_id) workbench_user = get_workbench_user(request.user) if not workbench_user in package.subscribed_users.all(): package.subscribed_users.add(workbench_user) package.save() else: package.subscribed_users.remove(workbench_user) package.save() messages.add_message(request, messages.SUCCESS, 'Subscription preferences changed') return HttpResponseRedirect( redirect_to=reverse('package_detail', kwargs={'pk': package_id}))
def post(self, request, experiment_id=0): experiment = Experiment() data = request.POST.copy() data['owner'] = get_workbench_user(request.user).id form = ExperimentForm(data, instance=experiment) if form.is_valid(): cookiecutter = form.cleaned_data['template'] experiment.language = cookiecutter.language experiment.owner = WorkbenchUser.objects.get(user=request.user) experiment.save() initialize_repository.delay(experiment.id, cookiecutter.id) return redirect(to=reverse('experiment_status_create')) else: return render( request, "experiments_manager/experiment_create/experiment_new.html", { 'form': form, 'experiment_id': experiment_id })
def form_valid(self, form): form.instance.owner = get_workbench_user(self.request.user) form.instance.template_id = 1 response = super(InternalPackageCreateView, self).form_valid(form) task_create_package.delay(form.instance.pk) return response
def form_valid(self, form): form.instance.owner = get_workbench_user(self.request.user) return super(ExternalPackageCreateView, self).form_valid(form)
def recommend_packageresource(request, pk): resource = PackageResource.objects.get(id=pk) workbench_user = get_workbench_user(request.user) return recommend(resource, workbench_user)
def recommend_package(request, pk): package = Package.objects.get(id=pk) workbench_user = get_workbench_user(request.user) return recommend(package, workbench_user)
def form_valid(self, form): package = Package.objects.get(id=self.kwargs['package_id']) form.instance.package = package form.instance.added_by = get_workbench_user(self.request.user) return super(PackageResourceCreateView, self).form_valid(form)