diff --git a/bfportal/bfportal/settings/base.py b/bfportal/bfportal/settings/base.py
index fdcea59..41e6f4c 100644
--- a/bfportal/bfportal/settings/base.py
+++ b/bfportal/bfportal/settings/base.py
@@ -39,6 +39,7 @@
"wagtail.admin",
"wagtail.core",
"wagtail.contrib.routable_page",
+ "wagtail.api.v2",
"wagtail_color_panel",
"modelcluster",
"taggit",
diff --git a/bfportal/bfportal/urls.py b/bfportal/bfportal/urls.py
index d0011cd..395aa59 100644
--- a/bfportal/bfportal/urls.py
+++ b/bfportal/bfportal/urls.py
@@ -1,4 +1,5 @@
from ajax_select import urls as ajax_select_urls
+from core.api import api_router
from core.views import CategoriesAutocomplete, TagsAutocomplete, handle_like_request
from django.conf import settings
from django.contrib import admin
@@ -42,6 +43,7 @@
handle_like_request,
name="add_like_to_experience_page",
),
+ path("api/", api_router.urls),
re_path(r"^ajax_select/", include(ajax_select_urls)),
path("markdownx/", include("markdownx.urls")),
]
diff --git a/bfportal/core/api.py b/bfportal/core/api.py
new file mode 100644
index 0000000..c849541
--- /dev/null
+++ b/bfportal/core/api.py
@@ -0,0 +1,30 @@
+from rest_framework.renderers import JSONRenderer
+from wagtail.api.v2.router import WagtailAPIRouter
+from wagtail.api.v2.views import BaseAPIViewSet, PagesAPIViewSet
+
+from .models import ExperiencePage
+
+
+class ExperiencePageAPIViewSet(BaseAPIViewSet):
+ """Class that defines how page api works."""
+
+ renderer_classes = [JSONRenderer]
+ model = ExperiencePage
+ filter_backends = PagesAPIViewSet.filter_backends
+ body_fields = [
+ "url",
+ "id",
+ "full_url",
+ "title",
+ "description",
+ "cover_img_url",
+ "code",
+ "exp_url",
+ "featured",
+ "bugged",
+ ]
+ listing_default_fields = body_fields
+
+
+api_router = WagtailAPIRouter("wagtailapi")
+api_router.register_endpoint("experiences", ExperiencePageAPIViewSet)
diff --git a/bfportal/core/wagtail_hooks.py b/bfportal/core/wagtail_hooks.py
index 2840bc4..202c7be 100644
--- a/bfportal/core/wagtail_hooks.py
+++ b/bfportal/core/wagtail_hooks.py
@@ -17,14 +17,13 @@ class ExperiencePageAdmin(ModelAdmin):
def get_owner(self, page: ExperiencePage):
"""Returns html formatted string containing avatar and username."""
- if social_account := page.owner.socialaccount_set.first():
- extra_data = social_account.extra_data
- if extra_data["avatar"]:
- src = f"https://cdn.discordapp.com/avatars/{extra_data['id']}/{extra_data['avatar']}.png"
- else:
- src = ""
- else:
- src = ""
+ src = ""
+ if socialaccount_set := page.owner.socialaccount_set:
+ if social_account := socialaccount_set.first():
+ extra_data = social_account.extra_data
+ if extra_data["avatar"]:
+ src = f"https://cdn.discordapp.com/avatars/{extra_data['id']}/{extra_data['avatar']}.png"
+
return format_html(
"""
diff --git a/readme.md b/readme.md
index 91dc420..15e9a72 100644
--- a/readme.md
+++ b/readme.md
@@ -10,33 +10,10 @@ With the release of battlefield 2042, ripple effect studio, added the ability to
This project will replace the current website at https://bfportal.gg/
# Info
-project is now in beta testing
-head over to http://vmi656705.contaboserver.net:8000/, and try it out
-
-### Screenshots of several parts of the website
-
-
-
- Click to show
-
-
-
- ## Home Page
- ![image](https://user-images.githubusercontent.com/22869882/162639043-ec231408-b2e2-4f7a-b89e-38e48fec75e3.png)
- ## Profile Page
-![image](https://user-images.githubusercontent.com/22869882/162639063-19c9bd0b-888b-4116-ab25-cfc3d67692ec.png)
- ## Experience Info Page
-![image](https://user-images.githubusercontent.com/22869882/162639079-105111d8-0557-4ce2-a697-6cb3b8091b16.png)
- ## Experience Submission and edit page
-![image](https://user-images.githubusercontent.com/22869882/162639108-f3fef6b3-1c44-4283-a504-8ab959815bd8.png)
- ## Discord Login process
-![image](https://user-images.githubusercontent.com/22869882/162639135-30265c6e-690a-47b2-b9c5-842f98061051.png)
-![image](https://user-images.githubusercontent.com/22869882/162639149-6ca41096-9892-4c5c-ab3f-0d1c7dd9b1d0.png)
-
-
+Head over to [bfportal.gg](https://bfportal.gg/), and try it out
## Features
-- User system (Discord login for intregation with bfportal community discord server)
+- User system (Discord login for integration with portal community discord server)
- Auto Fill API for forms
- Pagination and website wide search
@@ -44,7 +21,7 @@ head over to http://vmi656705.contaboserver.net:8000/, and try it out
It is pretty straight forward
- You use your discord account to make a new account on the website and submit your experiences.
-- On the submission page if u choose to share the playgound Url of the experience, the submission form will auto fill 😃.
+- On the submission page if u choose to share the playground Url of the experience, the submission form will autofill 😃.
You can later edit your experience if u like.
@@ -57,16 +34,8 @@ You can later edit your experience if u like.
- create and activate a venv
- install dependencies `python -m pip install -r requirements.txt`
-- create a .env file with the following values
-- ```
- DB_NAME=
- DB_USERNAME=
- DB_PASSWORD=
- POSTGRES_HOST=127.0.0.1
- SU_PASSWD=1234
- DISCORD_CLIENT_ID=931965340764737608
- DISCORD_SECRET=SuzQK6oAV_ArY3HGXUYIOUjFT46C5OtW
- ```
+- copy the [.env.template](bfportal/.env.template) file and rename it to .env
+- fill the appropriate data in .env file
- Do first run migrate
- run `python manage.py ensure_superuser --username bfportal --email superuser@bfportal.com --password `
- run `python manage.py ensure_initialization`
@@ -79,7 +48,7 @@ You can later edit your experience if u like.
### Special Thanks to
- - [gametools.network](https://gametools.network/) for providing API to auto fill submisson form 🥰
- - [Wagtail](https://github.com/wagtail/wagtail) for providing a awesome framework that makes managing submissions very easy ✅
+ - [gametools.network](https://gametools.network/) for providing API to autofill submisson form 🥰
+ - [Wagtail](https://github.com/wagtail/wagtail) for providing an awesome framework that makes managing submissions very easy ✅
- [tailwindcss](https://github.com/tailwindlabs/tailwindcss) for saving the lives of backend developers. 🙏
- - [Matavatar](https://discord.com/users/236802771381125120) from BFportal discord community for providing valuable feedback 🤝
+ - [Matavatar](https://discord.com/users/236802771381125120) from BFportal discord community for designing UI of the website 🤝