mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2026-01-01 20:27:02 -05:00
feat: Implement initial schema and add various API, service, and management command enhancements across the application.
This commit is contained in:
@@ -108,7 +108,7 @@ def sync_user_role_with_groups(sender, instance, **kwargs):
|
||||
User.Roles.MODERATOR,
|
||||
]:
|
||||
instance.is_staff = True
|
||||
elif old_instance.role in [
|
||||
elif old_instance.role in [ # noqa: SIM102
|
||||
User.Roles.ADMIN,
|
||||
User.Roles.MODERATOR,
|
||||
]:
|
||||
@@ -119,9 +119,7 @@ def sync_user_role_with_groups(sender, instance, **kwargs):
|
||||
except User.DoesNotExist:
|
||||
pass
|
||||
except Exception as e:
|
||||
print(
|
||||
f"Error syncing role with groups for user {instance.username}: {str(e)}"
|
||||
)
|
||||
print(f"Error syncing role with groups for user {instance.username}: {str(e)}")
|
||||
|
||||
|
||||
def create_default_groups():
|
||||
@@ -200,19 +198,19 @@ def log_successful_login(sender, user, request, **kwargs):
|
||||
"""
|
||||
try:
|
||||
# Get IP address
|
||||
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
|
||||
ip_address = x_forwarded_for.split(',')[0].strip() if x_forwarded_for else request.META.get('REMOTE_ADDR')
|
||||
x_forwarded_for = request.META.get("HTTP_X_FORWARDED_FOR")
|
||||
ip_address = x_forwarded_for.split(",")[0].strip() if x_forwarded_for else request.META.get("REMOTE_ADDR")
|
||||
|
||||
# Get user agent
|
||||
user_agent = request.META.get('HTTP_USER_AGENT', '')[:500]
|
||||
user_agent = request.META.get("HTTP_USER_AGENT", "")[:500]
|
||||
|
||||
# Determine login method from session or request
|
||||
login_method = 'PASSWORD'
|
||||
if hasattr(request, 'session'):
|
||||
sociallogin = getattr(request, '_sociallogin', None)
|
||||
login_method = "PASSWORD"
|
||||
if hasattr(request, "session"):
|
||||
sociallogin = getattr(request, "_sociallogin", None)
|
||||
if sociallogin:
|
||||
provider = sociallogin.account.provider.upper()
|
||||
if provider in ['GOOGLE', 'DISCORD']:
|
||||
if provider in ["GOOGLE", "DISCORD"]:
|
||||
login_method = provider
|
||||
|
||||
# Create login history entry
|
||||
|
||||
Reference in New Issue
Block a user