Skip to content

Commit

Permalink
Merge pull request #165 from zediious/0.4.5.4
Browse files Browse the repository at this point in the history
Changes for 0.4.5.4
  • Loading branch information
zediious authored Jun 1, 2024
2 parents b7928dc + 7ac45fd commit 016538c
Show file tree
Hide file tree
Showing 18 changed files with 215 additions and 159 deletions.
131 changes: 131 additions & 0 deletions config/jazzmin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
from os.path import join
from os import getenv
from pathlib import Path
from dotenv import load_dotenv

load_dotenv(join(Path(__file__).resolve().parent.parent, 'stack.env'))

ADMIN_BRAND_NAME = "Default" if getenv('ADMIN_BRAND_NAME') == '' else getenv('ADMIN_BRAND_NAME')

JAZZMIN_SETTINGS_ORIGINAL = {

"site_title": f"Admin {ADMIN_BRAND_NAME}",
"site_header": f"{ADMIN_BRAND_NAME}",
"site_brand": f"{ADMIN_BRAND_NAME}",
"site_logo_classes": "img-circle",
"welcome_sign": f"Welcome to {ADMIN_BRAND_NAME}",
"topmenu_links": [
{"name": "Return to Site", "url": "/", "new_window": False},
{"name": "Admin", "url": "/admin/", "new_window": False},
{"name": "Control Panel", "permissions": ["raptormc.panel"], "url": "/panel/", "new_window": False},
{"name": "Discord Bot", "permissions": ["raptormc.discord_bot"], "url": "/panel/discordbot/", "new_window": False},
{"name": "Server Actions", "permissions": ["raptormc.server_actions"], "url": "/panel/serveractions/", "new_window": False},
{"name": "Reporting", "permissions": ["raptormc.reporting"], "url": "/panel/reporting/", "new_window": False},
{"name": "Donations", "permissions": ["raptormc.donations"], "url": "/panel/donations/", "new_window": False},
{"app": "raptormc"},
{"app": "gameservers"},
{"app": "raptorbot"},
{"app": "donations"},
{"app": "staffapps"},
{"app": "authprofiles"},
{"name": "Settings", "permissions": ["raptormc.settings"], "url": "/panel/settings/", "new_window": False},
],
"usermenu_links": [
{"model": "auth.user"},
{"name": "Return to Site", "url": "/", "new_window": False},
{"name": "Admin", "url": "/admin/", "new_window": False},
{"name": "Control Panel", "permissions": ["raptormc.panel"], "url": "/panel/", "new_window": False},
{"name": "Discord Bot", "permissions": ["raptormc.discord_bot"], "url": "/panel/discordbot/", "new_window": False},
{"name": "Server Actions", "permissions": ["raptormc.server_actions"], "url": "/panel/serveractions/", "new_window": False},
{"name": "Reporting", "permissions": ["raptormc.reporting"], "url": "/panel/reporting/", "new_window": False},
{"name": "Donations", "permissions": ["raptormc.donations"], "url": "/panel/donations/", "new_window": False},
{"name": "Settings", "permissions": ["raptormc.settings"], "url": "/panel/settings/", "new_window": False},
],

# Sidebar
"show_sidebar": True,
"navigation_expanded": False,
"hide_apps": ['ipn'],
"order_with_respect_to": ["raptormc", "gameservers", "raptorbot", 'donations', "staffapps", "authprofiles"],
"custom_links": {
"raptorbot": [{
"name": "Discord Bot Control Panel",
"url": "/panel/discordbot/",
"icon": "fas fa-terminal",
"permissions": ["raptormc.discord_bot"]
}],
"gameservers": [{
"name": "Server Actions",
"url": "/panel/serveractions/",
"icon": "fas fa-terminal",
"permissions": ["raptormc.server_actions"]
}],
"donations": [{
"name": "Completed Donations",
"url": "/panel/donations/",
"icon": "fa fa-check-double",
"permissions": ["raptormc.donations"]
}],
"donations": [{
"name": "Completed Donations",
"url": "/panel/donations/",
"icon": "fa fa-check-double",
"permissions": ["raptormc.donations"]
}]
},
"icons": {
"raptormc": "fas fa-book",
"raptormc.InformativeText": "fas fa-scroll",
"raptormc.NavbarLink": "fas fa-map-marker",
"raptormc.NavbarDropdown": "fas fa-map-marker",
"raptormc.NavWidget": "fas fa-map-pin",
"raptormc.NavWidgetBar": "fas fa-map-pin",
"raptormc.NotificationToast": "fas fa-envelope-square",
"raptormc.Page": "fas fa-file",
"gameservers": "fas fa-gamepad",
"gameservers.Player": "fas fa-headset",
"gameservers.Server": "fas fa-server",
"raptorbot": "fas fa-robot",
"raptorbot.SentEmbedMessage": "fas fa-comment",
"raptorbot.GlobalAnnouncement": "fas fa-bullhorn",
"raptorbot.ServerAnnouncement": "fas fa-bullhorn",
"staffapps": "fas fa-book-reader",
"staffapps.ModeratorApplication": "fas fa-book-open",
"staffapps.AdminApplication": "fas fa-book-open",
"authprofiles": "fas fa-users",
"authprofiles.RaptorUserGroup": "fas fa-users",
"authprofiles.RaptorUser": "fas fa-user",
"authprofiles.UserProfileInfo": "fas fa-user-tag",
"authprofiles.DiscordUserInfo": "fas fa-user-tag",
"donations": "fa fa-coins",
"donations.DonationPackage": "fa fa-archive",
"donations.DonationServerCommand": "fa fa-terminal",
"donations.DonationDiscordRole": "fa fa-mask",

},
"default_icon_parents": "fas fa-chevron-circle-right",
"default_icon_children": "fas fa-circle",
"use_google_fonts_cdn": True,
"show_ui_builder": False,

}

