Skip to content

Commit

Permalink
work with forked guest-uesr lib
Browse files Browse the repository at this point in the history
  • Loading branch information
m4ra committed Feb 13, 2025
1 parent bdbd3c8 commit c3e2c5d
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 53 deletions.
10 changes: 5 additions & 5 deletions adhocracy-plus/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
"widget_tweaks",
"rest_framework",
"rest_framework.authtoken",
"guest_user",
"guest_user.contrib.allauth",
# JWT authentication
"rest_framework_simplejwt.token_blacklist",
"django_filters",
"allauth",
"allauth.account",
"allauth.socialaccount",
"guest_user",
# "guest_user.contrib.allauth",
"rules.apps.AutodiscoverRulesConfig",
"easy_thumbnails",
"parler",
Expand Down Expand Up @@ -710,8 +710,8 @@
}

GUEST_USER = {
'NAME_GENERATOR': 'guest_user.functions.generate_uuid_username', # Default option
"NAME_GENERATOR": "guest_user.functions.generate_uuid_username", # Default option
}

GUEST_USER_MODEL = "a4_candy_users.CustomGuestUser"
# GUEST_USER_MODEL = "users.CustomGuestUser"
# GUEST_USER_MODEL = "a4_candy_users.CustomGuestUser"
# GUEST_USER_MODEL = "users.CustomGuestUser"
4 changes: 1 addition & 3 deletions apps/users/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from django.contrib.auth.signals import user_logged_in
from django.utils.translation import gettext_lazy as _

# from .guests import CustomGuestUser
# import guests
# __all__ = ['CustomGuest']

# default_app_config = "users.apps.UsersConfig"


USERNAME_REGEX = r"^[\w]+[ \w.@+-]*$"
Expand Down
9 changes: 0 additions & 9 deletions apps/users/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,3 @@
class Config(AppConfig):
name = "apps.users"
label = "a4_candy_users"


# class UsersConfig(AppConfig):
# name = "apps.users"
# label = "a4_candy_users"

# def ready(self):
# # Import the model here to ensure it's registered
# from .guests import CustomGuestUser
12 changes: 0 additions & 12 deletions apps/users/guests.py

This file was deleted.

25 changes: 1 addition & 24 deletions apps/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,10 @@
from adhocracy4.projects.enums import Access
from adhocracy4.projects.models import Project
from apps.organisations.models import OrganisationTermsOfUse
# from .guests import CustomGuestUser
# __all__ = ['CustomGuest']

from . import USERNAME_INVALID_MESSAGE
from . import USERNAME_REGEX

from guest_user.models import Guest, GuestManager

# didn't work
# from django.utils.module_loading import import_string

# def get_guest_model():
# Guest = import_string('guest_user.models.Guest')
# return Guest

# def get_guest_manager():
# GuestManager = import_string('guest_user.models.GuestManager')
# return GuestManager

class CustomGuestManager(GuestManager):
def create_guest_user(self, request=None, username=None):
# is just User in the example...
user = CustomGuestUser.objects.create(username=username, email='guest' + username + '@liqd.net')
return user

class CustomGuestUser(Guest):
objects = CustomGuestManager()


class User(auth_models.AbstractBaseUser, auth_models.PermissionsMixin):
username = models.CharField(
Expand Down Expand Up @@ -150,6 +126,7 @@ class User(auth_models.AbstractBaseUser, auth_models.PermissionsMixin):
objects = auth_models.UserManager()

USERNAME_FIELD = "username"
PASSWORD_FIELD = "username"
REQUIRED_FIELDS = ["email"]

def get_projects_follow_list(self, exclude_private_projects=False):
Expand Down
1 change: 1 addition & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ git+https://github.com/liqd/[email protected]#egg=adhocracy4
brotli==1.1.0
django-cloudflare-push==0.2.2
django_csp==3.8
django-guest-user @ git+https://github.com/liqd/django-guest-user.git@mk-2025-add-email-password-to-guest-user
django-parler==2.3
djangorestframework-simplejwt==5.3.1
sentry-sdk==2.19.2
Expand Down

0 comments on commit c3e2c5d

Please sign in to comment.