summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCruiseDevice2018-11-01 19:38:29 +0530
committerCruiseDevice2018-11-01 19:44:59 +0530
commita7553c125964748830712b6aee58189475547ee0 (patch)
treec93c5d326fe23b61cbfdb2aa962e0997f0eaa76f
parent4050ec641b8cc4fef8d8a757c27bde0802b5c3e9 (diff)
downloadsbhs_server-a7553c125964748830712b6aee58189475547ee0.tar.gz
sbhs_server-a7553c125964748830712b6aee58189475547ee0.tar.bz2
sbhs_server-a7553c125964748830712b6aee58189475547ee0.zip
Make changes in README and add conditions in webcam views
-rw-r--r--README.rst56
-rw-r--r--sbhs/views.py15
2 files changed, 42 insertions, 29 deletions
diff --git a/README.rst b/README.rst
index 8d686a7..2bd4b8b 100644
--- a/README.rst
+++ b/README.rst
@@ -5,48 +5,60 @@ INSTALLATION GUIDE
~~~~~~~~~~~~~~~~~~
1. Clone from the SBHS Github server ::
- https://github.com/CruiseDevice/sbhs_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. Add ``'crispy_forms'`` to INSTALLED_APPS in ``settings.py``
+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. Enter the admin ``username`` and ``email`` you want, then enter the admin
+ ``password``.
+
+8. Create moderator group by using command ::
-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``.
+9. Update the connected boards by using command ::
+
+ python manage.py update_boards
+
+10. Fill in the necessary information in the file
+
+ ``sbhs_server/credentials.py``.
+
+11. In ``sbhs_server/settings.py``, fill in the following details -
-9. In ``sbhs_server/settings.py``, fill in the following details -
+ a. Make sure the sbhs_api (https://github.com/CruiseDevice/sbhs_api) is
+ hosted on the slave machines to which SBHS devices are connected.
- 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 SBHS devices are connected to a cluster of slave machines
+ and/or master machine (where the Django server is hosted),
+ enter the slave machine IPs and port (if hosted on a specific port)
+ in the variable ``SBHS_API_IPS``.
- 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.
+12. Run the server by using the command ::
-10. Run the server by using the command ::
- python manage.py runserver
+ python manage.py runserver
-11. Once the server is running successfully, go to the URL ``http://localhost:8000/account/enter/``
+13. Once the server is running successfully, go to the URL ``http://localhost:8000``
To create a normal user, just fill the registration form and submit. You can
the login with the created normal user.
@@ -55,8 +67,8 @@ source myenv/bin/activate
* 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 ?``
+ * Login into admin by using credentials you entered while creating admin
+ in ``step 6``
* 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.
diff --git a/sbhs/views.py b/sbhs/views.py
index f486cfb..f0da87d 100644
--- a/sbhs/views.py
+++ b/sbhs/views.py
@@ -904,10 +904,10 @@ def show_video(request):
user = request.user
context = {}
board = UserBoard.objects.filter(user=user).order_by("id").last()
- image_link = board.board.image_link()
- mid = str(board.board.mid)
- context["image_link"] = image_link
- context["mid"] = mid
+ if board:
+ image_link = board.board.image_link()
+ context["image_link"] = image_link
+ context["mid"] = board.board.mid
return render(request, 'webcam/show_video.html',context)
@login_required
@@ -920,8 +920,9 @@ def show_video_to_moderator(request,mid):
if not is_moderator(user):
raise Http404("You are not allowed to view this page.")
else:
- board = Board.objects.get(mid=mid)
- image_link = board.image_link()
- context["image_link"] = image_link
+ board = Board.objects.filter(mid=mid).order_by("id").last()
+ if board:
+ image_link = board.image_link()
+ context["image_link"] = image_link
context["mid"] = mid
return render(request, 'webcam/show_video.html',context)