summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--date.txt2
-rw-r--r--maintenance/management/__init__.py0
-rw-r--r--maintenance/management/commands/__init__.py1
-rw-r--r--maintenance/management/commands/log_generator.py20
-rw-r--r--map_machine_ids.txt28
-rw-r--r--myadmin/views.py21
-rw-r--r--new.csv3
-rw-r--r--new_cron_job.sh24
-rw-r--r--sbhs_server/sbhs.py2
-rw-r--r--sbhs_server/settings.py7
-rw-r--r--slot/views.py2
-rw-r--r--templates/admin/testexp.html37
12 files changed, 103 insertions, 44 deletions
diff --git a/date.txt b/date.txt
index 2312a90..0ac25fc 100644
--- a/date.txt
+++ b/date.txt
@@ -1 +1 @@
-Wed Jan 4 10:58:02 IST 2017
+Fri May 26 00:00:46 IST 2017
diff --git a/maintenance/management/__init__.py b/maintenance/management/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/maintenance/management/__init__.py
diff --git a/maintenance/management/commands/__init__.py b/maintenance/management/commands/__init__.py
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/maintenance/management/commands/__init__.py
@@ -0,0 +1 @@
+
diff --git a/maintenance/management/commands/log_generator.py b/maintenance/management/commands/log_generator.py
new file mode 100644
index 0000000..95c03d0
--- /dev/null
+++ b/maintenance/management/commands/log_generator.py
@@ -0,0 +1,20 @@
+#Dev/KoDe :)
+
+import csv
+import datetime
+import os
+import sys
+from django.core.management.base import BaseCommand, CommandError
+
+class Command(BaseCommand):
+ args = ''
+ help = 'Creates Log'
+
+ def handle(self, *args, **options):
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sbhs_server.settings") # To make a Django Environment.
+
+ from sbhs_server.tables.models import Board
+ board_details = Board.objects.values_list("online", flat=True)
+ board = str([x for x in board_details])
+ with open('new.csv', "a") as newcsv:
+ newcsv.write("{0} {1} \n".format(datetime.datetime.now(), board.replace(",", "").replace("[", "").replace("]","")))
diff --git a/map_machine_ids.txt b/map_machine_ids.txt
index 7b66f9f..d586cb4 100644
--- a/map_machine_ids.txt
+++ b/map_machine_ids.txt
@@ -1,29 +1 @@
-32=/dev/ttyUSB2
-25=/dev/ttyUSB1
52=/dev/ttyUSB0
-15=/dev/ttyUSB30
-16=/dev/ttyUSB36
-14=/dev/ttyUSB31
-11=/dev/ttyUSB41
-1=/dev/ttyUSB40
-8=/dev/ttyUSB39
-7=/dev/ttyUSB38
-2=/dev/ttyUSB32
-13=/dev/ttyUSB37
-10=/dev/ttyUSB35
-12=/dev/ttyUSB34
-9=/dev/ttyUSB33
-20=/dev/ttyUSB28
-17=/dev/ttyUSB26
-28=/dev/ttyUSB25
-24=/dev/ttyUSB24
-22=/dev/ttyUSB23
-18=/dev/ttyUSB22
-30=/dev/ttyUSB20
-29=/dev/ttyUSB18
-3=/dev/ttyUSB13
-6=/dev/ttyUSB12
-31=/dev/ttyUSB7
-19=/dev/ttyUSB6
-23=/dev/ttyUSB5
-5=/dev/ttyUSB3
diff --git a/myadmin/views.py b/myadmin/views.py
index a15770b..9e9c314 100644
--- a/myadmin/views.py
+++ b/myadmin/views.py
@@ -2,9 +2,9 @@ from django.shortcuts import render, redirect
from django.http import Http404,HttpResponse
from django.contrib.auth.decorators import login_required
from django.views.decorators.csrf import csrf_exempt
-from sbhs_server.tables.models import Board, Booking
+from sbhs_server.tables.models import Board, Booking, Slot
from sbhs_server import settings,sbhs
-import subprocess,json,serial,os
+import subprocess,json,serial,os, datetime
# Create your views here.
def checkadmin(req):
@@ -27,7 +27,7 @@ def toggle_allotment_mode(req):
@login_required(redirect_field_name=None)
def booking_index(req):
checkadmin(req)
- bookings = Booking.objects.order_by('-booking_date').select_related()[:50]
+ bookings = Booking.objects.order_by('-booking_date','-slot_id').filter(trashed_at__isnull=True).select_related()[:50]
return render(req, 'admin/booking_index.html', {"bookings": bookings})
@login_required(redirect_field_name=None)
@@ -78,9 +78,20 @@ def profile(req, mid):
@login_required(redirect_field_name=None)
def testing(req):
checkadmin(req)
- boards = Board.objects.order_by('online').all()
+ now = datetime.datetime.now()
+ current_slot_id = Slot.objects.filter(start_hour=now.hour,
+ start_minute__lt=now.minute,
+ end_minute__gt=now.minute)
+
+ current_slot_id = -1 if not current_slot_id else current_slot_id[0].id
+
+ current_bookings = Booking.objects.filter(slot_id=current_slot_id,
+ booking_date=datetime.date.today()).select_related()
+ current_mids = list([-1]) if not current_bookings else [current_booking.account.board.mid for current_booking in current_bookings]
+
+ boards = Board.objects.filter(online=1)
allotment_mode = "Random" if Board.can_do_random_allotment() else "Workshop"
- return render(req, 'admin/testexp.html', {"boards": boards, "allotment_mode": allotment_mode})
+ return render(req, 'admin/testexp.html', {"boards": boards, "allotment_mode": allotment_mode, "mids": current_mids})
@csrf_exempt
def reset_device(req):
diff --git a/new.csv b/new.csv
index 624561f..d8b8930 100644
--- a/new.csv
+++ b/new.csv
@@ -4692,3 +4692,6 @@
2017-01-04 08:58:02.090423 True True True False True True True True True True True True True True True True True True True True False True True True True False True True True True True True False False False False False False False False False False False
2017-01-04 09:58:01.592575 True True True False True True True True True True True True True True True True True True True True False True True True True False True True True True True True False False False False False False False False False False False
2017-01-04 10:58:02.140706 True True True False True True True True True True True True True True True True True True True True False True True True True False True True True True True True False False False False False False False False False False False
+2017-05-25 23:58:31.794913 False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False True
+2017-05-25 23:58:55.790097 False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False
+2017-05-26 00:00:46.763190 False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False True
diff --git a/new_cron_job.sh b/new_cron_job.sh
new file mode 100644
index 0000000..f757e20
--- /dev/null
+++ b/new_cron_job.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+# Django 1.11 compatible
+
+
+find $(pwd) -iname \*.pyc -exec rm -rfv {} \; #to delete all .pyc files
+
+DIR="$( cd "$( dirname "$0" )" && pwd )"
+cd $DIR
+killall streamer
+source ../bin/activate
+#source ./bin/activate
+python sbhs_server/scan_machines.py
+#python offline_reconnect.py
+python manage.py makemigrations
+python manage.py migrate
+python manage.py initialize_machines
+python manage.py generate_checksum
+touch index.wsgi
+python manage.py log_generator
+
+#python log_generator.py
+date > date.txt
+sleep 2 \ No newline at end of file
diff --git a/sbhs_server/sbhs.py b/sbhs_server/sbhs.py
index c9620e9..f7873cb 100644
--- a/sbhs_server/sbhs.py
+++ b/sbhs_server/sbhs.py
@@ -1,7 +1,7 @@
import serial
import os
from time import localtime, strftime, sleep
-import sbhs_server.credentials as credentials
+import credentials
MAP_FILE = credentials.MAP_FILE
#LOG_FILE = '../log/sbhserr.log'
diff --git a/sbhs_server/settings.py b/sbhs_server/settings.py
index 7161f29..82c95d7 100644
--- a/sbhs_server/settings.py
+++ b/sbhs_server/settings.py
@@ -73,6 +73,7 @@ INSTALLED_APPS = (
'slot',
'sbhs_server.tables',
'webcam',
+ 'maintenance',
)
MIDDLEWARE = (
@@ -242,8 +243,10 @@ WEBCAM_STATIC_DIR = 'img/webcam/'
if not is_production:
SBHS_ADMINS = (
- ("Amol Mandhane", "+91-9999999999", "amol_mandhane@iitb.ac.in"),
- ("Amol Mandhane", "+91-9999999999", "amol_mandhane@iitb.ac.in"),
+ # ("Amol Mandhane", "+91-9999999999", "amol_mandhane@iitb.ac.in"),
+ # ("Amol Mandhane", "+91-9999999999", "amol_mandhane@iitb.ac.in"),
+ ('Debakanta Kar' , '0123456789' , 'kar.bubu.15@gmail.com'),
+ ('Deep Bhattacharyya' , '9876543210' , 'cr7.rick@gmail.com')
)
else:
from sbhs_server.sbhs_admin_config import SBHS_ADMINS
diff --git a/slot/views.py b/slot/views.py
index b137f93..5d22ac2 100644
--- a/slot/views.py
+++ b/slot/views.py
@@ -54,7 +54,7 @@ def create(req):
@login_required(redirect_field_name=None)
def index(req):
- bookings = req.user.booking_set.select_related("slot").order_by("booking_date")
+ bookings = req.user.booking_set.select_related("slot").filter(trashed_at__isnull=True).order_by("booking_date")
return render(req, "slot/index.html", {"bookings": reversed(bookings),
"now_time": datetime.datetime.now()})
diff --git a/templates/admin/testexp.html b/templates/admin/testexp.html
index 880f081..39291fa 100644
--- a/templates/admin/testexp.html
+++ b/templates/admin/testexp.html
@@ -2,6 +2,18 @@
{% load staticfiles %}
{% block content %}
+<style type="text/css">
+ .highlight {
+ background-color: lightblue;
+ }
+ #test-device, #monitor-logs {
+ position: fixed;
+ right: 10%;
+ border: 1px slategray solid;
+ padding: 15px;
+ display: none;
+ }
+</style>
<div class="container">
<div class="row">
{% include "account/sub_nav.html" %}
@@ -15,6 +27,7 @@
<tr>
<th>Board MID</th>
<th>Status</th>
+ <th>Occupied</th>
</tr>
</thead>
<tbody>
@@ -22,12 +35,13 @@
<tr>
<td>{{ b.mid }}</td>
<td><span class="label label-{% if b.online %}success{% else %}important{% endif %}">{% if b.online %}Online{% else %}Offline{% endif %}</span></td>
+ <td><span class="label label-{% if b.mid in mids %}important{% else %}success{% endif %}">{% if b.mid in mids %}Ongoing{% else %}Vacant{% endif %}</span></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
- <div class="span5" style="position: fixed;right: 10%; border: 1px slategray solid; padding: 15px;">
+ <div id="test-device" class="span5">
<div>
<input type="text" id="temp" disabled="true"><br/>
<button class="btn btn-primary" onclick="getTemp()">Get Temperature</button>
@@ -48,18 +62,29 @@
</div>
+ <div class="span5" id="monitor-logs">
+ <span>chal raha hain bhai</span>
+ </div>
+
</div>
</div>
-<style type="text/css">
- .highlight {
- background-color: lightblue;
- }
-</style>
<script>
var BASE_URL = window.location.origin;
$("#tableId").on("click", "tr", function(e) {
$("#tableId").find("tr.highlight").removeClass("highlight");
$(this).addClass("highlight");
+
+ columns = e.currentTarget.getElementsByTagName("td");
+ isSelectedMachineVacant = columns[columns.length-1].childNodes[0].className.indexOf("label-success") > -1
+
+ if (isSelectedMachineVacant) {
+ $("#test-device").show();
+ $("#monitor-logs").hide();
+ }
+ else {
+ $("#monitor-logs").show();
+ $("#test-device").hide();
+ }
});
function resetParams() {