From 0d5fa7b288399aada1bad5c8cf5c9e43e9461fe5 Mon Sep 17 00:00:00 2001 From: prshnt19 Date: Mon, 13 Apr 2020 02:24:27 +0530 Subject: [PATCH] added setting up instructions in README --- README.rst | 76 ++++++++++++++++++++++++++++++++++++++++++ shell/views.py | 1 + sympy_live/settings.py | 2 +- templates/base.html | 21 ++++++++++++ 4 files changed, 99 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index c66c498..f1f59bb 100644 --- a/README.rst +++ b/README.rst @@ -48,6 +48,82 @@ We use submodules to include external libraries in sympy-live:: This is sufficient to clone appropriate repositories in correct versions into sympy-live (see git documentation on submodules for information). +Setting Up for Testing PR 144 +----------------------------- +Here are the steps to be followed for testing the PR +https://github.com/sympy/sympy-live/pull/144. The following are +the steps to be followed for Ubuntu. The steps for other Operating Systems +could be reproduced similiarly. + +You must have python3 installed. You can check your version by:: + + $ python3 -V + +The version must be greater than 3.4. If not present you can install it by:: + + $ sudo apt install python3 + +You need to create the virtual environment and activate it:: + + $ sudo apt-get install python3-venv + $ python3 -m venv env + $ source env/bin/activate + +SymPy Live uses MySQL for database purpose. So you need to setup mysql:: + + $ sudo apt-get install mysql-server + $ sudo apt-get install libmysqlclient-dev + $ sudo apt-get install python3-dev + $ sudo systemctl start mysql + $ sudo mysql + +This will open mysql. You will now have to create a new database with name +{database_name}. Create a new user {user_name} and password {user_password}. +Grant all previleges to {user_name} on {database_name}:: + + mysql> CREATE DATABASE {database_name}; + mysql> UPDATE mysql.user SET authentication_string = PASSWORD('{user_password}') WHERE User = '{user_name}'; + mysql> FLUSH PRIVILEGES; + mysql> GRANT ALL PRIVILEGES ON *.* TO '{user_name}'@'localhost' IDENTIFIED BY '{user_password}'; + +To ensure that the database server launches after a reboot, run the following command:: + + $ sudo systemctl enable mysql + +Now in settings.py set up the database for MySQL:: + + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'HOST': '127.0.0.1', # DataBase's IP address + 'PORT': '3306', + 'NAME': '{database_name}', + 'USER': '{user_name}', + 'PASSWORD': '{user_password}', + } + } + +Install dependencies from requirements.txt:: + + $ pip install -r requirements.txt + +Migrate the changes so that all DataBase tables are created:: + + $ python3 manage.py makemigrations + $ python3 manage.py migrate + $ python3 manage.py createsuperuser # Admin. It will be used to login into admin panel + +And finally you need to run the server:: + + $ python3 manage.py runserver + +This runs the site on localhost. But before using the SymPy Live go to +admin panel http://127.0.0.1:8000/admin/. Login using the Admin details. +There you need to create new user 'anonymous'. You can keep password +anything but name must be exactly same as 'anonymous'. + +Congratulations, now you can test the SymPy Live. + Development server ------------------ diff --git a/shell/views.py b/shell/views.py index 8bd2549..6e7e2c8 100644 --- a/shell/views.py +++ b/shell/views.py @@ -677,6 +677,7 @@ def index(request): context = { # 'server_software': os.environ['SERVER_SOFTWARE'], + 'hosted_on_app_engine': os.getenv('GAE_APPLICATION', None), 'application_version': LIVE_VERSION, 'date_deployed': LIVE_DEPLOYED, 'python_version': sys.version, diff --git a/sympy_live/settings.py b/sympy_live/settings.py index 8d05801..28481ca 100644 --- a/sympy_live/settings.py +++ b/sympy_live/settings.py @@ -105,7 +105,7 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', - 'HOST': '127.0.0.1', # DB's IP address + 'HOST': '127.0.0.1', # DataBase's IP address 'PORT': '3306', 'NAME': 'sympyDB', 'USER': 'root', diff --git a/templates/base.html b/templates/base.html index 69d94a7..7bcb409 100644 --- a/templates/base.html +++ b/templates/base.html @@ -5,6 +5,7 @@ {% block title %}{% endblock %} + {% if hosted_on_app_engine %} @@ -19,6 +20,22 @@ + {% else %} + + + + + + + + + + + + + + + {% endif %}