diff options
Diffstat (limited to 'sbhs_server')
56 files changed, 45 insertions, 1726 deletions
diff --git a/sbhs_server/account/__init__.py b/sbhs_server/account/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/sbhs_server/account/__init__.py +++ /dev/null diff --git a/sbhs_server/account/admin.py b/sbhs_server/account/admin.py deleted file mode 100644 index 8c38f3f..0000000 --- a/sbhs_server/account/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/sbhs_server/account/models.py b/sbhs_server/account/models.py deleted file mode 100644 index 71a8362..0000000 --- a/sbhs_server/account/models.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.db import models - -# Create your models here. diff --git a/sbhs_server/account/tests.py b/sbhs_server/account/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/sbhs_server/account/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/sbhs_server/account/views.py b/sbhs_server/account/views.py deleted file mode 100644 index 306b318..0000000 --- a/sbhs_server/account/views.py +++ /dev/null @@ -1,111 +0,0 @@ -from django.shortcuts import render, redirect -from sbhs_server.tables.models import Account, Board -from django.core.exceptions import ValidationError -from django.core.validators import validate_email -from django.contrib import messages -from sbhs_server.helpers import simple_encrypt -from django.contrib.auth import authenticate -from django.contrib.auth import login as LOGIN -from django.contrib.auth import logout as LOGOUT -from django.contrib.auth.decorators import login_required -# Create your views here. - -def index(req): - if req.user.is_authenticated(): - return redirect(home) - return render(req, "account/index.html") - -def new(): - pass - -def create(req): - error = [] - - name = req.POST.get("name").strip() - email = req.POST.get("email").strip() - username = req.POST.get("username").strip() - roll_number = req.POST.get("roll_number").strip() - password = req.POST.get("password") - confirm = req.POST.get("confirm") - institute = req.POST.get("institute").strip() - department = req.POST.get("department").strip() - position = req.POST.get("position").strip() - - error = error + (["Please enter a name."] if name == "" else []) - error = error + (["Please enter an email."] if email == "" else []) - error = error + (["Please enter an username."] if username == "" else []) - error = error + (["Please enter a roll_number."] if roll_number == "" else []) - - error = error + (["Please enter a password."] if password == "" else []) - error = error + (["Password confirmation does not match."] if password != confirm else []) - - error = error + (["Please enter an institute."] if institute == "" else []) - error = error + (["Please enter a department."] if department == "" else []) - error = error + (["Please enter a position."] if position == "" else []) - - try: - validate_email(email) - except ValidationError: - error = error + ["Please enter a valid email."] - - email_exists = Account.objects.filter(email=email).count() - error = error + (["Account with given email already exists."] if email_exists > 0 else []) - - username_exists = Account.objects.filter(username=username).count() - error = error + (["Account with given username already exists."] if username_exists > 0 else []) - - if error != []: - messages.add_message(req, messages.ERROR, "<br>".join(error)) - return redirect(index) - - # try: - account = Account( - name=name, - username=username, - email=email, - board_id=Board.allot_board() - ) - account.set_password(password) - account.save() - account.send_confirmation() - print "Done" - messages.add_message(req, messages.SUCCESS, "You have been registered successfully. Please check your email for confirmation.") - return redirect(index) - # except: - # messages.add_message(req, messages.ERROR, "Invalid information. Please try again.") - # return redirect(index) - -def confirm(req, token): - try: - email = simple_encrypt.decrypt(token) - account = Account.objects.get(email=email) - account.is_active = True - account.save() - messages.add_message(req, messages.SUCCESS, "Your email has been confirmed. You can login now.") - except: - messages.add_message(req, messages.ERROR, "Invalid confirmation token.") - - return redirect(index) - -def login(req): - username = req.POST.get('username') - password = req.POST.get('password') - user = authenticate(username=username, password=password) - if user is not None: - if user.is_active: - LOGIN(req, user) - return redirect(index) - else: - messages.add_message(req, messages.ERROR, "Your account is not activated yet. Please check your email for activation link.") - return redirect(index) - else: - messages.add_message(req, messages.ERROR, "Invalid username or password.") - return redirect(index) - -def logout(req): - LOGOUT(req) - return redirect(index) - -@login_required(redirect_field_name=None) -def home(req): - return render(req, "account/home.html") diff --git a/sbhs_server/admin/__init__.py b/sbhs_server/admin/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/sbhs_server/admin/__init__.py +++ /dev/null diff --git a/sbhs_server/admin/admin.py b/sbhs_server/admin/admin.py deleted file mode 100644 index 8c38f3f..0000000 --- a/sbhs_server/admin/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/sbhs_server/admin/models.py b/sbhs_server/admin/models.py deleted file mode 100644 index 71a8362..0000000 --- a/sbhs_server/admin/models.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.db import models - -# Create your models here. diff --git a/sbhs_server/admin/tests.py b/sbhs_server/admin/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/sbhs_server/admin/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/sbhs_server/admin/views.py b/sbhs_server/admin/views.py deleted file mode 100644 index 8289cfa..0000000 --- a/sbhs_server/admin/views.py +++ /dev/null @@ -1,75 +0,0 @@ -from django.shortcuts import render, redirect -from django.http import Http404 -from django.contrib.auth.decorators import login_required -from sbhs_server.tables.models import Board, Booking -from sbhs_server import settings -import subprocess -# Create your views here. - -def checkadmin(req): - if not req.user.is_admin: - raise Http404 - -@login_required(redirect_field_name=None) -def index(req): - checkadmin(req) - boards = Board.objects.order_by('online').all() - allotment_mode = "Random" if Board.can_do_random_allotment() else "Workshop" - return render(req, 'admin/index.html', {"boards": boards, "allotment_mode": allotment_mode}) - -@login_required(redirect_field_name=None) -def toggle_allotment_mode(req): - checkadmin(req) - Board.toggle_random_allotment() - return redirect(index) - -@login_required(redirect_field_name=None) -def booking_index(req): - checkadmin(req) - bookings = Booking.objects.order_by('-booking_date').select_related()[:50] - return render(req, 'admin/booking_index.html', {"bookings": bookings}) - -@login_required(redirect_field_name=None) -def webcam_index(req): - checkadmin(req) - boards = Board.objects.all() - return render(req, 'admin/webcam_index.html', {"boards": boards}) - -@login_required(redirect_field_name=None) -def profile(req, mid): - checkadmin(req) - try: - filename = settings.SBHS_GLOBAL_LOG_DIR + "/" + mid + ".log" - f = open(filename, "r") - f.close() - except: - raise Http404 - - delta_T = 1000 - data = subprocess.check_output("tail -n %d %s" % (delta_T, filename), shell=True) - data = data.split("\n") - plot = [] - heatcsv = "" - fancsv = "" - tempcsv = "" - - for t in xrange(len(data)): - line = data[t] - entry = line.strip().split(" ") - try: - plot.append([int(i) for i in entry[0:-1] + [float(entry[-1])]]) - heatcsv += "%d,%s\\n" % (t+1, entry[1]) - fancsv += "%d,%s\\n" % (t+1, entry[2]) - tempcsv += "%d,%s\\n" % (t+1, entry[3]) - except: - continue - - plot = zip(*plot) # transpose - - return render(req, "admin/profile.html", { - "mid": mid, - "delta_T": delta_T, - "heat": heatcsv, - "fan": fancsv, - "temp": tempcsv - })
\ No newline at end of file diff --git a/sbhs_server/experiment/__init__.py b/sbhs_server/experiment/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/sbhs_server/experiment/__init__.py +++ /dev/null diff --git a/sbhs_server/experiment/admin.py b/sbhs_server/experiment/admin.py deleted file mode 100644 index 8c38f3f..0000000 --- a/sbhs_server/experiment/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/sbhs_server/experiment/models.py b/sbhs_server/experiment/models.py deleted file mode 100644 index 71a8362..0000000 --- a/sbhs_server/experiment/models.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.db import models - -# Create your models here. diff --git a/sbhs_server/experiment/tests.py b/sbhs_server/experiment/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/sbhs_server/experiment/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/sbhs_server/experiment/views.py b/sbhs_server/experiment/views.py deleted file mode 100644 index 515d2b2..0000000 --- a/sbhs_server/experiment/views.py +++ /dev/null @@ -1,221 +0,0 @@ -from django.shortcuts import render -from django.http import HttpResponse -from django.contrib.auth.decorators import login_required -from django.contrib.auth import authenticate -from django.contrib.auth import login as LOGIN -from sbhs_server.tables.models import Slot, Account, Experiment, Booking -import json, datetime, os, time -from django.views.decorators.csrf import csrf_exempt -from sbhs_server import settings -# Create your views here. -# -def check_connection(req): - return HttpResponse("TESTOK") - -@csrf_exempt -def initiation(req): - username = req.POST.get("username") - password = req.POST.get("password") - user = authenticate(username=username, password=password) - if user is not None: - if user.is_active: - user1 = Account.objects.select_related().filter(id=user.id) - user1 = user1[0] - user_board = user1.board - if user_board.online: - slots = Slot.slots_now() - slot_ids = [s.id for s in slots] - now = datetime.datetime.now() - bookings = user.booking_set.filter(booking_date__year=now.year, - booking_date__month=now.month, - booking_date__day=now.day, - slot_id__in=slot_ids).select_related("slot") - try: - cur_booking = bookings[0] - active_slot = cur_booking.slot - except: - cur_booking = None - active_slot = None - - if active_slot is not None: - endtime = cur_booking.end_time() - if now < endtime: - filename = datetime.datetime.strftime(now, "%Y%b%d_%H_%M_%S.txt") - logdir = os.path.join(settings.EXPERIMENT_LOGS_DIR, user.username) - if not os.path.exists(logdir): - os.makedirs(logdir) - - f = open(os.path.join(logdir, filename), "a") - f.close() - - LOGIN(req, user) - - e = Experiment() - e.booking=cur_booking - e.log=os.path.join(logdir, filename) - e.save() - - key = str(user_board.mid) - - settings.boards[key]["experiment_id"] = e.id - reset(req) - - - STATUS = 1 - MESSAGE = filename - else: - reset(req) - STATUS = 0 - MESSAGE = "Slot has ended. Please book the next slot to continue the experiment." - else: - STATUS = 0 - MESSAGE = "You haven't booked this slot." - else: - STATUS = 0 - MESSAGE = "Your SBHS is offline. Please contact the Vlabs team." - else: - STATUS = 0 - MESSAGE = "Your account is not activated yet. Please check your email for activation link." - else: - STATUS = 0 - MESSAGE = "Invalid username or password" - - return HttpResponse(json.dumps({"STATUS": STATUS, "MESSAGE": MESSAGE})) -# return HttpResponse(key) -# @login_required(redirect_field_name=None) -@csrf_exempt -def experiment(req): - try: - server_start_ts = int(time.time() * 1000) - from sbhs_server.settings import boards - user = req.user - key = str(user.board.mid) - experiment = Experiment.objects.select_related().filter(id=boards[key]["experiment_id"]) - - if len(experiment) == 1 and user.id == experiment[0].booking.account.id and experiment[0].booking.trashed_at == None: - experiment = experiment[0] - now = datetime.datetime.now() - endtime = experiment.booking.end_time() - if endtime > now: - timeleft = int((endtime-now).seconds) - heat = max(min(int(req.POST.get("heat")), 100), 0) - fan = max(min(int(req.POST.get("fan")), 100), 0) - - boards[key]["board"].setHeat(heat) - boards[key]["board"].setFan(fan) - temperature = boards[key]["board"].getTemp() - log_data(boards[key]["board"], key, heat=heat, fan=fan, temp=temperature) - - server_end_ts = int(time.time() * 1000) - - STATUS = 1 - MESSAGE = "%s %d %d %2.2f" % (req.POST.get("iteration"), - heat, - fan, - temperature) - MESSAGE = "%s %s %d %d,%s,%d" % (MESSAGE, - req.POST.get("timestamp"), - server_start_ts, - server_end_ts, - req.POST.get("variables"), timeleft) - - f = open(experiment.log, "a") - f.write(" ".join(MESSAGE.split(",")[:2]) + "\n") - f.close() - else: - boards[key]["board"].setHeat(0) - boards[key]["board"].setFan(100) - log_data(boards[key]["board"], key) - - STATUS = 0 - MESSAGE = "Slot has ended. Please book the next slot to continue the experiment." - - reset(req) - boards[key]["experiment_id"] = None - else: - STATUS = 0 - MESSAGE = "You haven't booked this slot." - - return HttpResponse(json.dumps({"STATUS": STATUS, "MESSAGE": MESSAGE})) - except Exception: - return HttpResponse(json.dumps({"STATUS": 0, "MESSAGE": "Invalid input. Perhaps the slot has ended. Please book the next slot to continue the experiment."})) - -@csrf_exempt -def reset(req): - try: - from sbhs_server.settings import boards - user = req.user - if user.is_authenticated(): - key = str(user.board.mid) - experiment = Experiment.objects.select_related().filter(id=boards[key]["experiment_id"]) - - if len(experiment) == 1 and user == experiment[0].booking.account: - experiment = experiment[0] - now = datetime.datetime.now() - endtime = experiment.booking.end_time() - boards[key]["board"].setHeat(0) - boards[key]["board"].setFan(100) - log_data(boards[key]["board"], key) - if endtime < now: - boards[key]["experiment_id"] = None - except: - pass - - return HttpResponse("") - -def client_version(req): - return HttpResponse("3") - -@login_required(redirect_field_name=None) -def logs(req): - bookings = Booking.objects.only("id").filter(account__id=req.user.id) - deleted_bookings = Booking.trash.only("id").filter(account__id=req.user.id) - bookings = list(bookings) + list(deleted_bookings) - booking_ids = [b.id for b in bookings] - experiments = Experiment.objects.select_related("booking", "booking__slot").filter(booking_id__in=booking_ids) - for e in experiments: - e.logname = e.log.split("/")[-1] - return render(req, "experiment/logs.html", {"experiments": reversed(experiments)}) - -@login_required(redirect_field_name=None) -def download_log(req, experiment_id, fn): - try: - experiment = Experiment.objects.select_related("booking", "booking__account").get(id=experiment_id) - assert req.user.id == experiment.booking.account.id - f = open(experiment.log, "r") - data = f.read() - f.close() - return HttpResponse(data, content_type='text/text') - except: - return HttpResponse("Requested log file doesn't exist.") - -def log_data(sbhs, mid, heat=None, fan=None, temp=None): - f = open(settings.SBHS_GLOBAL_LOG_DIR + "/" + str(mid) + ".log", "a") - if heat is None: - heat = sbhs.getHeat() - if fan is None: - fan = sbhs.getFan() - if temp is None: - temp = sbhs.getTemp() - - data = "%d %s %s %s\n" % (int(time.time()), str(heat), str(fan), str(temp)) - f.write(data) - f.close() - -def validate_log_file(req): - import hashlib - data = req.POST.get("data") - data = data.strip().split("\n") - clean_data = "" - for line in data: - columns = line.split(" ") - if len(columns) >= 6: - clean_data += (" ".join(columns[0:6]) + "\n") - - checksum = hashlib.sha1(clean_data).hexdigest() - - try: - e = Experiment.objects.get(checksum=checksum) - return HttpResponse("TRUE") - except: - return HttpResponse("FALSE") diff --git a/sbhs_server/experiment/views.py.new b/sbhs_server/experiment/views.py.new deleted file mode 100644 index 004f852..0000000 --- a/sbhs_server/experiment/views.py.new +++ /dev/null @@ -1,222 +0,0 @@ -from django.shortcuts import render -from django.http import HttpResponse -from django.contrib.auth.decorators import login_required -from django.contrib.auth import authenticate -from django.contrib.auth import login as LOGIN -from sbhs_server.tables.models import Slot, Account, Experiment, Booking -import json, datetime, os, time -from django.views.decorators.csrf import csrf_exempt -from sbhs_server import settings -# Create your views here. -# -def check_connection(req): - return HttpResponse("TESTOK") - -@csrf_exempt -def initiation(req): - username = req.POST.get("username") - password = req.POST.get("password") - user = authenticate(username=username, password=password) - if user is not None: - if user.is_active: - user1 = Account.objects.select_related().filter(id=user.id) - user1 = user1[0] - user_board = user1.board - if user_board.online: - slots = Slot.slots_now() - slot_ids = [s.id for s in slots] - now = datetime.datetime.now() - bookings = user.booking_set.filter(booking_date__year=now.year, - booking_date__month=now.month, - booking_date__day=now.day, - slot_id__in=slot_ids).select_related("slot") - try: - cur_booking = bookings[0] - active_slot = cur_booking.slot - except: - cur_booking = None - active_slot = None - - if active_slot is not None: - endtime = cur_booking.end_time() - if now < endtime: - filename = datetime.datetime.strftime(now, "%Y%b%d_%H_%M_%S.txt") - logdir = os.path.join(settings.EXPERIMENT_LOGS_DIR, user.username) - if not os.path.exists(logdir): - os.makedirs(logdir) - - f = open(os.path.join(logdir, filename), "a") - f.close() - - LOGIN(req, user) - - e = Experiment() - e.booking=cur_booking - e.log=os.path.join(logdir, filename) - e.save() - - key = str(user_board.mid) - - settings.boards[key]["experiment_id"] = e.id - - - reset(req) - - STATUS = 1 - MESSAGE = filename - else: - reset(req) - STATUS = 0 - MESSAGE = "Slot has ended. Please book the next slot to continue the experiment." - else: - STATUS = 0 - MESSAGE = "You haven't booked this slot." - else: - STATUS = 0 - MESSAGE = "Your SBHS is offline. Please contact the Vlabs team." - else: - STATUS = 0 - MESSAGE = "Your account is not activated yet. Please check your email for activation link." - else: - STATUS = 0 - MESSAGE = "Invalid username or password" - - return HttpResponse(json.dumps({"STATUS": STATUS, "MESSAGE": MESSAGE})) -# return HttpResponse(str(e.id), str(settings.board[key]) ) -#@login_required(redirect_field_name=None) -@csrf_exempt -def experiment(req): - try: - server_start_ts = int(time.time() * 1000) - from sbhs_server.settings import boards - user = req.user - key = str(user.board.mid) - experiment = Experiment.objects.select_related().filter(id=boards[key]["experiment_id"]) - - if len(experiment) == 1 and user.id == experiment[0].booking.account.id and experiment[0].booking.trashed_at == None: - experiment = experiment[0] - now = datetime.datetime.now() - endtime = experiment.booking.end_time() - if endtime > now: - timeleft = int((endtime-now).seconds) - heat = max(min(int(req.POST.get("heat")), 100), 0) - fan = max(min(int(req.POST.get("fan")), 100), 0) - - boards[key]["board"].setHeat(heat) - boards[key]["board"].setFan(fan) - temperature = boards[key]["board"].getTemp() - log_data(boards[key]["board"], key, heat=heat, fan=fan, temp=temperature) - - server_end_ts = int(time.time() * 1000) - - STATUS = 1 - MESSAGE = "%s %d %d %2.2f" % (req.POST.get("iteration"), - heat, - fan, - temperature) - MESSAGE = "%s %s %d %d,%s,%d" % (MESSAGE, - req.POST.get("timestamp"), - server_start_ts, - server_end_ts, - req.POST.get("variables"), timeleft) - - f = open(experiment.log, "a") - f.write(" ".join(MESSAGE.split(",")[:2]) + "\n") - f.close() - else: - boards[key]["board"].setHeat(0) - boards[key]["board"].setFan(100) - log_data(boards[key]["board"], key) - - STATUS = 0 - MESSAGE = "Slot has ended. Please book the next slot to continue the experiment." - - reset(req) - boards[key]["experiment_id"] = None - else: - STATUS = 0 - MESSAGE = "You haven't booked this slot." - - return HttpResponse(json.dumps({"STATUS": STATUS, "MESSAGE": MESSAGE})) - except Exception: - return HttpResponse(json.dumps({"STATUS": 0, "MESSAGE": "Invalid input. Perhaps the slot has ended. Please book the next slot to continue the experiment."})) - -@csrf_exempt -def reset(req): - try: - from sbhs_server.settings import boards - user = req.user - if user.is_authenticated(): - key = str(user.board.mid) - experiment = Experiment.objects.select_related().filter(id=boards[key]["experiment_id"]) - - if len(experiment) == 1 and user == experiment[0].booking.account: - experiment = experiment[0] - now = datetime.datetime.now() - endtime = experiment.booking.end_time() - boards[key]["board"].setHeat(0) - boards[key]["board"].setFan(100) - log_data(boards[key]["board"], key) - if endtime < now: - boards[key]["experiment_id"] = None - except: - pass - - return HttpResponse("") - -def client_version(req): - return HttpResponse("3") - -@login_required(redirect_field_name=None) -def logs(req): - bookings = Booking.objects.only("id").filter(account__id=req.user.id) - deleted_bookings = Booking.trash.only("id").filter(account__id=req.user.id) - bookings = list(bookings) + list(deleted_bookings) - booking_ids = [b.id for b in bookings] - experiments = Experiment.objects.select_related("booking", "booking__slot").filter(booking_id__in=booking_ids) - for e in experiments: - e.logname = e.log.split("/")[-1] - return render(req, "experiment/logs.html", {"experiments": reversed(experiments)}) - -@login_required(redirect_field_name=None) -def download_log(req, experiment_id, fn): - try: - experiment = Experiment.objects.select_related("booking", "booking__account").get(id=experiment_id) - assert req.user.id == experiment.booking.account.id - f = open(experiment.log, "r") - data = f.read() - f.close() - return HttpResponse(data, content_type='text/text') - except: - return HttpResponse("Requested log file doesn't exist.") - -def log_data(sbhs, mid, heat=None, fan=None, temp=None): - f = open(settings.SBHS_GLOBAL_LOG_DIR + "/" + str(mid) + ".log", "a") - if heat is None: - heat = sbhs.getHeat() - if fan is None: - fan = sbhs.getFan() - if temp is None: - temp = sbhs.getTemp() - - data = "%d %s %s %s\n" % (int(time.time()), str(heat), str(fan), str(temp)) - f.write(data) - f.close() - -def validate_log_file(req): - import hashlib - data = req.POST.get("data") - data = data.strip().split("\n") - clean_data = "" - for line in data: - columns = line.split(" ") - if len(columns) >= 6: - clean_data += (" ".join(columns[0:6]) + "\n") - - checksum = hashlib.sha1(clean_data).hexdigest() - - try: - e = Experiment.objects.get(checksum=checksum) - return HttpResponse("TRUE") - except: - return HttpResponse("FALSE") diff --git a/sbhs_server/pages/__init__.py b/sbhs_server/pages/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/sbhs_server/pages/__init__.py +++ /dev/null diff --git a/sbhs_server/pages/admin.py b/sbhs_server/pages/admin.py deleted file mode 100644 index 8c38f3f..0000000 --- a/sbhs_server/pages/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/sbhs_server/pages/management/__init__.py b/sbhs_server/pages/management/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/sbhs_server/pages/management/__init__.py +++ /dev/null diff --git a/sbhs_server/pages/management/commands/__init__.py b/sbhs_server/pages/management/commands/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/sbhs_server/pages/management/commands/__init__.py +++ /dev/null diff --git a/sbhs_server/pages/management/commands/arm.diff b/sbhs_server/pages/management/commands/arm.diff deleted file mode 100644 index 868bec1..0000000 --- a/sbhs_server/pages/management/commands/arm.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- a/sbhs_server/pages/management/commands/zip_client.py -+++ b/sbhs_server/pages/management/commands/zip_client.py -@@ -33,6 +33,10 @@ class Command(BaseCommand): - run_file_dirpath = os.path.join(dirpath, "run_file") - - os.mkdir(tmp_dirpath) -+ for root, dirs, files in os.walk(dirpath): -+ for f in files: -+ shutil.copy(os.path.join(dirpath, f), os.path.join(tmp_dirpath, f)) -+ - distutils.dir_util.copy_tree(scilab_codes_dirpath, tmp_dirpath) - try: - shutil.rmtree(tmp_dirpath + "/" + scilab_codes_dirname + "/.git") - diff --git a/sbhs_server/pages/management/commands/zip_client.py b/sbhs_server/pages/management/commands/zip_client.py deleted file mode 100644 index 89263bf..0000000 --- a/sbhs_server/pages/management/commands/zip_client.py +++ /dev/null @@ -1,66 +0,0 @@ -from django.core.management.base import BaseCommand -import os, zipfile, shutil, distutils.core -from sbhs_server import settings - -class Command(BaseCommand): - args = '' - help = 'ZIP all clients for all architectures.' - - def handle(self, *args, **options): - def zipdir(path, zip, rootname): - for root, dirs, files in os.walk(path): - for file in files: - pathname = os.path.join(root, file) - zip.write(pathname, rootname + "/" + pathname.replace(path, "")) - - scilab_codes_dirname = "scilab_codes" - scilab_codes_dirpath = os.path.join(settings.SBHSCLIENT_STATIC_DIR, scilab_codes_dirname) - zipped_dirname = "zipped" - zipped_dirpath = os.path.join(settings.SBHSCLIENT_STATIC_DIR, zipped_dirname) - - dirs = os.listdir(settings.SBHSCLIENT_STATIC_DIR) - print dirs - dirs.remove(scilab_codes_dirname) - dirs.remove(zipped_dirname) - print dirs - dirs = [d for d in dirs if os.path.isdir(os.path.join(settings.SBHSCLIENT_STATIC_DIR, d))] - print dirs - dirs = [d for d in dirs if not d.startswith(".")] - - for dirname in dirs: - print dirname - dirpath = os.path.join(settings.SBHSCLIENT_STATIC_DIR, dirname) - tmp_dirpath = os.path.join(zipped_dirpath, dirname) - common_files_dirpath = os.path.join(dirpath, "common_files") - run_file_dirpath = os.path.join(dirpath, "run_file") - - os.mkdir(tmp_dirpath) - for f in os.listdir(dirpath): - if os.path.isfile(os.path.join(dirpath, f)): - shutil.copy(os.path.join(dirpath, f), os.path.join(tmp_dirpath, f)) - - if dirname not in ["analysis", "local"]: - distutils.dir_util.copy_tree(scilab_codes_dirpath, tmp_dirpath) - else: - distutils.dir_util.copy_tree(dirpath, tmp_dirpath) - try: - shutil.rmtree(tmp_dirpath + "/" + scilab_codes_dirname + "/.git") - except: - pass - - try: - for root, dirs, files in os.walk(tmp_dirpath): - if os.path.exists(os.path.join(root, "scilabread.sce")): - distutils.dir_util.copy_tree(run_file_dirpath, root) - except: - pass - - try: - distutils.dir_util.copy_tree(common_files_dirpath, os.path.join(tmp_dirpath, "common_files")) - except: - pass - - zipf = zipfile.ZipFile(os.path.join(zipped_dirpath, "sbhsclient/scilab_codes_" + dirname + ".zip"), 'w', zipfile.ZIP_DEFLATED) - zipdir(tmp_dirpath, zipf, "scilab_codes_" + dirname) - zipf.close() - shutil.rmtree(tmp_dirpath) diff --git a/sbhs_server/pages/models.py b/sbhs_server/pages/models.py deleted file mode 100644 index 71a8362..0000000 --- a/sbhs_server/pages/models.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.db import models - -# Create your models here. diff --git a/sbhs_server/pages/tests.py b/sbhs_server/pages/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/sbhs_server/pages/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/sbhs_server/pages/views.py b/sbhs_server/pages/views.py deleted file mode 100644 index 4b88086..0000000 --- a/sbhs_server/pages/views.py +++ /dev/null @@ -1,41 +0,0 @@ -from django.shortcuts import render -from django.template.loader import render_to_string -from django.http import HttpResponseNotFound, HttpResponseServerError - -# Create your views here. - -def index(req): - return render(req, "pages/index.html") - -def about(req): - return render(req, "pages/about.html") - -def contact(req): - return render(req, "pages/contact.html") - -def info(req): - return render(req, "pages/info.html") - -def downloads(req): - return render(req, "pages/downloads.html") - -def theory(req): - return render(req, "pages/theory.html") - -def procedure(req): - return render(req, "pages/procedure.html") - -def experiments(req): - return render(req, "pages/experiments.html") - -def feedback(req): - return render(req, "pages/feedback.html") - -def quiz(req): - return render(req, "pages/quiz.html") - -def e404(req): - return HttpResponseNotFound(render_to_string('pages/e404.html')) - -def e500(req): - return HttpResponseServerError(render_to_string('pages/e500.html')) diff --git a/sbhs_server/password/__init__.py b/sbhs_server/password/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/sbhs_server/password/__init__.py +++ /dev/null diff --git a/sbhs_server/password/admin.py b/sbhs_server/password/admin.py deleted file mode 100644 index 8c38f3f..0000000 --- a/sbhs_server/password/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/sbhs_server/password/models.py b/sbhs_server/password/models.py deleted file mode 100644 index 71a8362..0000000 --- a/sbhs_server/password/models.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.db import models - -# Create your models here. diff --git a/sbhs_server/password/tests.py b/sbhs_server/password/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/sbhs_server/password/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/sbhs_server/password/views.py b/sbhs_server/password/views.py deleted file mode 100644 index 6659998..0000000 --- a/sbhs_server/password/views.py +++ /dev/null @@ -1,83 +0,0 @@ -from django.shortcuts import render, redirect -from sbhs_server.tables.models import Account -from django.contrib import messages -from sbhs_server.helpers import simple_encrypt -from sbhs_server.pages.views import index as INDEX_PAGE -import datetime - -# Create your views here. - -def new(req): - return render(req, 'password/new.html') - -def password_token(username): - return simple_encrypt.encrypt(username + ",,," + str(datetime.datetime.now())) - -def email(req): - email = req.POST.get("email") - - account = Account.objects.filter(email=email) - - if len(account) == 1: - account[0].send_password_link(password_token(account[0].username)) - messages.add_message(req, messages.SUCCESS, "Password reset link has been sent to your email address.") - return redirect(INDEX_PAGE) - -def validate_token(req, token): - try: - data = simple_encrypt.decrypt(token) - except: - messages.add_message(req, messages.ERROR, "Invalid link") - return redirect(INDEX_PAGE), False - - data = data.split(",,,") - if len(data) != 2: - messages.add_message(req, messages.ERROR, "Invalid link") - return redirect(INDEX_PAGE), False - - return data, True - -def edit(req, token): - data, flag = validate_token(req, token) - if not flag: - return data - - timediff = datetime.datetime.now() - datetime.datetime.strptime(data[1], "%Y-%m-%d %H:%M:%S.%f") - - if timediff.total_seconds() < 7200: - return render(req, "password/edit.html", {"token": token}) - else: - messages.add_message(req, messages.ERROR, "The reset link is expired.") - return redirect(INDEX_PAGE) - -def update(req, token): - data, flag = validate_token(req, token) - if not flag: - return data - - timediff = datetime.datetime.now() - datetime.datetime.strptime(data[1], "%Y-%m-%d %H:%M:%S.%f") - - if timediff.total_seconds() < 7200: - username = data[0] - account = Account.objects.filter(username=username) - if len(account) == 1: - error = "" - if req.POST.get("email") != account[0].email: - error = "Invalid email" - if req.POST.get("password") != req.POST.get("confirm"): - error = "Passwords do not match" - - if error != "": - messages.add_message(req, messages.ERROR, error) - return redirect(INDEX_PAGE) - - account[0].set_password(req.POST.get("password")) - account[0].save() - messages.add_message(req, messages.SUCCESS, "Password changed successfully") - return redirect(INDEX_PAGE) - else: - messages.add_message(req, messages.ERROR, "Invalid link") - return redirect(INDEX_PAGE) - else: - messages.add_message(req, messages.ERROR, "The reset link is expired.") - return redirect(INDEX_PAGE)
\ No newline at end of file diff --git a/sbhs_server/settings.py b/sbhs_server/settings.py index 3782f7f..b690e83 100644 --- a/sbhs_server/settings.py +++ b/sbhs_server/settings.py @@ -49,19 +49,19 @@ INSTALLED_APPS = ( 'django.contrib.messages', 'django.contrib.staticfiles', - 'south', + #'south', 'undelete', #'yaksh', 'taggit', - 'sbhs_server.account', - 'sbhs_server.admin', - 'sbhs_server.experiment', - 'sbhs_server.pages', - 'sbhs_server.password', - 'sbhs_server.slot', + 'account', + 'myadmin', + 'experiment', + 'pages', + 'password', + 'slot', 'sbhs_server.tables', - 'sbhs_server.webcam', + 'webcam', ) MIDDLEWARE_CLASSES = ( @@ -149,10 +149,27 @@ if is_production: else: STATIC_URL = '/static/' -TEMPLATE_DIRS = ( - os.path.join(BASE_DIR, 'templates/'), -) - +# TEMPLATE_DIRS = ( +# os.path.join(BASE_DIR, 'pages/templates/'), +# ) + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ + os.path.join(BASE_DIR, 'templates'), + ], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] import warnings warnings.filterwarnings( diff --git a/sbhs_server/slot/__init__.py b/sbhs_server/slot/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/sbhs_server/slot/__init__.py +++ /dev/null diff --git a/sbhs_server/slot/admin.py b/sbhs_server/slot/admin.py deleted file mode 100644 index 8c38f3f..0000000 --- a/sbhs_server/slot/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/sbhs_server/slot/migrations/0001_slot_timing_data.py b/sbhs_server/slot/migrations/0001_slot_timing_data.py deleted file mode 100644 index 158f201..0000000 --- a/sbhs_server/slot/migrations/0001_slot_timing_data.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime -from south.db import db -from south.v2 import DataMigration -from django.db import models -from sbhs_server.tables.models import Slot - -class Migration(DataMigration): - - def forwards(self, orm): - # "Write your forwards methods here." - # Note: Don't use "from appname.models import ModelName". - # Use orm.ModelName to refer to models in this application, - # and orm['appname.ModelName'] for models in other applications. - for i in xrange(24): - Slot.objects.create(start_hour=i, end_hour=i, start_minute=0, end_minute=55) - - def backwards(self, orm): - # "Write your backwards methods here." - for i in xrange(24): - Slot.objects.delete(i) - - - models = { - - } - - complete_apps = ['slot'] - symmetrical = True diff --git a/sbhs_server/slot/migrations/__init__.py b/sbhs_server/slot/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/sbhs_server/slot/migrations/__init__.py +++ /dev/null diff --git a/sbhs_server/slot/models.py b/sbhs_server/slot/models.py deleted file mode 100644 index 71a8362..0000000 --- a/sbhs_server/slot/models.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.db import models - -# Create your models here. diff --git a/sbhs_server/slot/tests.py b/sbhs_server/slot/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/sbhs_server/slot/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/sbhs_server/slot/views.py b/sbhs_server/slot/views.py deleted file mode 100644 index b137f93..0000000 --- a/sbhs_server/slot/views.py +++ /dev/null @@ -1,76 +0,0 @@ -from django.contrib.auth.decorators import login_required -from django.shortcuts import render, redirect -from django.contrib import messages -from sbhs_server.tables.models import Account, Slot, Booking -import datetime - -LIMIT = 2 - -@login_required(redirect_field_name=None) -def new(req): - cur_slots = Slot.current_slots(req.user.board.mid) - all_slots = Slot.get_free_slots(req.user.board.mid) - date = (datetime.datetime.now()).strftime("%Y-%m-%d") - return render(req, "slot/new.html", {"all_slots": all_slots, "cur_slots": cur_slots, "nowdate": date}) - -@login_required(redirect_field_name=None) -def show(req, date_string): - date = datetime.datetime.strptime(date_string, "%Y-%m-%d") - all_slots = Slot.get_free_slots_on(date, req.user.board.mid) - return render(req, "slot/show.html", {"all_slots": all_slots}) - -@login_required(redirect_field_name=None) -def create(req): - slot = Slot.objects.get(id=req.POST.get("slot")) - date_string = req.POST.get("date") - date = datetime.date.today() if date_string == "CURRENT" else datetime.datetime.strptime(date_string, "%Y-%m-%d") - all_slots = Slot.get_free_slots(req.user.board.mid) if date_string == "CURRENT" else Slot.get_free_slots_on(date, req.user.board.mid) - - if slot in all_slots: - if date_string == "CURRENT": - Booking.objects.create(slot=slot, account=req.user, booking_date=date) - messages.add_message(req, messages.SUCCESS, "Slot " + str(slot) + " booked successfully.") - else: - bookings = req.user.booking_set.select_related("slot").filter(booking_date__year=date.year, - booking_date__month=date.month, - booking_date__day=date.day) - if len(bookings) >= LIMIT: - messages.add_message(req, messages.ERROR, "Can't book more than " + str(LIMIT) + " slots in a day in advance.") - elif len(bookings) < LIMIT: - consecutive_check = True - for b in bookings: - if abs(b.slot.start_hour - slot.start_hour) <= 1: - consecutive_check = False - break - if not consecutive_check: - messages.add_message(req, messages.ERROR, "Can't book 2 consecutive slots in a day in advance.") - else: - Booking.objects.create(slot=slot, account=req.user, booking_date=date) - messages.add_message(req, messages.SUCCESS, "Slot " + str(slot) + " booked successfully.") - else: - messages.add_message(req, messages.ERROR, "Slot " + str(slot) + " already booked.") - - return redirect(index) - -@login_required(redirect_field_name=None) -def index(req): - bookings = req.user.booking_set.select_related("slot").order_by("booking_date") - - return render(req, "slot/index.html", {"bookings": reversed(bookings), - "now_time": datetime.datetime.now()}) - - -@login_required(redirect_field_name=None) -def delete(req, booking_id): - try: - booking = Booking.objects.select_related("slot").get(id=booking_id) - assert booking.account_id == req.user.id - if booking.start_time() > datetime.datetime.now(): - booking.delete() - messages.add_message(req, messages.SUCCESS, "Slot booking deleted successfully.") - else: - messages.add_message(req, messages.ERROR, "Slot time is over. Cannot delete this booking now.") - except: - messages.add_message(req, messages.ERROR, "Booking does not exist.") - - return redirect(index) diff --git a/sbhs_server/tables/migrations/0001_initial.py b/sbhs_server/tables/migrations/0001_initial.py deleted file mode 100644 index b6de197..0000000 --- a/sbhs_server/tables/migrations/0001_initial.py +++ /dev/null @@ -1,150 +0,0 @@ -# -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Adding model 'Board' - db.create_table(u'tables_board', ( - (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('trashed_at', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)), - ('mid', self.gf('django.db.models.fields.IntegerField')(unique=True)), - ('online', self.gf('django.db.models.fields.BooleanField')(default=True)), - ('created_at', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), - ('updated_at', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)), - )) - db.send_create_signal(u'tables', ['Board']) - - # Adding model 'Account' - db.create_table(u'tables_account', ( - (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('password', self.gf('django.db.models.fields.CharField')(max_length=128)), - ('last_login', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)), - ('trashed_at', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)), - ('name', self.gf('django.db.models.fields.CharField')(max_length=255)), - ('username', self.gf('django.db.models.fields.CharField')(unique=True, max_length=127)), - ('email', self.gf('django.db.models.fields.EmailField')(unique=True, max_length=255)), - ('is_active', self.gf('django.db.models.fields.BooleanField')(default=False)), - ('is_admin', self.gf('django.db.models.fields.BooleanField')(default=False)), - ('board', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['tables.Board'])), - ('created_at', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), - ('updated_at', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)), - )) - db.send_create_signal(u'tables', ['Account']) - - # Adding model 'Slot' - db.create_table(u'tables_slot', ( - (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('trashed_at', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)), - ('start_hour', self.gf('django.db.models.fields.IntegerField')()), - ('start_minute', self.gf('django.db.models.fields.IntegerField')()), - ('end_hour', self.gf('django.db.models.fields.IntegerField')()), - ('end_minute', self.gf('django.db.models.fields.IntegerField')()), - ('created_at', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), - ('updated_at', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)), - )) - db.send_create_signal(u'tables', ['Slot']) - - # Adding model 'Booking' - db.create_table(u'tables_booking', ( - (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('trashed_at', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)), - ('account', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['tables.Account'])), - ('slot', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['tables.Slot'])), - ('created_at', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), - ('updated_at', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)), - )) - db.send_create_signal(u'tables', ['Booking']) - - # Adding model 'Experiment' - db.create_table(u'tables_experiment', ( - (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('trashed_at', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)), - ('booking', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['tables.Booking'])), - ('log', self.gf('django.db.models.fields.CharField')(max_length=255)), - ('checksum', self.gf('django.db.models.fields.CharField')(max_length=127)), - ('created_at', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), - ('updated_at', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)), - )) - db.send_create_signal(u'tables', ['Experiment']) - - - def backwards(self, orm): - # Deleting model 'Board' - db.delete_table(u'tables_board') - - # Deleting model 'Account' - db.delete_table(u'tables_account') - - # Deleting model 'Slot' - db.delete_table(u'tables_slot') - - # Deleting model 'Booking' - db.delete_table(u'tables_booking') - - # Deleting model 'Experiment' - db.delete_table(u'tables_experiment') - - - models = { - u'tables.account': { - 'Meta': {'object_name': 'Account'}, - 'board': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Board']"}), - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - 'email': ('django.db.models.fields.EmailField', [], {'unique': 'True', 'max_length': '255'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'is_admin': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), - 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '127'}) - }, - u'tables.board': { - 'Meta': {'object_name': 'Board'}, - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'mid': ('django.db.models.fields.IntegerField', [], {'unique': 'True'}), - 'online': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - }, - u'tables.booking': { - 'Meta': {'object_name': 'Booking'}, - 'account': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Account']"}), - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'slot': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Slot']"}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - }, - u'tables.experiment': { - 'Meta': {'object_name': 'Experiment'}, - 'booking': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Booking']"}), - 'checksum': ('django.db.models.fields.CharField', [], {'max_length': '127'}), - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'log': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - }, - u'tables.slot': { - 'Meta': {'object_name': 'Slot'}, - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - 'end_hour': ('django.db.models.fields.IntegerField', [], {}), - 'end_minute': ('django.db.models.fields.IntegerField', [], {}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'start_hour': ('django.db.models.fields.IntegerField', [], {}), - 'start_minute': ('django.db.models.fields.IntegerField', [], {}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - } - } - - complete_apps = ['tables']
\ No newline at end of file diff --git a/sbhs_server/tables/migrations/0002_remove_experiment_checksum.py b/sbhs_server/tables/migrations/0002_remove_experiment_checksum.py deleted file mode 100644 index 4771abf..0000000 --- a/sbhs_server/tables/migrations/0002_remove_experiment_checksum.py +++ /dev/null @@ -1,78 +0,0 @@ -# -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Deleting field 'Experiment.checksum' - db.delete_column(u'tables_experiment', 'checksum') - - - def backwards(self, orm): - # Adding field 'Experiment.checksum' - db.add_column(u'tables_experiment', 'checksum', - self.gf('django.db.models.fields.CharField')(default='0', max_length=127), - keep_default=False) - - - models = { - u'tables.account': { - 'Meta': {'object_name': 'Account'}, - 'board': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Board']"}), - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - 'email': ('django.db.models.fields.EmailField', [], {'unique': 'True', 'max_length': '255'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'is_admin': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), - 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '127'}) - }, - u'tables.board': { - 'Meta': {'object_name': 'Board'}, - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'mid': ('django.db.models.fields.IntegerField', [], {'unique': 'True'}), - 'online': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - }, - u'tables.booking': { - 'Meta': {'object_name': 'Booking'}, - 'account': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Account']"}), - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'slot': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Slot']"}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - }, - u'tables.experiment': { - 'Meta': {'object_name': 'Experiment'}, - 'booking': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Booking']"}), - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'log': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - }, - u'tables.slot': { - 'Meta': {'object_name': 'Slot'}, - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - 'end_hour': ('django.db.models.fields.IntegerField', [], {}), - 'end_minute': ('django.db.models.fields.IntegerField', [], {}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'start_hour': ('django.db.models.fields.IntegerField', [], {}), - 'start_minute': ('django.db.models.fields.IntegerField', [], {}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - } - } - - complete_apps = ['tables']
\ No newline at end of file diff --git a/sbhs_server/tables/migrations/0003_add_field_Booking_booking_date.py b/sbhs_server/tables/migrations/0003_add_field_Booking_booking_date.py deleted file mode 100644 index c6c4ec1..0000000 --- a/sbhs_server/tables/migrations/0003_add_field_Booking_booking_date.py +++ /dev/null @@ -1,79 +0,0 @@ -# -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Adding field 'Booking.booking_date' - db.add_column(u'tables_booking', 'booking_date', - self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime(2014, 5, 11, 0, 0)), - keep_default=False) - - - def backwards(self, orm): - # Deleting field 'Booking.booking_date' - db.delete_column(u'tables_booking', 'booking_date') - - - models = { - u'tables.account': { - 'Meta': {'object_name': 'Account'}, - 'board': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Board']"}), - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - 'email': ('django.db.models.fields.EmailField', [], {'unique': 'True', 'max_length': '255'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'is_admin': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), - 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '127'}) - }, - u'tables.board': { - 'Meta': {'object_name': 'Board'}, - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'mid': ('django.db.models.fields.IntegerField', [], {'unique': 'True'}), - 'online': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - }, - u'tables.booking': { - 'Meta': {'object_name': 'Booking'}, - 'account': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Account']"}), - 'booking_date': ('django.db.models.fields.DateTimeField', [], {}), - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'slot': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Slot']"}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - }, - u'tables.experiment': { - 'Meta': {'object_name': 'Experiment'}, - 'booking': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Booking']"}), - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'log': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - }, - u'tables.slot': { - 'Meta': {'object_name': 'Slot'}, - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - 'end_hour': ('django.db.models.fields.IntegerField', [], {}), - 'end_minute': ('django.db.models.fields.IntegerField', [], {}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'start_hour': ('django.db.models.fields.IntegerField', [], {}), - 'start_minute': ('django.db.models.fields.IntegerField', [], {}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - } - } - - complete_apps = ['tables']
\ No newline at end of file diff --git a/sbhs_server/tables/migrations/0004_add_field_Experiment_checksum.py b/sbhs_server/tables/migrations/0004_add_field_Experiment_checksum.py deleted file mode 100644 index 7f17e89..0000000 --- a/sbhs_server/tables/migrations/0004_add_field_Experiment_checksum.py +++ /dev/null @@ -1,80 +0,0 @@ -# -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Adding field 'Experiment.checksum' - db.add_column(u'tables_experiment', 'checksum', - self.gf('django.db.models.fields.CharField')(default='NONE', max_length=255), - keep_default=False) - - - def backwards(self, orm): - # Deleting field 'Experiment.checksum' - db.delete_column(u'tables_experiment', 'checksum') - - - models = { - u'tables.account': { - 'Meta': {'object_name': 'Account'}, - 'board': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Board']"}), - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - 'email': ('django.db.models.fields.EmailField', [], {'unique': 'True', 'max_length': '255'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'is_admin': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), - 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '127'}) - }, - u'tables.board': { - 'Meta': {'object_name': 'Board'}, - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'mid': ('django.db.models.fields.IntegerField', [], {'unique': 'True'}), - 'online': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - }, - u'tables.booking': { - 'Meta': {'object_name': 'Booking'}, - 'account': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Account']"}), - 'booking_date': ('django.db.models.fields.DateTimeField', [], {}), - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'slot': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Slot']"}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - }, - u'tables.experiment': { - 'Meta': {'object_name': 'Experiment'}, - 'booking': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Booking']"}), - 'checksum': ('django.db.models.fields.CharField', [], {'default': "'NONE'", 'max_length': '255'}), - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'log': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - }, - u'tables.slot': { - 'Meta': {'object_name': 'Slot'}, - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - 'end_hour': ('django.db.models.fields.IntegerField', [], {}), - 'end_minute': ('django.db.models.fields.IntegerField', [], {}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'start_hour': ('django.db.models.fields.IntegerField', [], {}), - 'start_minute': ('django.db.models.fields.IntegerField', [], {}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - } - } - - complete_apps = ['tables']
\ No newline at end of file diff --git a/sbhs_server/tables/migrations/0005_load_boards_data.py b/sbhs_server/tables/migrations/0005_load_boards_data.py deleted file mode 100644 index 8ce61a7..0000000 --- a/sbhs_server/tables/migrations/0005_load_boards_data.py +++ /dev/null @@ -1,75 +0,0 @@ -# -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models -from sbhs_server.tables.models import Board - -class Migration(SchemaMigration): - - def forwards(self, orm): - for i in xrange(1, 41): - Board.objects.create(id=i, mid=i) - - def backwards(self, orm): - Board.objects.filter(mid__in=range(1,41)).delete() - - models = { - u'tables.account': { - 'Meta': {'object_name': 'Account'}, - 'board': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Board']"}), - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - 'email': ('django.db.models.fields.EmailField', [], {'unique': 'True', 'max_length': '255'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'is_admin': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), - 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '127'}) - }, - u'tables.board': { - 'Meta': {'object_name': 'Board'}, - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'mid': ('django.db.models.fields.IntegerField', [], {'unique': 'True'}), - 'online': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - }, - u'tables.booking': { - 'Meta': {'object_name': 'Booking'}, - 'account': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Account']"}), - 'booking_date': ('django.db.models.fields.DateTimeField', [], {}), - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'slot': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Slot']"}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - }, - u'tables.experiment': { - 'Meta': {'object_name': 'Experiment'}, - 'booking': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Booking']"}), - 'checksum': ('django.db.models.fields.CharField', [], {'default': "'NONE'", 'max_length': '255'}), - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'log': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - }, - u'tables.slot': { - 'Meta': {'object_name': 'Slot'}, - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - 'end_hour': ('django.db.models.fields.IntegerField', [], {}), - 'end_minute': ('django.db.models.fields.IntegerField', [], {}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'start_hour': ('django.db.models.fields.IntegerField', [], {}), - 'start_minute': ('django.db.models.fields.IntegerField', [], {}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - } - } - - complete_apps = ['tables']
\ No newline at end of file diff --git a/sbhs_server/tables/migrations/0006_load_sample_users_data.py b/sbhs_server/tables/migrations/0006_load_sample_users_data.py deleted file mode 100644 index 5f287ac..0000000 --- a/sbhs_server/tables/migrations/0006_load_sample_users_data.py +++ /dev/null @@ -1,84 +0,0 @@ -# -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models -from sbhs_server.tables.models import Account - -class Migration(SchemaMigration): - - def forwards(self, orm): - for i in xrange(1, 41): - account = Account( - name="Sample User %d" % i, - username="suser%d" % i, - email="suser%d@os-hardware.in" % i, - board_id=i, - is_active=1 - ) - account.set_password("suser%d%d" % (i, 4229)) - account.save() - - def backwards(self, orm): - for i in xrange(1, 41): - Account.objects.filter(username="suser%d" % i).delete() - - models = { - u'tables.account': { - 'Meta': {'object_name': 'Account'}, - 'board': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Board']"}), - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - 'email': ('django.db.models.fields.EmailField', [], {'unique': 'True', 'max_length': '255'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'is_admin': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), - 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '127'}) - }, - u'tables.board': { - 'Meta': {'object_name': 'Board'}, - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'mid': ('django.db.models.fields.IntegerField', [], {'unique': 'True'}), - 'online': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - }, - u'tables.booking': { - 'Meta': {'object_name': 'Booking'}, - 'account': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Account']"}), - 'booking_date': ('django.db.models.fields.DateTimeField', [], {}), - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'slot': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Slot']"}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - }, - u'tables.experiment': { - 'Meta': {'object_name': 'Experiment'}, - 'booking': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tables.Booking']"}), - 'checksum': ('django.db.models.fields.CharField', [], {'default': "'NONE'", 'max_length': '255'}), - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'log': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - }, - u'tables.slot': { - 'Meta': {'object_name': 'Slot'}, - 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - 'end_hour': ('django.db.models.fields.IntegerField', [], {}), - 'end_minute': ('django.db.models.fields.IntegerField', [], {}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'start_hour': ('django.db.models.fields.IntegerField', [], {}), - 'start_minute': ('django.db.models.fields.IntegerField', [], {}), - 'trashed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) - } - } - - complete_apps = ['tables']
\ No newline at end of file diff --git a/sbhs_server/tables/migrations/__init__.py b/sbhs_server/tables/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/sbhs_server/tables/migrations/__init__.py +++ /dev/null diff --git a/sbhs_server/tables/models.py b/sbhs_server/tables/models.py index 7c18298..5be67aa 100644 --- a/sbhs_server/tables/models.py +++ b/sbhs_server/tables/models.py @@ -5,7 +5,7 @@ import random, datetime, os from sbhs_server.helpers import mailer, simple_encrypt from django.contrib.auth.models import UserManager from sbhs_server import settings -from yaksh.models import Profile +#from yaksh.models import Profile # Create your models here. class Board(TrashableMixin): diff --git a/sbhs_server/urls.py b/sbhs_server/urls.py index 3c7ce0b..8dd9d9e 100644 --- a/sbhs_server/urls.py +++ b/sbhs_server/urls.py @@ -1,67 +1,22 @@ -from django.conf.urls import patterns, include, url - -# from django.contrib import admin +from django.conf.urls import include, url +#from django.contrib import admin # admin.autodiscover() -urlpatterns = patterns('', +urlpatterns = [ # Examples: # url(r'^$', 'sbhs_server.views.home', name='home'), # url(r'^blog/', include('blog.urls')), #url(r'^admin/', include(admin.site.urls)), - url(r'^$', 'sbhs_server.pages.views.index'), - url(r'^exam/', include('yaksh.urls')), - url(r'^about/?$', 'sbhs_server.pages.views.about'), - url(r'^contact/?$', 'sbhs_server.pages.views.contact'), - url(r'^info/?$', 'sbhs_server.pages.views.info'), - url(r'^downloads/?$', 'sbhs_server.pages.views.downloads'), - url(r'^theory/?$', 'sbhs_server.pages.views.theory'), - url(r'^procedure/?$', 'sbhs_server.pages.views.procedure'), - url(r'^experiments/?$', 'sbhs_server.pages.views.experiments'), - url(r'^feedback/?$', 'sbhs_server.pages.views.feedback'), - url(r'^quiz/?$', 'sbhs_server.pages.views.quiz'), - - url(r'^enter/?$', 'sbhs_server.account.views.index'), - url(r'^account/create/?$', 'sbhs_server.account.views.create'), - url(r'^account/confirm/(.*)/?$', 'sbhs_server.account.views.confirm'), - url(r'^login/?$', 'sbhs_server.account.views.login'), - url(r'^logout/?$', 'sbhs_server.account.views.logout'), - url(r'^home/?$', 'sbhs_server.account.views.home'), - - url(r'^password/?$', 'sbhs_server.password.views.new'), - url(r'^password/link/?$', 'sbhs_server.password.views.email'), - url(r'^password/edit/(.*)/?$', 'sbhs_server.password.views.edit'), - url(r'^password/update/(.*)/?$', 'sbhs_server.password.views.update'), - - url(r'^slot/?$', 'sbhs_server.slot.views.index'), - url(r'^slot/new/?$', 'sbhs_server.slot.views.new'), - url(r'^slot/show/(.*)/?$', 'sbhs_server.slot.views.show'), - url(r'^slot/create/?$', 'sbhs_server.slot.views.create'), - url(r'^slot/delete/([0-9]+)/?$', 'sbhs_server.slot.views.delete'), - - # Following to are for backward incompatibility - url(r'^hardware/checkconnection/?$', 'sbhs_server.experiment.views.check_connection'), - url(r'^hardware/clientversion/?$', 'sbhs_server.experiment.views.client_version'), - - url(r'^experiment/check_connection/?$', 'sbhs_server.experiment.views.check_connection'), - url(r'^experiment/client_version/?$', 'sbhs_server.experiment.views.client_version'), - url(r'^experiment/initiate/?$', 'sbhs_server.experiment.views.initiation'), - url(r'^experiment/experiment/?$', 'sbhs_server.experiment.views.experiment'), - url(r'^experiment/reset/?$', 'sbhs_server.experiment.views.reset'), - url(r'^experiment/logs/?$', 'sbhs_server.experiment.views.logs'), - url(r'^experiment/logs/([0-9]+)/(.+)?$', 'sbhs_server.experiment.views.download_log'), - - url(r'^show_video/?$', 'sbhs_server.webcam.views.show_video'), - url(r'^reload_image/(.*)/?$', 'sbhs_server.webcam.views.reload'), - - url(r'^admin/?$', 'sbhs_server.admin.views.index'), - url(r'^admin/bookings/?$', 'sbhs_server.admin.views.booking_index'), - url(r'^admin/webcam/?$', 'sbhs_server.admin.views.webcam_index'), - url(r'^admin/profile/([0-9]+)/?$', 'sbhs_server.admin.views.profile'), - url(r'^admin/webcam/([0-9]+)/?$', 'sbhs_server.webcam.views.show_video_to_admin'), - url(r'^admin/toggle_allotment_mode/?$', 'sbhs_server.admin.views.toggle_allotment_mode'), - url(r'^admin/validate_log_file/?$', 'sbhs_server.experiment.views.validate_log_file'), -) - -handler404 = 'sbhs_server.pages.views.e404' -handler500 = 'sbhs_server.pages.views.e500' + url(r'^', include('pages.urls')), + #url(r'^exam/', include('yaksh.urls')), + url(r'^', include('account.urls')), + url(r'^password/', include('password.urls')), + url(r'^slot/', include('slot.urls')), + url(r'^', include('experiment.urls')), + url(r'^', include('webcam.urls')), + url(r'^', include('myadmin.urls')), +] + +handler404 = 'pages.views.e404' +handler500 = 'pages.views.e500' diff --git a/sbhs_server/webcam/__init__.py b/sbhs_server/webcam/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/sbhs_server/webcam/__init__.py +++ /dev/null diff --git a/sbhs_server/webcam/admin.py b/sbhs_server/webcam/admin.py deleted file mode 100644 index 8c38f3f..0000000 --- a/sbhs_server/webcam/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/sbhs_server/webcam/management/__init__.py b/sbhs_server/webcam/management/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/sbhs_server/webcam/management/__init__.py +++ /dev/null diff --git a/sbhs_server/webcam/management/commands/__init__.py b/sbhs_server/webcam/management/commands/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/sbhs_server/webcam/management/commands/__init__.py +++ /dev/null diff --git a/sbhs_server/webcam/management/commands/reload_images.py b/sbhs_server/webcam/management/commands/reload_images.py deleted file mode 100644 index 5b735cb..0000000 --- a/sbhs_server/webcam/management/commands/reload_images.py +++ /dev/null @@ -1,12 +0,0 @@ -from django.core.management.base import BaseCommand -from sbhs_server.tables.models import Board -from sbhs_server.webcam.views import load_image - -class Command(BaseCommand): - args = '' - help = 'Reloads images for all SBHS machines' - - def handle(self, *args, **options): - boards = Board.objects.all() - for b in boards: - load_image(b.mid) diff --git a/sbhs_server/webcam/models.py b/sbhs_server/webcam/models.py deleted file mode 100644 index 71a8362..0000000 --- a/sbhs_server/webcam/models.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.db import models - -# Create your models here. diff --git a/sbhs_server/webcam/tests.py b/sbhs_server/webcam/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/sbhs_server/webcam/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/sbhs_server/webcam/views.py b/sbhs_server/webcam/views.py deleted file mode 100644 index d765730..0000000 --- a/sbhs_server/webcam/views.py +++ /dev/null @@ -1,47 +0,0 @@ -from django.shortcuts import render -from django.contrib.auth.decorators import login_required -import os, requests -from sbhs_server import settings -from django.http import HttpResponse -from sbhs_server.admin.views import checkadmin -from sbhs_server.tables.models import Board -# Create your views here. -# - -def load_image(mid): -# for images on server 15, it will gstream the photos on reload - if int(mid) in range(8,17): - command = "streamer -q -f jpeg -c /dev/video" + str(mid) - command += " -o " + settings.WEBCAM_DIR + "/image" + str(mid) + ".jpeg" - os.system(command) - - else: - take_snapshot = requests.get("http://10.102.152.16:8080/webcams/%d/take_snapshot" % int(mid)) - get_image_link = "http://10.102.152.16:8080/webcams/%d/get_image_data" % int(mid) - - command = "curl -s %s > %s/image%d.jpeg" % (get_image_link, str(settings.WEBCAM_DIR), int(mid)) - os.system(command) -def reload(req, mid): - - load_image(mid) - return HttpResponse("") - -@login_required(redirect_field_name=None) -def show_video(req): - board = req.user.board - - image_link = board.image_link() - mid = str(board.mid) - -# image_link = board.image_link() - - return render(req, "webcam/show_video.html", {"image_link": image_link, "mid": mid}) - - -@login_required(redirect_field_name=None) -def show_video_to_admin(req, mid): - checkadmin(req) - board = Board.objects.get(mid=int(mid)) - image_link = board.image_link() - mid = str(board.mid) - return render(req, "webcam/show_video.html", {"image_link": image_link, "mid": mid}) diff --git a/sbhs_server/webcam/views.py-bkup b/sbhs_server/webcam/views.py-bkup deleted file mode 100644 index d765730..0000000 --- a/sbhs_server/webcam/views.py-bkup +++ /dev/null @@ -1,47 +0,0 @@ -from django.shortcuts import render -from django.contrib.auth.decorators import login_required -import os, requests -from sbhs_server import settings -from django.http import HttpResponse -from sbhs_server.admin.views import checkadmin -from sbhs_server.tables.models import Board -# Create your views here. -# - -def load_image(mid): -# for images on server 15, it will gstream the photos on reload - if int(mid) in range(8,17): - command = "streamer -q -f jpeg -c /dev/video" + str(mid) - command += " -o " + settings.WEBCAM_DIR + "/image" + str(mid) + ".jpeg" - os.system(command) - - else: - take_snapshot = requests.get("http://10.102.152.16:8080/webcams/%d/take_snapshot" % int(mid)) - get_image_link = "http://10.102.152.16:8080/webcams/%d/get_image_data" % int(mid) - - command = "curl -s %s > %s/image%d.jpeg" % (get_image_link, str(settings.WEBCAM_DIR), int(mid)) - os.system(command) -def reload(req, mid): - - load_image(mid) - return HttpResponse("") - -@login_required(redirect_field_name=None) -def show_video(req): - board = req.user.board - - image_link = board.image_link() - mid = str(board.mid) - -# image_link = board.image_link() - - return render(req, "webcam/show_video.html", {"image_link": image_link, "mid": mid}) - - -@login_required(redirect_field_name=None) -def show_video_to_admin(req, mid): - checkadmin(req) - board = Board.objects.get(mid=int(mid)) - image_link = board.image_link() - mid = str(board.mid) - return render(req, "webcam/show_video.html", {"image_link": image_link, "mid": mid}) |