Skip to content

Commit

Permalink
Merge branch 'main' into bast0006-new-infraction-filters
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisLovering committed Jun 4, 2021
2 parents 7a5a032 + 03c787b commit b076394
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 34 deletions.
4 changes: 2 additions & 2 deletions docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ Make sure you add the following to your hosts file:
```
When trying to access the site, you'll be using the domains above instead of the usual `localhost:8000`.

Finally, you will need to set the environment variable `DEBUG=1`. When using `pipenv`, you can
set put this into an `.env` file to have it exported automatically. It's also recommended to
Finally, you will need to set the environment variable `DEBUG=1`. If you have `python-dotenv` installed, you can put this into a
`.env` file to have it exported automatically. It's also recommended to
export `LOG_LEVEL=INFO` when using `DEBUG=1` if you don't want super verbose logs.

To run the server, run `python manage.py runserver`. If it gives you an error saying
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,29 @@ icon: fab fa-github

> **Note:** The process varies depending on your choice of code editor / IDE, so refer to one of the following guides:
- [Cloning with PyCharm](#cloning-with-pycharm)
- [Cloning with the command line](#cloning-with-the-command-line)
- [Cloning with PyCharm](#cloning-with-pycharm)

The following will use the [Sir-Lancebot](https://github.com/python-discord/sir-lancebot/) repository as an example, but the steps are the same for all other repositories. You should have already retrieved your fork's Git URL as described in [**Creating a Fork**](../forking-repository).

---

## Cloning with PyCharm
1. Load up PyCharm and click `Get from VCS`.<br>
![Create Project in PyCharm](/static/images/content/contributing/pycharm_create_project.png)
2. Enter the URL of your forked repository.
3. Change the directory if you desire and click `Clone`.<br>
![Clone Git Project in Pycharm](/static/images/content/contributing/pycharm_checkout.png)

---

## Cloning with the command line

1. Clone your forked repository using `git clone` followed by your fork's Git URL. Then, change your working directory to the repository.

```shell
$ git clone https://github.com/<your username>/sir-lancebot
...
$ cd sir-lancebot
```

---

## Cloning with PyCharm

1. Load up PyCharm and click `Get from VCS`.<br>
![Create Project in PyCharm](/static/images/content/contributing/pycharm_create_project.png)
2. Enter the URL of your forked repository.
3. Change the directory if you desire and click `Clone`.<br>
![Clone Git Project in Pycharm](/static/images/content/contributing/pycharm_checkout.png)
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ If the linter complains, the commit is aborted so that you can fix the linting e
That way, you never commit the problematic code in the first place!

Please refer to the project-specific documentation to see how to setup and run those tools.
In most cases, you can install pre-commit using `pipenv run precommit` or `poetry run task precommit`, and lint using `pipenv run lint` or `poetry run task lint`.
In most cases, you can install pre-commit using `poetry run task precommit`, and lint using `poetry run task lint`.

## Type Hinting

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,36 @@ icon: fab fa-python

> **Note:** The process varies depending on your choice of code editor / IDE, so refer to one of the following guides:
- [Installing dependencies with PyCharm](#installing-dependencies-with-pycharm)
- [Installing dependencies with the command line](#installing-dependencies-with-the-command-line)
- [Installing dependencies with PyCharm](#installing-dependencies-with-pycharm)

The following will use the [Sir-Lancebot](https://github.com/python-discord/sir-lancebot/) repository as an example, but the steps are the same for all other repositories.
You should have already cloned your fork as described in [**Cloning a Repository**](../cloning-repository).

---

## Installing dependencies with PyCharm
1. Load up your project in PyCharm.
2. Go to the Project Settings by clicking `File`, then `Settings...`. Alternatively, use the shortcut key: `Ctrl+Alt+S` (`command+comma` on Mac OS).
3. Install the [poetry plugin](https://plugins.jetbrains.com/plugin/14307-poetry).
4. Navigate to `Project Interpreter`, then click the gear icon and click `Add`.<br/>
![PyCharm Interpreter Settings](/static/images/content/contributing/pycharm_interpreter.png)<br/>
5. Click `Poetry Environment`, then click `OK`.<br/>
![PyCharm Pipenv Environment](/static/images/content/contributing/pycharm_poetry.png)<br/>
6. PyCharm will automatically install the packages required into a virtual environment.<br/>
![PyCharm Project Interpreter](/static/images/content/contributing/pycharm_poetry_success.png)

---

## Installing dependencies with the command line

1. Make sure you are in the root project directory. This directory will always have a file titled `README.md`.
2. Install project and development dependencies. Remember to also set up pre-commit hooks to ensure your pushed commits will never fail linting.
---

---

```shell
$ poetry install
$ poetry run task precommit
```

---

## Installing dependencies with PyCharm

1. Load up your project in PyCharm.
2. Go to the Project Settings by clicking `File`, then `Settings...`. Alternatively, use the shortcut key: `Ctrl+Alt+S` (`command+comma` on Mac OS).
3. Install the [poetry plugin](https://plugins.jetbrains.com/plugin/14307-poetry).
4. Navigate to `Project Interpreter`, then click the gear icon and click `Add`.<br/>
![PyCharm Interpreter Settings](/static/images/content/contributing/pycharm_interpreter.png)<br/>
5. Click `Poetry Environment`, then click `OK`.<br/>
![PyCharm Poetry Environment](/static/images/content/contributing/pycharm_poetry.png)<br/>
6. PyCharm will automatically install the packages required into a virtual environment.<br/>
![PyCharm Project Interpreter](/static/images/content/contributing/pycharm_poetry_success.png)
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ toc: 1

# Requirements

- [Python 3.8](https://www.python.org/downloads/)
- [Pipenv](https://github.com/pypa/pipenv#installation)
- `pip install pipenv`
- [Python 3.9](https://www.python.org/downloads/)
- [Poetry](https://python-poetry.org/docs/#installation)
- `pip install poetry`
- [Git](https://git-scm.com/downloads)
- [Windows](https://git-scm.com/download/win)
- [MacOS](https://git-scm.com/download/mac) or `brew install git`
Expand Down Expand Up @@ -122,10 +122,10 @@ If you're not using Docker, then use [pg_ctl](https://www.postgresql.org/docs/cu

### Webserver

Starting the webserver is done simply through pipenv:
Starting the webserver is done simply through poetry:

```shell
pipenv run start
poetry run task start
```

---
Expand Down
4 changes: 3 additions & 1 deletion pydis_site/apps/home/views/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from django.views import View

from pydis_site.apps.home.models import RepositoryMetadata
from pydis_site.constants import GITHUB_TOKEN

log = logging.getLogger(__name__)

Expand All @@ -18,6 +19,7 @@ class HomeView(View):

github_api = "https://api.github.com/users/python-discord/repos?per_page=100"
repository_cache_ttl = 3600
headers = {"Authorization": f"token {GITHUB_TOKEN}"}

# Which of our GitHub repos should be displayed on the front page, and in which order?
repos = [
Expand All @@ -42,7 +44,7 @@ def _get_api_data(self) -> Dict[str, Dict[str, str]]:
repo_dict = {}

# Fetch the data from the GitHub API
api_data: List[dict] = requests.get(self.github_api).json()
api_data: List[dict] = requests.get(self.github_api, headers=self.headers).json()

# Process the API data into our dict
for repo in api_data:
Expand Down
1 change: 1 addition & 0 deletions pydis_site/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os

GIT_SHA = os.environ.get("GIT_SHA", "development")
GITHUB_TOKEN = os.environ.get("GITHUB_TOKEN")

0 comments on commit b076394

Please sign in to comment.