This repository contains the Transport Nantes website code.
This program is distributed under the GNU GPL v3 licence. See the file LICENCE for its text.
(to come)
You will need the following softwares:
Vagrant and VirtualBox are optional (but recommended) if you use Linux. Those two software will be used to create a virtual machine on which you will run the website. This machine is will be running Ubuntu 20.04, and Vagrant is used to script the installation of requirements on it. The following instructions assume you have installed all the softwares listed above.
At the end of those instructions, you should be able to run a local version of the website.
-
Fork the repository Fork the repository on GitHub. Let's assume you have created a new repository called
mobilitains
in/Documents/mobilitains
. -
Use the
cd
command to change the current directory to the repository. Ex :cd /Documents/mobilitains/
-
Use
vagrant up --provision
to create the virtual machine. This can take some times depending on your internet connection. It creates an Ubuntu environnement with all requirements to run the website (Django etc.). -
Use
vagrant ssh
to connect to the virtual machine. You can check that if your terminal displaysvagrant@ubuntu-focal:~$
. -
Use
cd /vagrant/
to move to the website directory. You can find the website's code in this folder. -
Enter the vagrant's virtual environnement by using
source venv.vagrant/bin/activate
. You can confirm it works by seeing the(venv.vagrant) vagrant@ubuntu-focal:/vagrant$
in your terminal. -
Enter the website's directory by using
cd transport_nantes/transport_nantes
. Your current directory should now be(venv.vagrant) vagrant@ubuntu-focal:/vagrant/transport_nantes/transport_nantes$
-
Create a file called
settings_local.py
and fill it with the content ofsettings_local.py.DEV.template
. This file isn't tracked on GitHub, so you can edit it without affecting the repository. It's mandatory to create this file in order to run the website. The content ofsettings_local.py.DEV.template
is a base that defines the settings for the development environment. -
Go one folder up using
cd ..
, you're current directory should now be(venv.vagrant) vagrant@ubuntu-focal:/vagrant/transport_nantes$
-
You're ready to run the website, you can use
python manage.py runserver 0.0.0.0:8000
to run the server. If you open your browser athttp://localhost:8000/
or0.0.0.0:8000
, you should see the website. However at this point, you should see a message saying you have X unnaplied migrations in your console, and a 404 error.
Indeed, even though your configuration is fine, you don't have the database created yet.
-
Start by running the
python manage.py migrate
command. You should now see a new file nameddb.sqlite3
in your current directory. -
Run
python manage.py createsuperuser
to create a superuser, you will use this to connect to Django's admin interface.
The database is set but still empty. Let's display a "Hello, world!" message in the landing page of your local version of the website !
-
Run
python manage.py runserver 0.0.0.0:8000
to run the server. -
Open your browser at
http://localhost:8000/admin
or0.0.0.0:8000/admin
. You're facing Django Admin's interface. Use the credentials you created to connect to it.
The landing page is an instance of an app named "topicblog", however because your database is empty, you will also need to create 3 items before you can see the landing page :
- Edition of the landing page
- At the bottom of Admin Interface, click on on the "+ Add" button next to "Topic blog content types". In the form, fill the "Content type" with "content" or whatever you want to call your content type. I'll assume you also entered "content".
- Save the form by hitting "Save" at the bottom right.
- Back to admin interface, now click on on the "+ Add" button next to "Topic blog templates". In the form fill the fields like this :
- "Template name" with
topicblog/content.html
- "Comment" with any string, suggestion :
This template is used to display the content of a topic blog item.
- "Content type" with the content type you created in the previous step. In our case only "content" is available.
- Save the form by hitting "Save" at the bottom right.
- "Template name" with
- Back to admin interface, now click on on the "+ Add" button next to "Topic blog Items". In the form fill the fields like this :
- "slug" to "index"
- "item_sort_key" to "0"
- "servable" to "True" (checked)
- "publication_date" to any anterior date (you can use Django's button to have the current date)
- "User" to the superuser you created in the previous step.
- "content_type" to the content type you created in the previous step.
- "template" to the template you created in the previous step.
- "title" to "Hello, world!"
- "body text 1 md" to "This is my first Hello, world! on this website !" or anything you like ;)
- Save the form by hitting "Save" at the bottom right.
Congratulations, you customized your first page on the website ! You can now see it at http://localhost:8000/
or 0.0.0.0:8000/
!
Make sure your code is well formatted.
This means : Complies to PEP8 (https://www.python.org/dev/peps/pep-0008/) and PEP257 (https://www.python.org/dev/peps/pep-0257/).
You can use linters such as flake8
and pylint
to check your code.
It must be written in English.
- Your commits should be short and concise.
- Use the present tense ("Add feature" not "Added feature")
- Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
- Reference issues and pull requests liberally after the first line
Thank you for your interest in contributing to this project. The simplest way for you to contribute is to fork the repository and start a pull request.
If you want to report a bug, please open an issue on GitHub.
You can send your questions to this address.