Skip to content

Commit

Permalink
Adds facility for doctor to post news, needs UX implementation, jinja…
Browse files Browse the repository at this point in the history
… templating needed, fixes Issue #33
  • Loading branch information
sudheesh001 committed Aug 12, 2014
1 parent 274b8ab commit d2766f4
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
7 changes: 7 additions & 0 deletions Dispensary.sql
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ CREATE TABLE IF NOT EXISTS `ChatQueue` (
PRIMARY KEY (Sno)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- News Posted which will be available on the screen panel.

CREATE TABLE IF NOT EXISTS `DoctorNews` (
`Date` datetime NOT NULL,
`Content` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

----------------------------------------------------
----Tried to use prescription with dependency name column....complexity increased.....keeping it simple
CREATE TABLE IF NOT EXISTS `DependencyPrescription` (
Expand Down
21 changes: 19 additions & 2 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,11 @@ def screen():
sql = 'select * from Users where RegNo = "%s"'
db.execute(sql%app.config['USERID'])
names = db.fetchall()
newssql = 'select * from DoctorNews order by Date'
db.execute(newssql)
news = db.fetchall()
db.execute("commit")
return render_template('screen.html',names=names) #show_entries
return render_template('screen.html',names=names, news=news) #show_entries

@app.route('/chat')
def chat():
Expand Down Expand Up @@ -214,7 +217,21 @@ def printletter():
else:
flash('Error occured with the form')
return redirect(url_for('screen'))


@app.route('/postNews',methods=['GET','POST'])
def postNews():
if request.method=="POST":
db=get_cursor()
date = datetime.datetime.now()
content = request.form['content']
sql = 'insert into DoctorNews values ("%s","%s")'
db.execute(sql%(date,content))
db.execute("commit")
flash('Posted the news.')
return redirect(url_for('screen'))
return redirect(url_for('screen'))


@app.route('/register')
def register():
return render_template('show_entries.html')
Expand Down
38 changes: 38 additions & 0 deletions templates/screen.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ <h1>Hello! <i style="font-size:40px;font-weight:100;">{{name[2]}} {{name[4]}}</i
{%endif%}
{% if session.temp==3 %}
<!-- The doctor should be able to enter the EMP_ID / REG_NO and see their prescription table -->
<p><button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#NewsModal" style="width:20%;">Post News</button></p>
<p><a class="btn btn-primary btn-lg" role="button" href="/prescription" style="width:20%;">Give Prescriptions</a></p>
<p><button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#depModal" style="width:20%;">Give dependency Prescription</button></p>
<p><button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal" style="width:20%;">Give Sick Letter</button></p>
Expand Down Expand Up @@ -77,7 +78,44 @@ <h1>Hello! <i style="font-size:40px;font-weight:100;">{{name[2]}} {{name[4]}}</i
<i style="margin-left:25px;">Change password</i>
</p>
{% endif %}
{% for newsvalue in news %}
{{newsvalue[0]}} {{newsvalue[1]}}
{% endfor %}
</div>
<!-- News Modal -->
<div class="modal fade" id="NewsModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="width:19%;">&times;</button>
<h4 class="modal-title" id="myModalLabel">Post News</h4>
</div>
<form action="{{url_for('postNews')}}" method="POST">
<div class="modal-body">

<div class="container">
<div class="row">
<div class="form-horizontal">
<div class="form-group">
<label class="col-md-2 control-label" >Enter post</label>
<div class="col-xs-3">
<textarea type="textarea" class="form-control" name="content" placeholder="Enter Content" rows=10 cols=40></textarea>
</div>
</div>
</div>
</div>
</div>

</div>
<div class="modal-footer">
<button type="button" class="btn btn-warning" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-success" >Post News</button>
</div>
</form>
</div>
</div>
</div>
<!-- My Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
Expand Down

0 comments on commit d2766f4

Please sign in to comment.