JAZZMIN_UI_TWEAKS_ORIGINAL = {

"navbar_small_text": True,
"footer_small_text": True,
"body_small_text": False,
"brand_small_text": False,
"brand_colour": False,
"accent": "accent-lightblue",
"navbar": "navbar-gray-dark navbar-dark",
"no_navbar_border": False,
"navbar_fixed": True,
"layout_boxed": False,
"footer_fixed": False,
"sidebar_disable_expand": True,
"theme": "cyborg",
"actions_sticky_top": False,
"sidebar_nav_child_indent": True,

}
5 changes: 5 additions & 0 deletions config/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@
'level': 'DEBUG',
'propagate': False,
},
'authprofiles.tasks': {
'handlers': ['console', 'log_file', 'mail_admins'],
'level': 'DEBUG',
'propagate': False,
},
'gameservers.views': {
'handlers': ['console', 'log_file', 'mail_admins'],
'level': 'DEBUG',
Expand Down
131 changes: 7 additions & 124 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from celery.schedules import crontab

from config.logging import LOGGING_DEFINITION
from config.jazzmin import JAZZMIN_SETTINGS_ORIGINAL, JAZZMIN_UI_TWEAKS_ORIGINAL

# Define project directories
BASE_DIR: str = Path(__file__).resolve().parent.parent
Expand Down Expand Up @@ -231,9 +232,6 @@

BACKGROUND_TASK_RUN_ASYNC: bool = True

# ** Settings for "raptormc" app **
ADMIN_BRAND_NAME = "Default" if getenv('ADMIN_BRAND_NAME') == '' else getenv('ADMIN_BRAND_NAME')

# ** Settings for "donations" app **
STRIPE_PUBLISHABLE_KEY = '' if str(getenv('STRIPE_PUBLISHABLE_KEY')) == '' else str(getenv('STRIPE_PUBLISHABLE_KEY'))
STRIPE_SECRET_KEY = '' if str(getenv('STRIPE_SECRET_KEY')) == '' else str(getenv('STRIPE_SECRET_KEY'))
Expand Down Expand Up @@ -279,131 +277,16 @@
'task': 'raptorWeb.authprofiles.tasks.check_for_deletable_users',
'schedule': crontab(minute='*/15'),
},
'check_for_deletable_qr_images': {
'task': 'raptorWeb.authprofiles.tasks.check_for_deletable_qr_images',
'schedule': crontab(minute='*/5'),
}
}

