Compare commits
1 Commits
master
...
dj-keycloa
Author | SHA1 | Date | |
---|---|---|---|
f00f36fba3 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
|||||||
[submodule "public/libcasa/themes/risotto"]
|
|
||||||
path = public/libcasa/themes/risotto
|
|
||||||
url = https://github.com/joeroe/risotto.git
|
|
@ -1,3 +0,0 @@
|
|||||||
from django.contrib import admin
|
|
||||||
|
|
||||||
# Register your models here.
|
|
@ -1,6 +0,0 @@
|
|||||||
from django.apps import AppConfig
|
|
||||||
|
|
||||||
|
|
||||||
class ControlConfig(AppConfig):
|
|
||||||
default_auto_field = 'django.db.models.BigAutoField'
|
|
||||||
name = 'control'
|
|
@ -1,34 +0,0 @@
|
|||||||
from django.db import models
|
|
||||||
|
|
||||||
class ScheduledTask(models.Model):
|
|
||||||
from control.tasks import REGISTERED_TASKS
|
|
||||||
|
|
||||||
class CatchupMode(models.IntegerChoices):
|
|
||||||
SKIP = 0, ('SKIP TO LATEST')
|
|
||||||
EXEC = 1, ('EXECUTE ALL')
|
|
||||||
|
|
||||||
class Interval(models.IntegerChoices):
|
|
||||||
HOURS = 1, ('HOURS')
|
|
||||||
DAYS = 24, ('DAYS')
|
|
||||||
WEEKS = 168, ('WEEKS')
|
|
||||||
|
|
||||||
active = models.BooleanField(default=False)
|
|
||||||
name = models.CharField(max_length=128)
|
|
||||||
action = models.CharField(max_length=128, choices=zip(
|
|
||||||
REGISTERED_TASKS.keys(), REGISTERED_TASKS.keys()))
|
|
||||||
kwargs = models.JSONField(blank=True, null=True)
|
|
||||||
repeat = models.IntegerField('Repeat Every', default=0)
|
|
||||||
repeat_interval = models.IntegerField(
|
|
||||||
'Interval', choices=Interval.choices, default=1)
|
|
||||||
start_datetime = models.DateTimeField()
|
|
||||||
end_datetime = models.DateTimeField(blank=True, null=True)
|
|
||||||
next_cycle = models.DateTimeField(blank=True, null=True)
|
|
||||||
catchup_mode = models.IntegerField(
|
|
||||||
default=0, choices=CatchupMode.choices)
|
|
||||||
|
|
||||||
class Meta():
|
|
||||||
verbose_name = 'Scheduled Task'
|
|
||||||
verbose_name_plural = 'Scheduled Tasks'
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.name
|
|
@ -1,9 +0,0 @@
|
|||||||
from datetime import datetime, timezone, timedelta,
|
|
||||||
|
|
||||||
### TASKS ###
|
|
||||||
|
|
||||||
# def test_task(comms: dict, debug=False):
|
|
||||||
# timestamp = datetime.now(tz=timezone.utc).strftime("%b %d %Y %H:%M")
|
|
||||||
# text = "Test Task fired at " + timestamp
|
|
||||||
# blocks = [make_section(text)]
|
|
||||||
# process_comms(comms, blocks, debug)
|
|
@ -1,5 +0,0 @@
|
|||||||
from django.contrib import admin
|
|
||||||
|
|
||||||
from posts.models import *
|
|
||||||
|
|
||||||
admin.site.register(Post)
|
|
@ -1,11 +0,0 @@
|
|||||||
from django.urls import path, include
|
|
||||||
from rest_framework.routers import DefaultRouter
|
|
||||||
from . import views
|
|
||||||
|
|
||||||
router = DefaultRouter()
|
|
||||||
router.register(r'posts', views.PostsViewSet)
|
|
||||||
# router.register(r'users', views.UserViewSet)
|
|
||||||
|
|
||||||
urlpatterns = [
|
|
||||||
path('', include(router.urls)),
|
|
||||||
]
|
|
@ -1,30 +0,0 @@
|
|||||||
from django.contrib.auth.models import User
|
|
||||||
from django.shortcuts import render
|
|
||||||
from snippets.serializers import UserSerializer
|
|
||||||
from .models import Post
|
|
||||||
from .serializers import PostSerializer
|
|
||||||
from posts.permissions import IsOwnerOrReadOnly
|
|
||||||
from rest_framework import permissions, renderers
|
|
||||||
from rest_framework.reverse import reverse
|
|
||||||
from rest_framework import viewsets
|
|
||||||
from rest_framework.decorators import action
|
|
||||||
from rest_framework.response import Response
|
|
||||||
|
|
||||||
class PostsViewSet(viewsets.ModelViewSet):
|
|
||||||
"""
|
|
||||||
docstring
|
|
||||||
"""
|
|
||||||
queryset = Post.objects.all()
|
|
||||||
serializer_class = PostSerializer
|
|
||||||
permission_classes = [permissions.IsAuthenticatedOrReadOnly,
|
|
||||||
IsOwnerOrReadOnly]
|
|
||||||
|
|
||||||
def perform_create(self, serializer):
|
|
||||||
serializer.save(owner=self.request.user)
|
|
||||||
|
|
||||||
class UserViewSet(viewsets.ReadOnlyModelViewSet):
|
|
||||||
"""
|
|
||||||
This viewset automatically provides `list` and `retrieve` actions.
|
|
||||||
"""
|
|
||||||
queryset = User.objects.all()
|
|
||||||
serializer_class = UserSerializer
|
|
@ -1,3 +0,0 @@
|
|||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
# Create your tests here.
|
|
@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
title: "{{ replace .Name "-" " " | title }}"
|
|
||||||
date: {{ .Date }}
|
|
||||||
draft: true
|
|
||||||
---
|
|
||||||
|
|
@ -1,53 +0,0 @@
|
|||||||
baseURL: https://liberta.casa
|
|
||||||
theme: risotto
|
|
||||||
languageCode: en-us
|
|
||||||
title: Liberta Casa
|
|
||||||
paginate: 3
|
|
||||||
authors: [ Georg Pfuetzenreuter, Pratyush Desai ]
|
|
||||||
|
|
||||||
# Automatically add content sections to main menu
|
|
||||||
sectionPagesMenu: main
|
|
||||||
|
|
||||||
params:
|
|
||||||
theme:
|
|
||||||
palette: monokai-dark
|
|
||||||
mode: dark-mode
|
|
||||||
about:
|
|
||||||
title: Liberta Casa
|
|
||||||
description: 'For those who FLOSS shall be free.'
|
|
||||||
logo: images/logo.png
|
|
||||||
socialLinks:
|
|
||||||
- icon: fab fa-irc
|
|
||||||
title: IRC
|
|
||||||
url: 'https://liberta.casa/gamja'
|
|
||||||
- icon: fas fa-envelope
|
|
||||||
title: Email
|
|
||||||
url: 'mailto:hello@liberta.casa'
|
|
||||||
|
|
||||||
menu:
|
|
||||||
main:
|
|
||||||
- identifier: about
|
|
||||||
name: About
|
|
||||||
url: /about/
|
|
||||||
weight: 10
|
|
||||||
- identifier: rules
|
|
||||||
name: Rules
|
|
||||||
url: /rules/
|
|
||||||
weight: 10
|
|
||||||
- identifier: faqs
|
|
||||||
name: FAQ
|
|
||||||
url: /faqs/
|
|
||||||
weight: 10
|
|
||||||
- identifier: accounts
|
|
||||||
name: Account
|
|
||||||
url: /accounts/
|
|
||||||
weight: 10
|
|
||||||
- identifier: tools
|
|
||||||
name: Tools
|
|
||||||
url: /tools/
|
|
||||||
weight: 10
|
|
||||||
|
|
||||||
taxonomies:
|
|
||||||
category: categories
|
|
||||||
tag: tags
|
|
||||||
series: series
|
|
@ -1,3 +0,0 @@
|
|||||||
+++
|
|
||||||
author = "LibCasa Authors"
|
|
||||||
+++
|
|
@ -1,7 +0,0 @@
|
|||||||
+++
|
|
||||||
title = "About"
|
|
||||||
description = "Liberta Casa, providing services.. for some reason."
|
|
||||||
date = "2021-12-12"
|
|
||||||
aliases = ["about-us", "about-libertacasa", "contact"]
|
|
||||||
author = "LibCasa Authors"
|
|
||||||
+++
|
|
@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
title: "Accounts"
|
|
||||||
date: 2022-01-08T15:14:39+05:30
|
|
||||||
draft: true
|
|
||||||
---
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
title: "Faqs"
|
|
||||||
date: 2022-01-08T15:14:13+05:30
|
|
||||||
draft: true
|
|
||||||
---
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
+++
|
|
||||||
title = "Rules"
|
|
||||||
+++
|
|
@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
title: "Tools"
|
|
||||||
date: 2022-01-08T15:14:47+05:30
|
|
||||||
draft: true
|
|
||||||
---
|
|
||||||
|
|
@ -1 +0,0 @@
|
|||||||
Subproject commit 07f1b3ecfd4202a69847d47c89ece4e4d01278c4
|
|
@ -1,7 +1,19 @@
|
|||||||
asgiref==3.4.1
|
asgiref==3.4.1
|
||||||
|
certifi==2021.10.8
|
||||||
|
charset-normalizer==2.0.10
|
||||||
Django==4.0
|
Django==4.0
|
||||||
|
django-keycloak==0.1.2.dev0
|
||||||
djangorestframework==3.13.1
|
djangorestframework==3.13.1
|
||||||
|
ecdsa==0.17.0
|
||||||
|
idna==3.3
|
||||||
psycopg2==2.9.2
|
psycopg2==2.9.2
|
||||||
|
pyasn1==0.4.8
|
||||||
Pygments==2.11.2
|
Pygments==2.11.2
|
||||||
|
python-jose==3.3.0
|
||||||
|
python-keycloak-client==0.2.3
|
||||||
pytz==2021.3
|
pytz==2021.3
|
||||||
|
requests==2.27.1
|
||||||
|
rsa==4.8
|
||||||
|
six==1.16.0
|
||||||
sqlparse==0.4.2
|
sqlparse==0.4.2
|
||||||
|
urllib3==1.26.8
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
|
|
||||||
|
|
5
website/blog/admin.py
Normal file
5
website/blog/admin.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
from blog.models import *
|
||||||
|
|
||||||
|
admin.site.register(Post)
|
@ -1,6 +1,6 @@
|
|||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
class PostsConfig(AppConfig):
|
class BlogConfig(AppConfig):
|
||||||
default_auto_field = 'django.db.models.BigAutoField'
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
name = 'posts'
|
name = 'blog'
|
7
website/blog/urls.py
Normal file
7
website/blog/urls.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from django.urls import path, include
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('blogs/', include('blog.urls')),
|
||||||
|
path('', views.index, name='index')
|
||||||
|
]
|
BIN
website/db.sqlite3
Normal file
BIN
website/db.sqlite3
Normal file
Binary file not shown.
@ -11,26 +11,10 @@ https://docs.djangoproject.com/en/4.0/ref/settings/
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import os
|
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
|
||||||
## ENVARS ##
|
|
||||||
|
|
||||||
POSTGRES_DB = os.getenv('POSTGRES_DB')
|
|
||||||
POSTGRES_USER = os.getenv('POSTGRES_USER')
|
|
||||||
POSTGRES_PASSWORD = os.getenv('POSTGRES_PASSWORD')
|
|
||||||
POSTGRES_HOST = os.getenv('POSTGRES_HOST')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
|
||||||
DEBUG = False
|
|
||||||
if os.getenv('DEBUG') == 'True':
|
|
||||||
DEBUG = True
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Quick-start development settings - unsuitable for production
|
# Quick-start development settings - unsuitable for production
|
||||||
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
|
||||||
@ -55,9 +39,9 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'rest_framework',
|
'rest_framework',
|
||||||
'snippets.apps.SnippetsConfig',
|
'snippets.apps.SnippetsConfig',
|
||||||
'posts.apps.PostsConfig',
|
'blog.apps.BlogConfig',
|
||||||
'api.apps.ApiConfig',
|
'api.apps.ApiConfig',
|
||||||
'control.apps.ControlConfig',
|
'django_keycloak.apps.KeycloakAppConfig',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
@ -68,6 +52,7 @@ MIDDLEWARE = [
|
|||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
|
'django_keycloak.middleware.BaseKeycloakMiddleware',
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = 'website.urls'
|
ROOT_URLCONF = 'website.urls'
|
||||||
@ -94,18 +79,6 @@ WSGI_APPLICATION = 'website.wsgi.application'
|
|||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
|
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
||||||
'NAME': POSTGRES_DB,
|
|
||||||
'USER': POSTGRES_USER,
|
|
||||||
'PASSWORD': POSTGRES_PASSWORD,
|
|
||||||
'HOST': POSTGRES_HOST,
|
|
||||||
'PORT': '5432',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if os.getenv('DEV') == 'true':
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
@ -164,25 +137,8 @@ REST_FRAMEWORK = {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
# LOGGING = {
|
AUTHENTICATION_BACKENDS = [
|
||||||
# 'version': 1,
|
'django_keycloak.auth.backends.KeycloakAuthorizationCodeBackend',
|
||||||
# 'disable_existing_loggers': False,
|
]
|
||||||
# 'handlers': {
|
|
||||||
# 'file': {
|
LOGIN_URL = 'keycloak_login'
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# 'class': 'logging.FileHandler',
|
|
||||||
# 'filename': './debug.log',
|
|
||||||
# },
|
|
||||||
# 'error_file': {
|
|
||||||
# 'level': 'ERROR',
|
|
||||||
# 'class': 'logging.FileHandler',
|
|
||||||
# 'filename': './error.log',
|
|
||||||
# },
|
|
||||||
# },
|
|
||||||
# 'loggers': {
|
|
||||||
# 'django': {
|
|
||||||
# 'handlers': ['file', 'error_file'],
|
|
||||||
# 'propagate': True,
|
|
||||||
# },
|
|
||||||
# },
|
|
||||||
# }
|
|
@ -13,15 +13,16 @@ Including another URLconf
|
|||||||
1. Import the include() function: from django.urls import include, path
|
1. Import the include() function: from django.urls import include, path
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
|
from django import urls
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
path('snippets/', include('snippets.urls')),
|
path('', include('snippets.urls')),
|
||||||
path('posts/', include('posts.urls'))
|
|
||||||
]
|
]
|
||||||
|
|
||||||
urlpatterns += [
|
urlpatterns += [
|
||||||
path('api-auth/', include('rest_framework.urls')),
|
path('api-auth/', include('rest_framework.urls')),
|
||||||
|
path(r'^keycloak/', include('django_keycloak.urls')),
|
||||||
]
|
]
|
Reference in New Issue
Block a user