...
 
Commits (1)
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.forms import ReadOnlyPasswordHashField
from users.models import User
from django.conf import settings
from body.models import Weight, Gbw
from body.models import Weight, Gbw, Drug
class UserCreationForm(forms.ModelForm):
......@@ -39,6 +40,20 @@ class WeightCreateForm(forms.ModelForm):
# user will be set in views.ResumeNew
# other fields will be set as model default
class DrugCreateForm(forms.ModelForm):
"""
Use to create Weight
"""
salt = forms.CharField(label="ملح" , max_length=255, required=False)
dosage_form = forms.CharField(label= "شکل دارویی", max_length=255, required=False)
strengh = forms.CharField(label="مقدار دارو", max_length=255, required=False)
route_of_admin = forms.CharField(label="راه مصرف", max_length=255, required=False)
atcـcode = forms.CharField(label="دسته دارو", max_length=255, required=False)
ingredient = forms.CharField(label="ترکیبات", max_length=255, required=False)
remarks = forms.CharField(label="توضیحات", max_length=255, required=False)
class Meta(object):
model = Drug
fields = ('name', 'salt', 'dosage_form', 'strengh', 'route_of_admin', 'atcـcode', 'ingredient', 'remarks')
class GbwCreateForm(forms.ModelForm):
......
from django.conf.urls import url
from sites import views
from body.models import Weight
from body.models import Weight, Drug
from users.models import User
......@@ -23,7 +23,8 @@ urlpatterns = [
url(r'^rx/$', views.RxView.as_view(), name='rx'),
url(r'^goal/$', views.GoalView.as_view(), name='goal'),
url(r'^goal/create$', views.GoalCreate.as_view(), name='gbw_create'),
url(r'^drug/$', views.DrugView.as_view(), name='drug'),
url(r'^drug/$', views.DrugList.as_view(), name='drug'),
url(r'^drug/create$', views.CreateDrug.as_view(), name='drug_create'),
url(r'^weight/create$', views.WeightCreate.as_view(), name='weight_create'),
url(r'^weight/(?P<pk>[\w]+)/$', views.WeightShow.as_view(), name='weight_show'),
url(r'^weight/update/(?P<pk>[\w]+)/$', views.WeightUpdate.as_view(
......
......@@ -2,7 +2,7 @@ from django.shortcuts import render, redirect
from django.template import loader
from django.http import HttpResponse, HttpResponseRedirect
from django.views.generic import TemplateView, CreateView, DetailView, UpdateView, DeleteView, ListView
from .forms import UserCreationForm, WeightCreateForm, ProfileUpdateForm, GbwCreateForm
from .forms import UserCreationForm, WeightCreateForm, ProfileUpdateForm, GbwCreateForm, DrugCreateForm
from django.contrib.auth import login
from django.contrib.auth import get_user_model
from django.contrib.auth.decorators import login_required
......@@ -146,6 +146,10 @@ class GoalView(TemplateView):
return context
@method_decorator(staff_member_required, name='dispatch')
class DrugList(ListView):
model = Drug
@method_decorator(login_required, name='dispatch')
class DrugView(TemplateView):
......@@ -203,6 +207,9 @@ class WeightCreate(CreateView):
return super(WeightCreate, self).form_valid(form)
@method_decorator(login_required, name='dispatch')
class WeightList(ListView):
model = Weight
......@@ -290,6 +297,21 @@ class WeightList(ListView):
@method_decorator(login_required, name='dispatch')
class CreateDrug(CreateView):
model = Drug
form_class = DrugCreateForm
success_url = reverse_lazy('Drug_create')
def form_valid(self, form):
"""Force the user to request.user"""
self.object = form.save(commit=False)
self.object.save()
return super(CreateDrug, self).form_valid(form)
......
{% extends "sites/base_site.html" %}
{% block title %}
{% if object_list %}
ویرایش دارو
{% else %}
افزودن دارو
{% endif %}
{% endblock title %}
{% block stylesheets %}
{{ block.super }}
{% endblock stylesheets %}
{% if object_list %}
{% block location %}
{% if object_list %}
ویرایش دارو
{% else %}
افزودن دارو
{% endif %}
{% endblock location %}
{% endif %}
{% block content %}
<div class="row">
<div class="col-md-4 offset-sm-4">
<div class="card">
<div class="card-header">
{% if object_list %}
ویرایش <strong> دارو </strong>
{% else %}
افزودن <strong> دارو </strong>
{% endif %}
</div>
<div class="card-block">
<form action="" method="post" enctype="multipart/form-data" class="form-horizontal ">{% csrf_token %}
{% if form.errors %}
{% include "users/partials/errors.html" %}
{% endif %}
{% csrf_token %}
{% for field in form %}
<div class="input-group m-b-1">
{% include "users/partials/field.html" %}
</div>
{% endfor %}
<div class="card-footer">
<button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-dot-circle-o"></i>
{% if object_list %}
ویرایش
{% else %}
افزودن
{% endif %}
</button>
<button type="reset" class="btn btn-sm btn-danger"><i class="fa fa-ban"></i> بازنشانی</button>
</div>
</div>
</div>
</div>
{% endblock content %}
{% block javascripts %}
{{ block.super }}
{% endblock javascripts %}
\ No newline at end of file
{% extends "sites/base_site.html" %}
{% load static %}
{% load jformat %}
{% block title %} لیست داروها {% endblock title %}
{% block stylesheets %}
{{ block.super }}
{% endblock stylesheets %}
{% block location %}
لیست داروها
{% endblock location %}
{% block content %}
<!-- Calculates user weight status according to bmi and show allerts -->
<!--/.container-fluid-->
<div class="container-fluid">
<div class="animated fadeIn">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<i class="fa fa-align-justify"></i> لیست داروها
</div>
<div class="card-block">
<p>
<a class="btn btn-outline-primary" href="{% url 'drug_create' %}" role="button">
<span class="fas fa-plus"></span>
دارو جدید
</a>
</p>
<table class="table">
<thead>
<tr>
<th>#</th>
<th>نام</th>
<th>ملح</th>
<th>شکل دارویی</th>
<th>مقدار دارو</th>
<th>راه مصرف</th>
</tr>
</thead>
<tbody>
{% for drug in object_list %}
<tr>
<td>{{ drug.id }}</td>
<td>{{ drug.name }}</td>
<td>{{ drug.salt }}</td>
<td>{{ drug.dosage_form }}</td>
<td>{{ drug.strengh }}</td>
<td>{{ drug.route_of_admin }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<ul class="pagination">
<li class="page-item"><a class="page-link" href="#">Prev</a>
</li>
<li class="page-item active">
<a class="page-link" href="#">1</a>
</li>
<li class="page-item"><a class="page-link" href="#">2</a>
</li>
<li class="page-item"><a class="page-link" href="#">3</a>
</li>
<li class="page-item"><a class="page-link" href="#">4</a>
</li>
<li class="page-item"><a class="page-link" href="#">Next</a>
</li>
</ul>
</div>
</div>
</div>
<!--/col-->
</div>
<!-- /.conainer-fluid -->
{% endblock content %}
{% block javascripts %}
{{ block.super }}
{% endblock javascripts %}
......@@ -40,7 +40,8 @@
</tr>
</thead>
<tbody>
{% for user in object_list %}
{% for user in object_list %}
{% if user.is_patient is True %}
<tr>
<td>{{ user.id }}</td>
......@@ -50,8 +51,11 @@
</tr>
{% endfor %}
{% endif %}
{% endfor %}
</tbody>
</table>
<ul class="pagination">
<li class="page-item"><a class="page-link" href="#">Prev</a>
......