# ** Settings for "django-jazzmin" app **
JAZZMIN_SETTINGS = {

"site_title": f"Admin {ADMIN_BRAND_NAME}",
"site_header": f"{ADMIN_BRAND_NAME}",
"site_brand": f"{ADMIN_BRAND_NAME}",
"site_logo_classes": "img-circle",
"welcome_sign": f"Welcome to {ADMIN_BRAND_NAME}",
"topmenu_links": [
{"name": "Return to Site", "url": "/", "new_window": False},
{"name": "Admin", "url": "/admin/", "new_window": False},
{"name": "Control Panel", "permissions": ["raptormc.panel"], "url": "/panel/", "new_window": False},
{"name": "Discord Bot", "permissions": ["raptormc.discord_bot"], "url": "/panel/discordbot/", "new_window": False},
{"name": "Server Actions", "permissions": ["raptormc.server_actions"], "url": "/panel/serveractions/", "new_window": False},
{"name": "Reporting", "permissions": ["raptormc.reporting"], "url": "/panel/reporting/", "new_window": False},
{"name": "Donations", "permissions": ["raptormc.donations"], "url": "/panel/donations/", "new_window": False},
{"app": "raptormc"},
{"app": "gameservers"},
{"app": "raptorbot"},
{"app": "donations"},
{"app": "staffapps"},
{"app": "authprofiles"},
{"name": "Settings", "permissions": ["raptormc.settings"], "url": "/panel/settings/", "new_window": False},
],
"usermenu_links": [
{"model": "auth.user"},
{"name": "Return to Site", "url": "/", "new_window": False},
{"name": "Admin", "url": "/admin/", "new_window": False},
{"name": "Control Panel", "permissions": ["raptormc.panel"], "url": "/panel/", "new_window": False},
{"name": "Discord Bot", "permissions": ["raptormc.discord_bot"], "url": "/panel/discordbot/", "new_window": False},
{"name": "Server Actions", "permissions": ["raptormc.server_actions"], "url": "/panel/serveractions/", "new_window": False},
{"name": "Reporting", "permissions": ["raptormc.reporting"], "url": "/panel/reporting/", "new_window": False},
{"name": "Donations", "permissions": ["raptormc.donations"], "url": "/panel/donations/", "new_window": False},
{"name": "Settings", "permissions": ["raptormc.settings"], "url": "/panel/settings/", "new_window": False},
],

# Sidebar
"show_sidebar": True,
"navigation_expanded": False,
"hide_apps": ['ipn'],
"order_with_respect_to": ["raptormc", "gameservers", "raptorbot", 'donations', "staffapps", "authprofiles"],
"custom_links": {
"raptorbot": [{
"name": "Discord Bot Control Panel",
"url": "/panel/discordbot/",
"icon": "fas fa-terminal",
"permissions": ["raptormc.discord_bot"]
}],
"gameservers": [{
"name": "Server Actions",
"url": "/panel/serveractions/",
"icon": "fas fa-terminal",
"permissions": ["raptormc.server_actions"]
}],
"donations": [{
"name": "Completed Donations",
"url": "/panel/donations/",
"icon": "fa fa-check-double",
"permissions": ["raptormc.donations"]
}],
"donations": [{
"name": "Completed Donations",
"url": "/panel/donations/",
"icon": "fa fa-check-double",
"permissions": ["raptormc.donations"]
}]
},
"icons": {
"raptormc": "fas fa-book",
"raptormc.InformativeText": "fas fa-scroll",
"raptormc.NavbarLink": "fas fa-map-marker",
"raptormc.NavbarDropdown": "fas fa-map-marker",
"raptormc.NavWidget": "fas fa-map-pin",
"raptormc.NavWidgetBar": "fas fa-map-pin",
"raptormc.NotificationToast": "fas fa-envelope-square",
"raptormc.Page": "fas fa-file",
"gameservers": "fas fa-gamepad",
"gameservers.Player": "fas fa-headset",
"gameservers.Server": "fas fa-server",
"raptorbot": "fas fa-robot",
"raptorbot.SentEmbedMessage": "fas fa-comment",
"raptorbot.GlobalAnnouncement": "fas fa-bullhorn",
"raptorbot.ServerAnnouncement": "fas fa-bullhorn",
"staffapps": "fas fa-book-reader",
"staffapps.ModeratorApplication": "fas fa-book-open",
"staffapps.AdminApplication": "fas fa-book-open",
"authprofiles": "fas fa-users",
"authprofiles.RaptorUserGroup": "fas fa-users",
"authprofiles.RaptorUser": "fas fa-user",
"authprofiles.UserProfileInfo": "fas fa-user-tag",
"authprofiles.DiscordUserInfo": "fas fa-user-tag",
"donations": "fa fa-coins",
"donations.DonationPackage": "fa fa-archive",
"donations.DonationServerCommand": "fa fa-terminal",
"donations.DonationDiscordRole": "fa fa-mask",

},
"default_icon_parents": "fas fa-chevron-circle-right",
"default_icon_children": "fas fa-circle",
"use_google_fonts_cdn": True,
"show_ui_builder": False,
JAZZMIN_SETTINGS = JAZZMIN_SETTINGS_ORIGINAL

}

