A user-friendly online platform for viewing and posting recipes effortlessly.
- VSCode
- Anaconda or Miniconda. Ensure you can run the
conda
command through your terminal. - Git
- Navigate to the checked-out repository folder:
cd thecampuscookbook
- Run the command:
This will use the environment.yml file to create the development environment.
conda env create
- Activate the conda environment using the command:
conda activate cookbook
- Create a new environment with the required dependencies:
conda create -n cookbook python==3.11 django pillow black pre-commit
- Navigate to the checked-out repository and export the environment.:
conda env export -n cookbook --ignore-channels --from-history -f environment.yml
- Commit the environment.yml file to version control. Ensure that it does not have platform-specific dependencies.
- Deactivate the environment by running:
conda deactivate
- Remove the environment by running:
conda env remove -n cookbook
- Open a terminal.
- Run the command
This will ask you to provide a filepath to for storing the key. Please provide a valid path to the file and remember the path for future use.
ssh-keygen -t ed25519
The key generation utility will then ask you to set a password, but this is optional and can be skipped by just pressing the enter key. - Run the command:
Replace
ssh-add <the_path_to_key_file>
<the_path_to_key_file>
with the path you had used for storing the key. - Click on Switch branches/tags button on this page. Then type in a new
branch name.
You will be using this branch to work on your code. See the image below:
Then type in a branch name:
- If you have already cloned this repository before, navigate to the checked-out repository folder through the terminal and run:
git pull
- If this is your first time cloning the repository, run the following in a
new terminal:
git clone [email protected]:Rapteon/thecampuscookbook.git
- After ensuring that you have the repository on your computer, switch
to the branch which you created. Run the command:
The branch name must match the name you used to create the branch on GitHub.
git checkout <the-branch-name>
- After ensuring that the conda environment for this project active, run the command
This will install a Git hook which would automatically format your Python code before each commit.
pre-commit install
Note that you can also run this hook manually using the commandpre-commit run
when the conda environment is active. - Start making your code changes. Once you have finished making your changes, proceed to the section on committing your changes.
Ensure that you have navigated to the repository folder in your terminal window. This is essential for all the following commands.
You should run git status
before/after each command to determine the status of your files.
Running status command shows you which information
about modified and unstaged (files which are not marked for commit) files.
Committing changes is a four-stage process:
- Add your files so that Git knows these files need to be version controlled.
Run the command:git add <file_or_folder_to_store>
- Commit the files to Git by running:
If you see a message asking you to configure your Git username and password, follow the instructions shown in the terminal.
git commit -m '<message string describing changes>'
Then repeat this step. - All commits are local by default, so you need to upload (a.k.a. push) your changes to GitHub so that other members
of the team can view and integrate them in their code. To do so, run:git push
- Open the GitHub website, and select your branch through the Switch branches/tags
button (shown in the image below).
After selecting the branch, you'll see a banner like the following suggesting
you to create a new pull request:
- Click on Compare and pull request button:
This will take you to a new page. - Add a title for your pull request and describe your changes. See the image below:
- The following figure shows a pull request which can be easily merged (no conflicts).
Do note that you need approval from at least 1 reviewer before the code can be merged into the main branch.
This repository can be configured with a pre-commit hook to format Python files before committing them to Git.
It is strongly recommended to install the pre-configured hook.
The pre-commit hook uses the Black formatter to format .py files.
- Ensure the conda environent for the project is activated. Check the section for creating a Conda environment.
- Run the command
pre-commit install
if activating your environment for the first time. - Autoformatting of Python code happens when you commit your code using
git commit
.
In case the formatter decides the code is not formatted, you will see a failed message after
trying to commit the changes. This means the file has been formatted, but your changes
have not been committed. After the failed message, simply add the file usinggit add <failed_file_path>
and then commit the changes again usinggit commit -m '<message>'
. - If you would like to run the formatter manually, you can run it like
black <file_name>.py
.
- Activate the conda environment as specified in the conda env setup section.
- Navigate to the directory containing the
manage.py
file. - Run
python manage.py migrate
to create the database.
We have created a script to populate the database with sample data.
To run the data-populator.py
script, type python data-populator.py
Making changes to any of the model.py files means you would need to update the database.
Note that you might also need to modify the data-populator.py
script to support
new schema changes.
In this scenario, follow these steps:
- Save the modified
models.py
file. - Delete the existing
db.sqlite3
file. This means you will be deleting the existing database. - Navigate to the directory containing the
manage.py
script. - Run
python manage.py makemigrations
. This will create one or more migration files in the modified app. - Run
python manage.py migrate
. This command will apply the changes to your database. - Run
python data-populator.py
script to repopulate the database.