How to use remote development for HOLON - Zenmo/Holon-webapp GitHub Wiki

VScode: Get remote dev extension and remote development


Name: Dev Containers
Id: ms-vscode-remote.remote-containers
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers


Name: Remote Development
Id: ms-vscode-remote.vscode-remote-extensionpack
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack


Generate SSH key

This is the safer alternative to using a password. SSH is secure but also very powerful. That's why we prefer one of the latest and greatest in protocols (ed25519). Never share your private key (the file without the .pub extension). That file is yours and yours alone.

  1. Open bash or cmd. (will start in your user root folder ~/users/<username>/)
cd .ssh
ssh-keygen -t ed25519
  1. When prompted to provide a location use holondev_{yourname} (replace {yourname} by your name)
  2. Provide no passphrase when prompted (or make sure to write that down)

Create config file

  1. While still at ~/users/<username>/.ssh, create a config file at that location using nul > config (cmd) or touch config(bash)
  2. Open the file in vscode (code config) or notepad (notepad.exe config)
  3. Enter the content below to that file (replace the first part by your user path to .ssh and the last part by the filename of the keys you just generated)
Host holondev
    HostName 167.235.148.91
    User root
    IdentityFile <your_user_path>/.ssh/holondev_{yourname}

Share the public key with me (Seth)

  1. Use whatever channel to send me the .pub version of your key
  2. I'll use ssh-copy-id -f -i <your_key.pub> <myconfig_host> to add your public key to the server.
  3. I'll let you know once that's done

Connect to the remote container

Connect to the server using SSH

  1. Open VScode
  2. Press ctrl+shift+p and type remote connect current and select the command Remote-SSH: Connect Current Window to Host (id: opensshremotes.openEmptyWindowInCurrentWindow)
  3. Select 'Add new SSH host'
  4. Type ssh holondev
  5. Select the correct location for your .ssh config (~/users/.shh/config)

Open the dev container

  1. Once connected, open the correct folder in VScode by selecting /root/projects/Holon-webapp/
  2. Click the dev container notification that appears ('Reopen in Container') OR: use ctrl+shift+p and type reopen container to select Remote-Containers: Reopen in Container

Use the Django backend

The Django backend consists of 2 interfaces: the CMS (Wagtail) and the django-admin interface. The CMS is more userfriendly while django-admin exposes all models and provides a more low-level interface.

URL Name Functionality
http://localhost:8000/wt/cms Wagtail CMS Nicer interface for working with Django models, allows you to create pages and make configurations.
http://localhost:8000/wt/admin django-admin The more low level interface for working with models. For now, this is where you should create your datamodel configuration.
http://localhost:8000/wt/api/nextjs/v2/datamodel/int:pk/ datamodel JSON endpoint replace the int:pk with your scenario number (can be found when editing the scenario at the end of the url (e.g., /wt/cms/scenarios/edit/1, where 1 is the pk of this scenario.

Clean the database

  1. Make sure the database is ready for use by you (check with other users Jorrit, Gillis & Peter).
  2. Open a terminal in VScode (ctrl + &#126)
  3. run cd src to navigate to the Python source folder
  4. run python manage.py flush (this will reset the database by erasing all entries but retains the schemas)
  5. run python manage.py createsuperuser (use user: admin, email: [email protected] and pass: admin)
  6. run python manage.py runserver

Configure the datamodel in django-admin

  1. Navigate to the django-admin
  2. Add your model configuration, starting at scenario, actors, gridnodes and gridconnections. You can create 'parents' in the same window by clickin on the green plus. This will open a window for you to add the parent model information. Add assets to gridconnections using the 'gridconnection' field. Similar for gridnode. In the json, these will be resolved to viewsets (as list in gridconnections/gridnodes)

Export the datamodel configuration to a fixture

  1. In your terminal that is in the src folder run:
    manage.py dumpdata holon --natural-primary --natural-foreign > <fixture_name>.json

Import datamodel from fixture

Hoe doe je dit?

⚠️ **GitHub.com Fallback** ⚠️