From 4050ec641b8cc4fef8d8a757c27bde0802b5c3e9 Mon Sep 17 00:00:00 2001 From: CruiseDevice Date: Thu, 1 Nov 2018 17:35:00 +0530 Subject: Update documentation in README and Add webcam features in SBHS - Admin can view all SBHS live feeds. - User can view their allocated live feed. - Request machine change modal fix in base.html. --- README.rst | 62 +++++++++++++++++++++++---- sbhs/models.py | 18 +++++--- sbhs/templates/base.html | 27 ++++++++++-- sbhs/templates/dashboard/all_images.html | 18 +++++++- sbhs/templates/dashboard/show_all_boards.html | 2 +- sbhs/templates/webcam/show_video.html | 54 +++++++++++++++++++++++ sbhs/urls.py | 5 +++ sbhs/views.py | 34 ++++++++++++++- sbhs_server/settings.py | 11 ++++- 9 files changed, 207 insertions(+), 24 deletions(-) create mode 100644 sbhs/templates/webcam/show_video.html diff --git a/README.rst b/README.rst index 2e84876..8d686a7 100644 --- a/README.rst +++ b/README.rst @@ -4,20 +4,64 @@ SINGLE BOARD HEATER SYSTEM INSTALLATION GUIDE ~~~~~~~~~~~~~~~~~~ -1. Clone from github server - https://github.com/CruiseDevice/sbhs_server +1. Clone from the SBHS Github server :: + https://github.com/CruiseDevice/sbhs_server + 2. Create a virtual environment, using command `virtualenv` and activate - the virtualenv. We recommend using Python 3.:: - virtualenv myenv -p python3 - source myenv/bin/activate + the virtualenv. We recommend using Python 3:: +virtualenv myenv -p python3 +source myenv/bin/activate 3. Install necessary packages from requirements.txt using command:: pip install -r requirements.txt -4. Make first migrations by using the commands :: - python manage..py makemigrations - python manage..py migrate -5. Please fill in the necessary information in the file + +4. Add ``'crispy_forms'`` to INSTALLED_APPS in ``settings.py`` + +5. Make first migrations by using the commands :: + python manage.py makemigrations + python manage.py migrate + +6. Create superuser by using the command :: + python manage.py createsuperuser + + Enter the admin ``username`` and ``email`` you want, then enter the admin + ``password``. + +7. Create moderator group by using command :: + python manage.py create_moderator + +8. Please fill in the necessary information in the file ``sbhs_server/credentials.py``. -6. In ``sbhs_server/settings.py``, fill in the following details - + +9. In ``sbhs_server/settings.py``, fill in the following details - + a. If SBHS devices are connected to a cluster of Raspberry Pis or other similar machines, enter the raspberry pi IPs in the variable ``RASP_PI_IP``. + + b. If the SBHS devices are connected directly to the main server through + USB, Keep ``RASP_PI_IP`` empty and the server will detect devices + automatically. + +10. Run the server by using the command :: + python manage.py runserver + +11. Once the server is running successfully, go to the URL ``http://localhost:8000/account/enter/`` + + To create a normal user, just fill the registration form and submit. You can + the login with the created normal user. + + To create a moderator :: + * First create a normal user by filling the registration form and submitting + it + * Then go to django admin by entering URL ``http://localhost:8000/admin`` + * Login into admin my using credentials you entered while creating admin + in ``step ?`` + * Go to the ``profile`` section and click on the user you just created. + * Tick is_moderator checkbox and click on save. + * Exit the admin by loggin out of it. + + Now you have created a moderator account. With moderator account you can + view state of all the SBHS connected, all the logs of the all the users, + all the slots booked by the users, and also the profile of each SBHS. + diff --git a/sbhs/models.py b/sbhs/models.py index 2cdbb90..506ba14 100644 --- a/sbhs/models.py +++ b/sbhs/models.py @@ -66,6 +66,13 @@ class Board(models.Model): self.userboard_set.all().count() ) + def image_link(self): + """ + Function to show the image obtained from webcam + """ + return settings.WEBCAM_STATIC_DIR + "image" + '0' + str(self.mid) \ + + ".jpeg" + class Profile(models.Model): """ Profile model to store user details. @@ -167,12 +174,11 @@ class UserBoard(models.Model): def __str__(self): return '{0}: {1}'.format(self.user.username, self.board.mid) -class Webcam(): - - def __init__(self): - pass +class Webcam(object): - def load_image(className,mid): + @staticmethod + def load_image(mid): command = "timeout 2s streamer -q -f jpeg -c /dev/video" + '0'+str(mid) - command += " -o " + settings.WEBCAM_DIR + "image" + '0'+str(mid) + ".jpeg" + command += " -o " + settings.WEBCAM_DIR + "image" + '0'+str(mid) \ + + ".jpeg" os.system(command) \ No newline at end of file diff --git a/sbhs/templates/base.html b/sbhs/templates/base.html index 099488b..65f05b9 100644 --- a/sbhs/templates/base.html +++ b/sbhs/templates/base.html @@ -20,6 +20,7 @@ {% endblock %}
+