forked from enviPath/enviPy
Implement Compound CRUD (#22)
Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#22
This commit is contained in:
@ -684,7 +684,7 @@ def package_compound(request, package_uuid, compound_uuid):
|
||||
|
||||
return render(request, 'objects/compound.html', context)
|
||||
|
||||
if request.method == 'POST':
|
||||
elif request.method == 'POST':
|
||||
if hidden := request.POST.get('hidden', None):
|
||||
if hidden == 'delete-compound':
|
||||
current_compound.delete()
|
||||
@ -706,6 +706,8 @@ def package_compound(request, package_uuid, compound_uuid):
|
||||
return redirect(current_compound.url)
|
||||
else:
|
||||
return HttpResponseBadRequest()
|
||||
else:
|
||||
return HttpResponseBadRequest()
|
||||
|
||||
|
||||
# https://envipath.org/package/<uuid>/compound/<uuid>/structure
|
||||
@ -724,7 +726,7 @@ def package_compound_structures(request, package_uuid, compound_uuid):
|
||||
reviewed_compound_structure_qs = CompoundStructure.objects.none()
|
||||
unreviewed_compound_structure_qs = CompoundStructure.objects.none()
|
||||
|
||||
if package.reviewed:
|
||||
if current_package.reviewed:
|
||||
reviewed_compound_structure_qs = current_compound.structures.order_by('name')
|
||||
else:
|
||||
unreviewed_compound_structure_qs = current_compound.structures.order_by('name')
|
||||
@ -734,13 +736,24 @@ def package_compound_structures(request, package_uuid, compound_uuid):
|
||||
|
||||
return render(request, 'collections/objects_list.html', context)
|
||||
|
||||
elif request.method == 'POST':
|
||||
structure_name = request.POST.get('structure-name')
|
||||
structure_smiles = request.POST.get('structure-smiles')
|
||||
structure_description = request.POST.get('structure-description')
|
||||
|
||||
cs = current_compound.add_structure(structure_smiles, structure_name, structure_description)
|
||||
|
||||
return redirect(cs.url)
|
||||
|
||||
else:
|
||||
return HttpResponseBadRequest()
|
||||
|
||||
# https://envipath.org/package/<id>/compound/<id>/structure/<id>
|
||||
def package_compound_structure(request, package_uuid, compound_uuid, structure_uuid):
|
||||
current_user = _anonymous_or_real(request)
|
||||
current_package = PackageManager.get_package_by_id(current_user, package_uuid)
|
||||
current_compound = Compound.objects.get(package=current_package, uuid=compound_uuid)
|
||||
current_structure = CompoundStructure.get(compound=current_compound, uuid=structure_uuid)
|
||||
current_structure = CompoundStructure.objects.get(compound=current_compound, uuid=structure_uuid)
|
||||
|
||||
if request.method == 'GET':
|
||||
context = get_base_context(request)
|
||||
@ -818,6 +831,8 @@ def package_rules(request, package_uuid):
|
||||
r = Rule.create(current_package, rule_type, name=rule_name, description=rule_description, **params)
|
||||
return redirect(r.url)
|
||||
|
||||
else:
|
||||
return HttpResponseBadRequest()
|
||||
|
||||
# https://envipath.org/package/<id>/rule/<id>
|
||||
def package_rule(request, package_uuid, rule_uuid):
|
||||
|
||||
Reference in New Issue
Block a user