From 142beab16e9e947456184e5624ac47599115bd04 Mon Sep 17 00:00:00 2001 From: Vibhakar Solanki Date: Sat, 25 Mar 2023 17:32:13 +0530 Subject: [PATCH 1/2] fix: Add CSRF_TRUSTED_ORIGINS to settings.py (#165) * feat: add github sponsors info * fix: add CSRF_TRUSTED_ORIGINS to settings * feat: add WIP action to manage PRs --- .github/funding.yaml | 1 + .github/workflows/wip.yml | 12 ++++++++++++ bfportal/bfportal/settings/production.py | 1 + 3 files changed, 14 insertions(+) create mode 100644 .github/workflows/wip.yml diff --git a/.github/funding.yaml b/.github/funding.yaml index 498559d..f9b1ada 100644 --- a/.github/funding.yaml +++ b/.github/funding.yaml @@ -1 +1,2 @@ +github: [battlefield-portal-community] patreon: battlefield_portal_community diff --git a/.github/workflows/wip.yml b/.github/workflows/wip.yml new file mode 100644 index 0000000..6e71c2e --- /dev/null +++ b/.github/workflows/wip.yml @@ -0,0 +1,12 @@ +name: WIP +on: + pull_request: + types: [opened, synchronize, reopened, edited] + +jobs: + wip: + runs-on: ubuntu-latest + steps: + - uses: wip/action@v1.1.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/bfportal/bfportal/settings/production.py b/bfportal/bfportal/settings/production.py index ec4a833..737375e 100644 --- a/bfportal/bfportal/settings/production.py +++ b/bfportal/bfportal/settings/production.py @@ -8,6 +8,7 @@ SECRET_KEY = os.environ.get("PRODUCTION_KEY") ALLOWED_HOSTS = os.environ.get("PRODUCTION_HOST").split(",") ALLOWED_HOSTS.append("localhost") +CSRF_TRUSTED_ORIGINS = ["https://*.bfportal.gg/"] logger.debug(f"Allowed Hosts {ALLOWED_HOSTS}") try: From b60726d7ff002c6f86448b6541b9d568cc299dce Mon Sep 17 00:00:00 2001 From: Vibhakar Solanki Date: Tue, 28 Mar 2023 23:48:50 +0530 Subject: [PATCH 2/2] fix: made category required in submit form (#166) * feat: add github sponsors info * fix: add CSRF_TRUSTED_ORIGINS to settings * feat: add WIP action to manage PRs * fix: make categories required; fixes #149 * chore: clean up readme * feat: remove update-portainer workflow --- .github/workflows/main.yml | 11 ----------- bfportal/core/forms.py | 13 +++++++++++-- readme.md | 3 +-- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 075264a..2c54a4c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,14 +48,3 @@ jobs: echo VERSION=$VERSION docker tag $BRANCH_NAME $IMAGE_ID:$VERSION docker push $IMAGE_ID:$VERSION - - update-portainer: - needs: production-deploy - runs-on: ubuntu-latest - steps: - - name: post to webhook - uses: fjogeleit/http-request-action@v1 - with: - url: ${{ secrets.PORTAINER_WEBHOOK_URL }} - method: 'POST' - timeout: 180000 diff --git a/bfportal/core/forms.py b/bfportal/core/forms.py index 841afec..5225c54 100644 --- a/bfportal/core/forms.py +++ b/bfportal/core/forms.py @@ -19,6 +19,7 @@ def __init__(self, *args, **kwargs): self.fields["sub_categories"].queryset = SubCategory.objects.filter( selectable_on_form=True ) + self.fields["category"].required = True self.fields["cover_img_url"].required = True creators = AutoCompleteSelectMultipleField( @@ -80,7 +81,11 @@ def clean_category(self): def clean_code(self): """Called when code field is being validated""" code = self.cleaned_data["code"] - if self.cleaned_data["category"].name.lower() != "prefab" and not len(code): + if ( + self.cleaned_data.get("category", None) + and self.cleaned_data["category"].name.lower() != "prefab" + and not len(code) + ): raise forms.ValidationError( "Must provide experience code if category is other than prefab" ) @@ -92,7 +97,11 @@ def clean_code(self): def clean_exp_url(self): """Called when experience url field is being validated""" url = self.cleaned_data["exp_url"] - if self.cleaned_data["category"].name.lower() == "prefab" and not len(url): + if ( + self.cleaned_data.get("category", None) + and self.cleaned_data["category"].name.lower() == "prefab" + and not len(url) + ): raise forms.ValidationError( "Must provide experience url if category is prefab" ) diff --git a/readme.md b/readme.md index 9089373..0557f6f 100644 --- a/readme.md +++ b/readme.md @@ -6,8 +6,7 @@ [![Docker Build](https://github.com/battlefield-portal-community/bfportal.gg/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/battlefield-portal-community/bfportal.gg/actions/workflows/main.yml) # What is this ? -With the release of battlefield 2042, ripple effect studio, added the ability to make custom game modes called "experiences", currently there is no way to share a game mode outside of the game, this project aims to fill that gap. -This project will replace the current website at https://bfportal.gg/ +With the release of battlefield 2042, ripple effect studio, added the ability to make custom game modes called "experiences", currently there is no way to share a game mode outside of the game, this project aims to fill that gap. # Info Head over to [bfportal.gg](https://bfportal.gg/), and try it out