Skip to content

Commit

Permalink
Closed #7; en route to #8, and probably thus completion of this branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgets committed Sep 20, 2018
1 parent 9b88d80 commit e48ed29
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 11 deletions.
24 changes: 19 additions & 5 deletions recadm/templates/recadm/add_entry.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<h2>Record Medication Administration</h2>

{% if error_message %}
<div name="err">
{{ error_message }}
</div>
{% endif %}

<form action="{% url 'recadm:save_admin' %}" method="post">
{% csrf_token %}

Expand All @@ -9,24 +15,32 @@ <h2>Record Medication Administration</h2>
Medication:
</td>
<td>
{% if my_sub_data %}
{% for sub_data in my_sub_data %}
{% if mydata %}
{% for sub_data in mydata %}
<input type="radio" name="substance" value="{{ sub_data.id }}">
{{ sub_data.name }}
</input>
</input><br />
{% endfor %}
{% endif %}
</td>
</tr>
<tr>
<td>
<input type="text" name="dosage" value="0" />
Dosage:
</td>
<td>
<input type="text" name="dosage" value="{{ administration.dosage }}" />
</td>
</tr>
<tr>
<td>
Administration &nbsp;Notes:
</td>
<td>
<textarea name="notes" maxlength="160" cols="40" rows="4">
{{ administration.notes }}
</textarea>
</td>
<td></td>
</tr>
</table>

Expand Down
4 changes: 2 additions & 2 deletions recadm/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

from . import views

app_name = 'viewdox'
app_name = 'recadm'
urlpatterns = [
path('<int:topic_id>/', views.detail, name='detail'),
path('', views.index, name='index'),
path('add', views.add, name='add'),
path('add_new', views.add_new, name='add_new'),
path('save_admin', views.save_admin, name='save_admin'),
]

31 changes: 27 additions & 4 deletions recadm/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,39 @@ def add(request):
#logic?!?

for sub in substances:
mydata.add({'name': sub.common_name, 'id': sub.id, })
mydata.append({'name': sub.common_name, 'id': sub.id, })

context = {
'my_sub_data': mydata,
'mydata': mydata,
}

return render(request, 'recadm/add_entry.html', context)

def add_new(request):
return HttpResponse("AhDittoThayat")
def save_admin(request):
#administration = Usage('sub': request.POST['substance'],
# 'dosage': request.POST['dosage'], 'notes': request.POST['notes'], )
administration = Usage({'sub': request.POST['substance'],
'dosage': request.POST['dosage'], 'notes': request.POST['notes']})

try:
administration.save()
except:
substances = Substance.objects.all()
mydata = [ ]

for sub in substances:
mydata.append({'name': sub.common_name, 'id': sub.id, })

error_message = "Unable to save to db for unknown reason!"
context = {
'mydata': mydata,
'administration': administration,
'error_message': error_message,
}

return render(request, 'recadm/add_entry.html', context)

return render(request, 'recadm/index.html')

def detail(request, usage_id):
return HttpResponse("Soon there will be code doing shit here, also...")
Expand Down

0 comments on commit e48ed29

Please sign in to comment.