Skip to content

Commit

Permalink
chore(core): merge dev into main (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
MagneticNeedle authored Jul 9, 2023
2 parents 099524c + 9af28d2 commit 6c9617f
Show file tree
Hide file tree
Showing 119 changed files with 687 additions and 432 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
pull_request:
branches:
- none

push:
branches:
- main
Expand All @@ -31,11 +30,11 @@ jobs:
run: docker build . --file Dockerfile --tag $BRANCH_NAME

- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push image
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$BRANCH_NAME
IMAGE_ID=ghcr.io/${{ github.repository }}/$BRANCH_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
Expand Down
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
default_install_hook_types: [pre-commit, commit-msg]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
Expand All @@ -17,6 +18,7 @@ repos:
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]

- repo: https://github.com/psf/black
rev: 23.3.0
Expand Down
22 changes: 18 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,21 @@ If you already have experience with django/wagtail, understanding the backend wi
----
# Env Setup
- ### Docker
- Create a Python Virtual Environment and activate it
- Install the pre-commit hooks by running `pre-commit install --install-hooks`
- Make sure You have **docker** installed and the `cd` to `bfportal` directory
- Copy the `.env.template` file to `.env`
- Create a [discord application](https://discord.com/developers/applications) for OAuth2 and copy the client id and secret
- Paste the client id and secret in `.env` file to `DISCORD_CLIENT_ID` and `DISCORD_SECRET` respectively
- Then run `docker-compose --profile dev_local up`
- The website should be available at `127.0.0.1:8000`
- If You want to set up everything your self, See the next points


- ### Python
- Refer to [readme.md](/readme.md#how-to-run-locally)
- install pre-commit checks by runnning (**make sure the Virtual Enviroment is activated !!**)
- install pre-commit checks by running (**make sure the Virtual Enviroment is activated !!**)
```
pre-commit install
```
Expand All @@ -41,7 +52,10 @@ If you already have experience with django/wagtail, understanding the backend wi
```
python manage.py tailwind start
```
- ### Postgres
- Make sure postgres is installed and running
- Create DB, USER and Password for the project
- Update the `.env` file accordingly
----
Expand Down Expand Up @@ -76,9 +90,9 @@ bfportal/
- Make sure all the precommit test are passed
- Open a pull request to merge the branch into dev branch
- The changes will be reviewed on dev deployment
- Upon successfull testing dev will be merged into main
- Upon successfully testing dev will be merged into main
# How to discuss with the maintainers
- Join our [discord server](https://bfportal.gg/join).
- Join our [discord server](https://discord.bfportal.gg/).
- Open a new issue.
- mail us at [email protected]
27 changes: 14 additions & 13 deletions bfportal/.env.template
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
POSTGRES_HOST=
DB_NAME=
DB_USERNAME=
DB_PASSWORD=

SU_PASSWD=
PRODUCTION_KEY=
PRODUCTION_HOST=
PRODUCTION_PORT=

SU_PASSWD=1234
PRODUCTION_KEY=%dn0n58@4z7j(5=o(i1w-24-d2n7elvvu3hawh)$8d^^cfg40-
PRODUCTION_HOST=127.0.0.1
ALLAUTH_PROTOCOL=HTTP
OWNERS=236802771381125120,338947895665360898,216307162106822659
PRODUCTION_PORT=8000
DEBUG=True
DB_NAME=postgres
DB_USERNAME=postgres
DB_PASSWORD=postgres
# required for login via discord Oauth
DISCORD_CLIENT_ID=
DISCORD_SECRET=

# Not required unless You want to the featues to publish updates to discord
DISCORD_BOT_TOKEN=#required to get scheduled events of a server

APPROVAL_CHANNEL_WEBHOOK_TOKEN=
APPROVAL_CHANNEL_WEBHOOK_ID=

APPROVAL_SUCCESS_CHANNEL_WEBHOOK_TOKEN=
APPROVAL_SUCCESS_CHANNEL_WEBHOOK_ID=

ALLAUTH_PROTOCOL=
OWNERS=
4 changes: 3 additions & 1 deletion bfportal/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use an official Python runtime based on Debian 10 "buster" as a parent image.
FROM python:3.11-slim-buster
FROM python:3.11-slim-buster as dev

# Add user that will be used in the container.
RUN useradd --create-home wagtail
Expand Down Expand Up @@ -59,6 +59,8 @@ COPY --chown=wagtail:wagtail . .
# Use user "wagtail" to run the build commands below and the server itself.
USER wagtail

FROM dev as final

RUN python manage.py tailwind install --no-input;
RUN python manage.py tailwind build --no-input
RUN python manage.py collectstatic --noinput --clear
3 changes: 1 addition & 2 deletions bfportal/bfportal/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
INSTALLED_APPS = [
"whitenoise.runserver_nostatic",
"core",
"factory",
"wagtail",
"wagtail.contrib.forms",
"wagtail.contrib.redirects",
"wagtail.embeds",
Expand All @@ -39,7 +39,6 @@
"wagtail.images",
"wagtail.search",
"wagtail.admin",
"wagtail.core",
"wagtail.contrib.routable_page",
"wagtail.api.v2",
"wagtail_color_panel",
Expand Down
1 change: 0 additions & 1 deletion bfportal/bfportal/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

# SECURITY WARNING: define the correct hosts in production!
ALLOWED_HOSTS = ["*"]

EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"


Expand Down
2 changes: 1 addition & 1 deletion bfportal/bfportal/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from django.contrib import admin
from django.urls import include, path, re_path
from django.views.generic import RedirectView, TemplateView
from wagtail import urls as wagtail_urls
from wagtail.admin import urls as wagtailadmin_urls
from wagtail.core import urls as wagtail_urls
from wagtail.documents import urls as wagtaildocs_urls
from wagtailautocomplete.urls.admin import urlpatterns as autocomplete_admin_urls

Expand Down
4 changes: 2 additions & 2 deletions bfportal/bfportal/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ def init_wsgi():
with warnings.catch_warnings():
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bfportal.settings.production")
from django.core.wsgi import get_wsgi_application
from wagtail.utils.deprecation import RemovedInWagtail50Warning
from wagtail.utils.deprecation import RemovedInWagtail60Warning

warnings.filterwarnings(
"ignore", category=RemovedInWagtail50Warning
"ignore", category=RemovedInWagtail60Warning
) # supress only wagtail warnings
application = get_wsgi_application()

Expand Down
5 changes: 5 additions & 0 deletions bfportal/core/admin.py
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
from django.contrib import admin

from .models.users import Profile

admin.site.register(Profile)
# Register your models here.
6 changes: 5 additions & 1 deletion bfportal/core/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

def get_scheduled_events(event_id: str, server_id: str = "870246147455877181") -> dict:
"""Tries to retrieve Scheduled events via discord API"""
if DISCORD_TOKEN := os.getenv("DISCORD_BOT_TOKEN", None):
if len(DISCORD_TOKEN := os.getenv("DISCORD_BOT_TOKEN", "")):
headers = {
"Authorization": f"Bot {DISCORD_TOKEN}",
"content-type": "application/json",
Expand All @@ -26,6 +26,10 @@ def get_scheduled_events(event_id: str, server_id: str = "870246147455877181") -
headers=headers,
)
return resp.json()
else:
logger.warning(
"Unable to get scheduled events... DISCORD_BOT_TOKEN not provided"
)


def validate_image_link(link: str):
Expand Down
2 changes: 1 addition & 1 deletion bfportal/core/management/commands/ensure_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.contrib.auth.models import User
from django.core.management.base import BaseCommand
from loguru import logger
from wagtail.core.models import Page, Site
from wagtail.models import Page, Site


class Command(BaseCommand):
Expand Down
1 change: 0 additions & 1 deletion bfportal/core/management/commands/import_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def handle(self, *args, **options): # noqa: D102
json_db = json.load(db_file)
su = User.objects.filter(is_superuser=True).first()
for json_row in json_db:

row = DBRow(**json_row)
if row.type == "Prefabs":
row.type = "Prefab"
Expand Down
Loading

0 comments on commit 6c9617f

Please sign in to comment.