JAZZMIN_UI_TWEAKS = {

"navbar_small_text": True,
"footer_small_text": True,
"body_small_text": False,
"brand_small_text": False,
"brand_colour": False,
"accent": "accent-lightblue",
"navbar": "navbar-gray-dark navbar-dark",
"no_navbar_border": False,
"navbar_fixed": True,
"layout_boxed": False,
"footer_fixed": False,
"sidebar_disable_expand": True,
"theme": "cyborg",
"actions_sticky_top": False,
"sidebar_nav_child_indent": True,

}
JAZZMIN_UI_TWEAKS = JAZZMIN_UI_TWEAKS_ORIGINAL

# ** Settings for "django_bootstrap5" app **
BOOTSTRAP5: dict = {
Expand Down
6 changes: 5 additions & 1 deletion raptorWeb/authprofiles/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,14 @@ class UserProfileEditForm(forms.ModelForm):
help_text="Indicates whether your profile appears on the user list, and whether it is publicly accessible.",
required = False
)
email: forms.EmailField = forms.EmailField(
label = 'Email',
help_text='The email address associated with your account.'
)

class Meta():
model: UserProfileInfo = UserProfileInfo
fields: tuple[str] = ('hidden_from_public', 'reset_toasts', 'picture_changed_manually', 'profile_picture', 'minecraft_username', 'favorite_modpack')
fields: tuple[str] = ('hidden_from_public', 'reset_toasts', 'picture_changed_manually', 'email', 'profile_picture', 'minecraft_username', 'favorite_modpack')

def clean(self):
"""
Expand Down
7 changes: 5 additions & 2 deletions raptorWeb/authprofiles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,16 @@ def update_user_profile_details(self, profile_edit_form: ModelForm, uploaded_fil

if profile_edit_form.cleaned_data["reset_toasts"] == True:
changed_user.toasts_seen = dict()
changed_user.save()

is_hidden = profile_edit_form.cleaned_data["hidden_from_public"]
if is_hidden != self.hidden_from_public:
self.hidden_from_public = is_hidden
self.hidden_from_public = is_hidden

if profile_edit_form.cleaned_data['email'] != changed_user.email:
changed_user.email = profile_edit_form.cleaned_data['email']

self.save()
changed_user.save()
return self

def save_profile_picture_from_url(self, url: str) -> None:
Expand Down
20 changes: 16 additions & 4 deletions raptorWeb/authprofiles/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@
"""

from logging import getLogger
from os.path import join
from os.path import join, getmtime
from os import listdir, remove
from datetime import datetime
from time import sleep
import time

from django.core.mail import send_mail
from django.template.loader import render_to_string
from django.conf import settings

from celery import shared_task

from raptorWeb.authprofiles.models import RaptorUser, DeletionQueueForUser
from raptorWeb.authprofiles.models import DeletionQueueForUser
from raptorWeb.raptormc.models import SiteInformation

LOGGER = getLogger('donations.tasks')
LOGGER = getLogger('authprofiles.tasks')
AUTH_TEMPLATE_DIR: str = getattr(settings, 'AUTH_TEMPLATE_DIR')
QR_MEDIA_DIR: str = join(getattr(settings, 'MEDIA_DIR'), 'totp/')
EMAIL_HOST_USER: str = getattr(settings, 'EMAIL_HOST_USER')

@shared_task
Expand All @@ -33,6 +35,16 @@ def check_for_deletable_users():
user.user.delete()
user.delete()

@shared_task
def check_for_deletable_qr_images():
"""
Check if any QR code images have existed for more than an hour, and delete them if so..
"""
epoch_time = int(time.time())

for qr_image in listdir(QR_MEDIA_DIR):
if (epoch_time - int(getmtime(join(QR_MEDIA_DIR, qr_image)))) / 60 >= 15:
remove(join(QR_MEDIA_DIR, qr_image))

@shared_task
def send_delete_request_email(deleting_user: list):
Expand Down
Loading

0 comments on commit 016538c

Please sign in to comment.