This is the nadooit execution manegment system.
It forms the interface to the system, hosts the website, and provides the API.
- Fork the package
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
-
Install github desktop (https://desktop.github.com/)
-
Clone the repository
-
Install docker (https://www.docker.com/)
-
Install docker-compose
-
Install newst version of python (https://www.python.org/downloads/)
-
Install update pip (pip install --upgrade pip) 6.1 open cmd and type pip install --upgrade pip
-
use the following command to install the requirements
Mac:
docker compose -f docker-compose-dev-MAC_SQLite.yml build docker-compose -f docker-compose-dev-MAC_SQLite.yml run --rm app python manage.py makemigrations docker-compose -f docker-compose-dev-MAC_SQLite.yml run --rm app python manage.py migrate docker-compose -f docker-compose-dev-MAC_SQLite.yml run --rm app python manage.py collectstatic --no-input docker-compose -f docker-compose-dev-MAC_SQLite.yml run --rm app python manage.py import_templates docker-compose -f docker-compose-dev-MAC_SQLite.yml run --rm app python manage.py createsuperuser docker-compose -f docker-compose-dev-MAC_SQLite.yml up
Windows:
docker compose -f docker-compose-dev-WIN_SQLite.yml build docker-compose -f docker-compose-dev-WIN_SQLite.yml run --rm app python manage.py makemigrations docker-compose -f docker-compose-dev-WIN_SQLite.yml run --rm app python manage.py migrate docker-compose -f docker-compose-dev-WIN_SQLite.yml run --rm app python manage.py collectstatic --no-input docker-compose -f docker-compose-dev-WIN_SQLite.yml run --rm app python manage.py import_templates docker-compose -f docker-compose-dev-WIN_SQLite.yml run --rm app python manage.py createsuperuser docker-compose -f docker-compose-dev-WIN_SQLite.yml up
MySQL:
Mac:
docker compose -f docker-compose-dev-MAC_MYSQL.yml build docker-compose -f docker-compose-dev-MAC_MYSQL.yml run --rm app python manage.py makemigrations docker-compose -f docker-compose-dev-MAC_MYSQL.yml run --rm app python manage.py migrate docker-compose -f docker-compose-dev-MAC_MYSQL.yml run --rm app python manage.py collectstatic --no-input docker-compose -f docker-compose-dev-MAC_MYSQL.yml run --rm app python manage.py import_templates docker-compose -f docker-compose-dev-MAC_MYSQL.yml run --rm app python manage.py createsuperuser docker-compose -f docker-compose-dev-MAC_MYSQL.yml up
Windows:
docker compose -f docker-compose-dev-WIN_MYSQL.yml build docker-compose -f docker-compose-dev-WIN_MYSQL.yml run --rm app python manage.py makemigrations docker-compose -f docker-compose-dev-WIN_MYSQL.yml run --rm app python manage.py migrate docker-compose -f docker-compose-dev-WIN_MYSQL.yml run --rm app python manage.py collectstatic --no-input docker-compose -f docker-compose-dev-WIN_MYSQL.yml run --rm app python manage.py import_templates docker-compose -f docker-compose-dev-WIN_MYSQL.yml run --rm app python manage.py createsuperuser docker-compose -f docker-compose-dev-WIN_MYSQL.yml up
To test the api go to https://127.0.0.1:8000/api/executions
def create__customer_program_execution__for__customer_program_id(customer_program_id): data = { "NADOOIT__API_KEY": nadooit_api_auth_data.get("NADOOIT__API_KEY"), "NADOOIT__USER_CODE": nadooit_api_auth_data.get("NADOOIT__USER_CODE"), "program_id": customer_program_id, } # production res = requests.post("https://nadooit.de/api/executions", data=data)
# development
"""
res = requests.post(
"https://127.0.0.1:8000/api/executions",
data=data,
cert=("./certificate.crt", "./key.pem"),
)
"""
return res.json()
give as Content: { "NADOOIT__API_KEY" : "407de0db-1a05-4dbc-982c-7921318c1020", "NADOOIT__USER_CODE" : "YFttKo", "program_id" : "a5bfdff9-bfc5-4141-829b-656f87ae2282" }
To run the tests, use the following command:
The following command will can be run either in a virtual environment.
tox
add -s to show print statements
To run the tests, use the following command:
First activate the virtual environment:
venv\Scripts\activate
change into the directory:
cd app
then you can use the following commands to run pytest:
All tests: removing the -s will hide the print statements pytest -s
Tests with a specific name: pytest -s -k "test_get__employee_roles_and_rights__for__employee__with__"
The coverage report does ignore apps.py
- Create a new app
- Create a new model that is called XcZcManager Add the following fields to the model: employee = models.OneToOneField(employee, on_delete=models.CASCADE) list_of_customers_the_manager_is_responsible_for = models.ManyToManyField(Customer, on_delete=models.CASCADE) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True)
- Add the following to the app to the list of apps in the settings.py file
- Create migrations and migrate
-
git
See the following link for instructions on installing git on your system: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
-
docker
-
docker-compose
See the following link for instructions on installing docker on your system: https://docs.docker.com/engine/installation/
Download the setup.sh script from the repository or copy the contents into a new file named setup.sh on your server.
Make the script executable by running chmod +x setup.sh.
Run the script with ./setup.sh.
Follow the prompts to provide the required information for the .env file.
Note: The automatic setup will clone the repository, create the .env file, and perform the necessary steps for project setup, including building Docker images, running migrations, creating a superuser, and starting the server.
To do this you need to also add your ssh key to the github account.
adduser nadooit
usermod -aG sudo nadooit
TODO Fill this section
-
Copy the repository to your servers home directory
git clone git@github.com:NADOOIT/NADOO-IT.git
-
Change into the directory
cd NADOO-IT
-
create .env file
cp .env.example .env set the following variables in the .env file for first time setup:
To open the file in nano, type:
sudo nano .env
Replace your_secret_key with a new secret key. You can generate one here: https://miniwebtool.com/django-secret-key-generator/
DJANGO_SECRET_KEY=your_secret_key
ACME_DEFAULT_EMAIL=your_email
DOMAIN=your_domain
-
to find the following variables, go to https://cockroachlabs.cloud/
-
login or create an account
-
create a new cluster
-
set SQL user to a username of your choice
-
click on generate user and password
-
copy the generated password and replace your_cockroach_db_password in the .env file
-
select the dopdown menu for Database and click on create database, name it as you like
-
Download the CA Cert
- Select the operating system of your server
- Copy curl command
- Paste the command into your terminal
-
select option/language select Parameters only and replace the following variables in the .env file
- your_cockroach_db_user = Username
- your_cockroach_db_name = Database
- your_cockroach_db_host = Host
- your_cockroach_db_port = Port
- your_cockroach_db_options = Options
COCKROACH_DB_HOST=your_cockroach_db_host
COCKROACH_DB_NAME=your_cockroach_db_name
COCKROACH_DB_PORT=your_cockroach_db_port
COCKROACH_DB_USER=your_cockroach_db_user
COCKROACH_DB_PASSWORD=your_cockroach_db_password
COCKROACH_DB_OPTIONS=your_cockroach_db_options
docker compose -f docker-compose-deploy.yml build
docker compose -f docker-compose-deploy.yml run --rm certbot /opt/certify-init.sh
Create a directory for the database file and set the appropriate permissions by running:
docker compose -f docker-compose-deploy.yml run --rm app sh -c "mkdir -p /app/db && touch app/db/db.sqlite3 && chmod -R 777 /app/db"
If you get the following error:
touch: cannot touch '/app/db/db.sqlite3': Permission denied
Follow these steps:
sudo touch app/db/db.sqlite3
sudo chmod -R 777 /app/db
-
The database needs to be migrated before the server can be started. To do this, run the following command:
docker compose -f docker-compose-deploy.yml run --rm app python manage.py migrate docker compose -f docker-compose-deploy.yml run --rm app python manage.py collectstatic --noinput docker compose -f docker-compose-deploy.yml run --rm app python manage.py import_templates
- Run the following command to create a superuser docker compose -f docker-compose-deploy.yml run --rm app python manage.py createsuperuser
- Run the following command to start the server docker compose -f docker-compose-deploy.yml up -d
- Run the following command to stop the server docker compose -f docker-compose-deploy.yml down
Run the following command to update the server
git stash
git pull
docker compose -f docker-compose-deploy.yml build
docker compose -f docker-compose-deploy.yml run --rm app python manage.py migrate
docker compose -f docker-compose-deploy.yml run --rm app python manage.py collectstatic --noinput
docker compose -f docker-compose-deploy.yml run --rm app python manage.py import_templates
docker compose -f docker-compose-deploy.yml down
docker compose -f docker-compose-deploy.yml up -d
go to https://nadooit.de/admin/nadooit_crm/customer/add/
fill out the form
go to https://nadooit.de/admin/nadooit_hr/employeecontract/add/
go to https://nadooit.de/admin/nadooit_api_key/nadooitapikeymanager/add/
go to https://nadooit.de/admin/nadooit_hr/customermanagercontract/add/
go to https://nadooit.de/admin/nadooit_hr/customerprogramexecutionmanagercontract/add/
go to https://nadooit.de/admin/nadooit_hr/customerprogrammanagercontract/add/
first sighn in to the main customer user account. If there is currently no key associated with the account, you will be be able to just sign in without a password.
after you have signed in, go to https://nadooit.de/mfa/fido2/
if you have a PC with fido2 support it will ask you if you want to add it. Cancel the process and go to the next step.
It will ask you to insert a security key. Insert the security key and click on the button.
It will ask you to setup a password. Setup a password and click on the button. The default password is 123456.
Follow the instructions on the screen to add the security key.
Test the security key by signing out and signing in again.
The Nadooit Website is the main website for the Nadooit project. It is a infinite scroll website that infoms visitors about the Nadooit project and the Nadooit products.
Because the page is build from sections that are stored in the database, the page can be edited by the admin. Also all sections are available as templates in the sections_templates folder.
Because the page is build from sections that are stored in the database, it is important to sync the database with the sections_templates folder.
To retrieve all sections from the database and save them as templates in the sections_templates folder, run the following command:
docker compose -f docker-compose-dev-MAC_MYSQL.yml run --rm app python manage.py export_templates
To then retrieve all sections from the sections_templates folder and save them in the database, run the following command:
docker compose -f docker-compose-dev-MAC_MYSQL.yml run --rm app python manage.py import_templates
Sections contain the content of the website. They are stored in the database and can be edited by the admin.
Sections can contain the following elements:
- Text
- Image
- Video
- File downloads
For embedding a video first upload the video. Then in the sections admin page select the video from the dropdown menu.
Then add the following html block to the html at the place where the video should be displayed:
<div class="video-container">
{{ video }}
</div>
For embedding a file download first upload the file. Then in the sections admin page select the file from the dropdown menu.
Then add the following html block to the html at the place where the file download should be displayed:
<div class="file-container">
{{ file }}
</div>
For details on the bot management app, see the bot management app README.