Skip to content

Commit

Permalink
feat: add calendar registration, extend slot days, format with black (#…
Browse files Browse the repository at this point in the history
…69)

* feat: add calendar registration, extend slot days, format with black

* chore: remove debug print statement

* chore: don't check for superuser status in register util function
  • Loading branch information
wipeautcrafter authored Jul 21, 2024
1 parent fe8b378 commit 6dde626
Show file tree
Hide file tree
Showing 19 changed files with 667 additions and 277 deletions.
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"editor.tabSize": 4,
"editor.detectIndentation": false
"editor.detectIndentation": false,
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
}
4 changes: 2 additions & 2 deletions aanmelden/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

# Only used in debug/devel mode
static_files = {
'/static': './aanmelden/static',
"/static": "./aanmelden/static",
}

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'aanmelden.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "aanmelden.settings")

application = ASGIApp(sio, get_asgi_application(), static_files=static_files)
116 changes: 58 additions & 58 deletions aanmelden/settings.example.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'jkweifgjewifjwiojfweiojfweiojfweiojfweiojfweijfweijfi'
SECRET_KEY = "jkweifgjewifjwiojfweiojfweiojfweiojfweiojfweijfweijfi"

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
Expand All @@ -23,82 +23,82 @@
# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'widget_tweaks',
'mathfilters',
'aanmelden.src'
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"widget_tweaks",
"mathfilters",
"aanmelden.src",
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]

ROOT_URLCONF = 'aanmelden.urls'
ROOT_URLCONF = "aanmelden.urls"

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'aanmelden', 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [os.path.join(BASE_DIR, "aanmelden", "templates")],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]

WSGI_APPLICATION = 'aanmelden.wsgi.application'
WSGI_APPLICATION = "aanmelden.wsgi.application"


# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
}
}
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]


# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
LANGUAGE_CODE = 'nl-nl'
TIME_ZONE = 'Europe/Amsterdam'
LANGUAGE_CODE = "nl-nl"
TIME_ZONE = "Europe/Amsterdam"
USE_I18N = True
USE_L10N = True
USE_TZ = True
Expand All @@ -107,29 +107,29 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = '/srv/static'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "aanmelden", "static"),
)
STATIC_URL = "/static/"
STATIC_ROOT = "/srv/static"
STATICFILES_DIRS = (os.path.join(BASE_DIR, "aanmelden", "static"),)

# IDP Settings
LOGIN_REDIRECT_URL = '/main/'
LOGIN_URL = '/'
IDP_CLIENT_ID = '<idp client id>'
IDP_CLIENT_SECRET = '<idp client secret>'
IDP_REDIRECT_URL = 'http://localhost:8000/oauth/'
IDP_AUTHORIZE_URL = 'https://leden.djoamersfoort.nl/o/authorize/'
IDP_TOKEN_URL = 'https://leden.djoamersfoort.nl/o/token/'
IDP_API_URL = 'https://leden.djoamersfoort.nl/api/v1/member/details'
IDP_LOGOUT_URL = 'https://leden.djoamersfoort.nl/accounts/logout/'
IDP_API_SCOPES = ['user/basic', 'user/names', 'user/email']
INTROSPECTION_CLIENT_ID = '<client id>'
INTROSPECTION_CLIENT_SECRET = '<client secret>'
IDP_INTROSPECTION_URL = 'https://leden.djoamersfoort.nl/o/introspect/'
OPENID_CONFIGURATION = 'https://leden.djoamersfoort.nl/o/.well-known/openid-configuration/'
LOGIN_REDIRECT_URL = "/main/"
LOGIN_URL = "/"
IDP_CLIENT_ID = "<idp client id>"
IDP_CLIENT_SECRET = "<idp client secret>"
IDP_REDIRECT_URL = "http://localhost:8000/oauth/"
IDP_AUTHORIZE_URL = "https://leden.djoamersfoort.nl/o/authorize/"
IDP_TOKEN_URL = "https://leden.djoamersfoort.nl/o/token/"
IDP_API_URL = "https://leden.djoamersfoort.nl/api/v1/member/details"
IDP_LOGOUT_URL = "https://leden.djoamersfoort.nl/accounts/logout/"
IDP_API_SCOPES = ["user/basic", "user/names", "user/email"]
INTROSPECTION_CLIENT_ID = "<client id>"
INTROSPECTION_CLIENT_SECRET = "<client secret>"
IDP_INTROSPECTION_URL = "https://leden.djoamersfoort.nl/o/introspect/"
OPENID_CONFIGURATION = (
"https://leden.djoamersfoort.nl/o/.well-known/openid-configuration/"
)
# Corvee is allowed to call the 'presence' API
API_CLIENT_WHITELIST = ['xxxxxxx']
API_CLIENT_WHITELIST = ["xxxxxxx"]

SESSION_COOKIE_SECURE = True
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
Expand Down
4 changes: 1 addition & 3 deletions aanmelden/sockets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import socketio

sio = socketio.AsyncServer(
async_mode='asgi', cors_allowed_origins='*'
)
sio = socketio.AsyncServer(async_mode="asgi", cors_allowed_origins="*")
6 changes: 3 additions & 3 deletions aanmelden/src/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

@admin.register(Presence)
class PresenceAdmin(admin.ModelAdmin):
date_hierarchy = 'date'
list_filter = ('user',)
date_hierarchy = "date"
list_filter = ("user",)


# Define an inline admin descriptor for User model
# which acts a bit like a singleton
class UserInfoInline(admin.StackedInline):
model = UserInfo
can_delete = False
verbose_name_plural = 'User info'
verbose_name_plural = "User info"


# Define a new User admin
Expand Down
Loading

0 comments on commit 6dde626

Please sign in to comment.