Skip to content

Commit

Permalink
Closed #129; note that #130 is still a bug that needs to be fixed wit…
Browse files Browse the repository at this point in the history
…h edit substance capability.
  • Loading branch information
dgets committed Jul 5, 2019
1 parent 926ea38 commit 8126af4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions subadd/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
path('add_class', views.add_sub_class, name='add_sub_class'),
path('class_details/<int:class_id>/', views.sub_class_details, name='sub_class_details'),
path('edit', views.edit_sub, name='edit_sub'),
path('edited_sub/<int:sub_id>/', views.edited_sub, name='edited_sub'),
]

27 changes: 25 additions & 2 deletions subadd/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def edit_sub(request):
except Exception as ex:
context['substances'] = Substance.objects.all()
context['error_message'] = "No substance selected for editing!"

return render(request, 'subadd/edit_sub.html', MiscMethods.add_header_info(context))

# substance_form = substance
Expand Down Expand Up @@ -147,11 +147,34 @@ def edited_sub(request, sub_id):
context = {}

edited_substance = Substance.objects.get(id=sub_id)

# print(str(edited_substance))
# print("\n---\n")

edited_substance.common_name = request.POST['common_name']
edited_substance.sci_name = request.POST['sci_name']
edited_substance.half_life = request.POST['half_life']
edited_substance.active_half_life = request.POST['active_half_life']
edited_substance.lipid_solubility = request.POST['lipid_solubility']
# edited_substance.lipid_solubility = request.POST['lipid_solubility']
edited_substance.lipid_solubility = request.POST.get('lipid_solubility', False)
# don't forget to check the measurement value, detc

# if edited_substance.lipid_solubility != False:
# edited_substance.lipid_solubility = True

context['edited_substance'] = edited_substance

try:
edited_substance.save()

context['user_message'] = "Saved this record for " + edited_substance.common_name + "."

except Exception as ex:
context['error_message'] = "Unable to save record for " + edited_substance.common_name + ": " + str(ex)

# print(str(edited_substance))

return render(request, 'subadd/edited.html', MiscMethods.add_header_info(context))


@login_required
Expand Down

0 comments on commit 8126af4

Please sign in to comment.