Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b84f73cbf | ||
|
|
6cf3e6ef6b | ||
|
|
c4fe55246b | ||
|
|
efc9b8e10b | ||
|
|
a9d639db55 | ||
|
|
fd249adbbb | ||
|
|
c9ef27ea18 | ||
|
|
c5d42c4d57 | ||
|
|
17e61ca66f | ||
|
|
04d6cd0351 | ||
|
|
01300ba54a | ||
|
|
71549178ff | ||
|
|
6fdca30b98 | ||
|
|
ab18fa6624 | ||
|
|
0ea875865d | ||
|
|
aa76bbf74b | ||
|
|
fd365ef3fb | ||
|
|
16f09b429a | ||
|
|
178fca2458 | ||
|
|
15c8c12356 | ||
|
|
fac00fc3a7 | ||
|
|
72dd180cca | ||
|
|
8747a585fe | ||
|
|
55a1ff6260 | ||
|
|
b701d75a50 | ||
|
|
60e6db452c | ||
|
|
284998f74e | ||
|
|
42c8efa1a6 |
24
.gitea/workflows/django-backendtests.yaml
Normal file
24
.gitea/workflows/django-backendtests.yaml
Normal file
@ -0,0 +1,24 @@
|
||||
name: Django Backend Validation
|
||||
run-name: ${{ gitea.actor }} is running Django Tests
|
||||
on: [push]
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.10", "3.11", "3.12"]
|
||||
os: [ubuntu-latest, debian-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
- name: Run Tests
|
||||
run: |
|
||||
python manage.py test
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -20,6 +20,8 @@ media
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
.idea/
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
|
||||
0
person/__init__.py
Normal file
0
person/__init__.py
Normal file
3
person/admin.py
Normal file
3
person/admin.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
6
person/apps.py
Normal file
6
person/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class PersonConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'person'
|
||||
23
person/migrations/0001_initial.py
Normal file
23
person/migrations/0001_initial.py
Normal file
@ -0,0 +1,23 @@
|
||||
# Generated by Django 5.1 on 2024-09-03 14:28
|
||||
|
||||
import uuid
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='quote_person_group',
|
||||
fields=[
|
||||
('label', models.CharField(max_length=255)),
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)),
|
||||
('description', models.TextField(null=True)),
|
||||
],
|
||||
),
|
||||
]
|
||||
@ -0,0 +1,17 @@
|
||||
# Generated by Django 5.1 on 2024-09-03 14:29
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('person', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameModel(
|
||||
old_name='quote_person_group',
|
||||
new_name='QuotePersonGroup',
|
||||
),
|
||||
]
|
||||
0
person/migrations/__init__.py
Normal file
0
person/migrations/__init__.py
Normal file
7
person/models.py
Normal file
7
person/models.py
Normal file
@ -0,0 +1,7 @@
|
||||
from django.db import models
|
||||
import uuid
|
||||
# Create your models here.
|
||||
class QuotePersonGroup(models.Model):
|
||||
label = models.CharField(max_length=255, null=False, unique=False)
|
||||
id = models.UUIDField(default=uuid.uuid4, editable = False, primary_key = True, unique = True)
|
||||
description = models.TextField(null=True)
|
||||
3
person/tests.py
Normal file
3
person/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
3
person/views.py
Normal file
3
person/views.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
0
quote/__init__.py
Normal file
0
quote/__init__.py
Normal file
3
quote/admin.py
Normal file
3
quote/admin.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
6
quote/apps.py
Normal file
6
quote/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class QuoteConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'quote'
|
||||
0
quote/migrations/__init__.py
Normal file
0
quote/migrations/__init__.py
Normal file
3
quote/models.py
Normal file
3
quote/models.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
3
quote/tests.py
Normal file
3
quote/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
3
quote/views.py
Normal file
3
quote/views.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
28
requirements.txt
Normal file
28
requirements.txt
Normal file
@ -0,0 +1,28 @@
|
||||
arrow==1.3.0
|
||||
asgiref==3.8.1
|
||||
binaryornot==0.4.4
|
||||
certifi==2024.7.4
|
||||
chardet==5.2.0
|
||||
charset-normalizer==3.3.2
|
||||
click==8.1.7
|
||||
cookiecutter==2.6.0
|
||||
Django==5.1
|
||||
django-browser-reload==1.15.0
|
||||
django-tailwind==3.8.0
|
||||
idna==3.8
|
||||
Jinja2==3.1.4
|
||||
markdown-it-py==3.0.0
|
||||
MarkupSafe==2.1.5
|
||||
mdurl==0.1.2
|
||||
Pygments==2.18.0
|
||||
python-dateutil==2.9.0.post0
|
||||
python-slugify==8.0.4
|
||||
PyYAML==6.0.2
|
||||
requests==2.32.3
|
||||
rich==13.8.0
|
||||
six==1.16.0
|
||||
sqlparse==0.5.1
|
||||
text-unidecode==1.3
|
||||
types-python-dateutil==2.9.0.20240821
|
||||
urllib3==2.2.2
|
||||
uuid==1.30
|
||||
0
settings/__init__.py
Normal file
0
settings/__init__.py
Normal file
3
settings/admin.py
Normal file
3
settings/admin.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
6
settings/apps.py
Normal file
6
settings/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class SettingsConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'settings'
|
||||
23
settings/migrations/0001_initial.py
Normal file
23
settings/migrations/0001_initial.py
Normal file
@ -0,0 +1,23 @@
|
||||
# Generated by Django 5.1 on 2024-08-28 13:28
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='settingsParameter',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('parameter_name', models.CharField(max_length=255, unique=True)),
|
||||
('parameter_value', models.CharField(max_length=255)),
|
||||
('parameter_class', models.CharField(blank=True, max_length=255)),
|
||||
],
|
||||
),
|
||||
]
|
||||
@ -0,0 +1,22 @@
|
||||
# Generated by Django 5.1 on 2024-08-28 13:29
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('settings', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='settingsparameter',
|
||||
name='id',
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='settingsparameter',
|
||||
name='parameter_name',
|
||||
field=models.CharField(max_length=255, primary_key=True, serialize=False, unique=True),
|
||||
),
|
||||
]
|
||||
@ -0,0 +1,47 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
from settings.models import settingsParameter
|
||||
|
||||
preloadData = [
|
||||
{
|
||||
"name": "openid_client_id",
|
||||
"value": "",
|
||||
"category": "openid"
|
||||
},{
|
||||
"name": "openid_client_secret",
|
||||
"value": "",
|
||||
"category": "openid"
|
||||
},{
|
||||
"name": "openid_autodiscoveryurl",
|
||||
"value": "",
|
||||
"category": "openid"
|
||||
},{
|
||||
"name": "openid_scopes",
|
||||
"value": "",
|
||||
"category": "openid"
|
||||
},{
|
||||
"name": "openid_group_attribute",
|
||||
"value": "",
|
||||
"category": "openid"
|
||||
},{
|
||||
"name": "openid_admin_group_name",
|
||||
"value": "",
|
||||
"category": "openid"
|
||||
}
|
||||
]
|
||||
|
||||
def create_datafields(apps, database_schema):
|
||||
for datapoint in preloadData:
|
||||
se = settingsParameter()
|
||||
se.parameter_name = datapoint["name"]
|
||||
se.parameter_value = datapoint["value"]
|
||||
se.parameter_class = datapoint["category"]
|
||||
se.save()
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('settings', '0002_remove_settingsparameter_id_and_more'),
|
||||
]
|
||||
operations = [
|
||||
migrations.RunPython(create_datafields),
|
||||
]
|
||||
0
settings/migrations/__init__.py
Normal file
0
settings/migrations/__init__.py
Normal file
7
settings/models.py
Normal file
7
settings/models.py
Normal file
@ -0,0 +1,7 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
class settingsParameter(models.Model):
|
||||
parameter_name = models.CharField(max_length=255, unique=True, blank=False, primary_key=True)
|
||||
parameter_value = models.CharField(max_length=255, blank=False)
|
||||
parameter_class = models.CharField(max_length=255, blank=True)
|
||||
3
settings/tests.py
Normal file
3
settings/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
6
settings/urls.py
Normal file
6
settings/urls.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.urls import path
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.home, name="home"),
|
||||
]
|
||||
7
settings/views.py
Normal file
7
settings/views.py
Normal file
@ -0,0 +1,7 @@
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
|
||||
def home(request):
|
||||
return HttpResponse('')
|
||||
0
theme/__init__.py
Normal file
0
theme/__init__.py
Normal file
5
theme/apps.py
Normal file
5
theme/apps.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ThemeConfig(AppConfig):
|
||||
name = 'theme'
|
||||
1
theme/static_src/.gitignore
vendored
Normal file
1
theme/static_src/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
||||
1537
theme/static_src/package-lock.json
generated
Normal file
1537
theme/static_src/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
28
theme/static_src/package.json
Normal file
28
theme/static_src/package.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "theme",
|
||||
"version": "3.8.0",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"start": "npm run dev",
|
||||
"build": "npm run build:clean && npm run build:tailwind",
|
||||
"build:clean": "rimraf ../static/css/dist",
|
||||
"build:tailwind": "cross-env NODE_ENV=production tailwindcss --postcss -i ./src/styles.css -o ../static/css/dist/styles.css --minify",
|
||||
"dev": "cross-env NODE_ENV=development tailwindcss --postcss -i ./src/styles.css -o ../static/css/dist/styles.css -w",
|
||||
"tailwindcss": "node ./node_modules/tailwindcss/lib/cli.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@tailwindcss/aspect-ratio": "^0.4.2",
|
||||
"@tailwindcss/forms": "^0.5.7",
|
||||
"@tailwindcss/typography": "^0.5.10",
|
||||
"cross-env": "^7.0.3",
|
||||
"postcss": "^8.4.32",
|
||||
"postcss-import": "^15.1.0",
|
||||
"postcss-nested": "^6.0.1",
|
||||
"postcss-simple-vars": "^7.0.1",
|
||||
"rimraf": "^5.0.5",
|
||||
"tailwindcss": "^3.4.0"
|
||||
}
|
||||
}
|
||||
7
theme/static_src/postcss.config.js
Normal file
7
theme/static_src/postcss.config.js
Normal file
@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
plugins: {
|
||||
"postcss-import": {},
|
||||
"postcss-simple-vars": {},
|
||||
"postcss-nested": {}
|
||||
},
|
||||
}
|
||||
3
theme/static_src/src/styles.css
Normal file
3
theme/static_src/src/styles.css
Normal file
@ -0,0 +1,3 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
57
theme/static_src/tailwind.config.js
Normal file
57
theme/static_src/tailwind.config.js
Normal file
@ -0,0 +1,57 @@
|
||||
/**
|
||||
* This is a minimal config.
|
||||
*
|
||||
* If you need the full config, get it from here:
|
||||
* https://unpkg.com/browse/tailwindcss@latest/stubs/defaultConfig.stub.js
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
content: [
|
||||
/**
|
||||
* HTML. Paths to Django template files that will contain Tailwind CSS classes.
|
||||
*/
|
||||
|
||||
/* Templates within theme app (<tailwind_app_name>/templates), e.g. base.html. */
|
||||
'../templates/**/*.html',
|
||||
|
||||
/*
|
||||
* Main templates directory of the project (BASE_DIR/templates).
|
||||
* Adjust the following line to match your project structure.
|
||||
*/
|
||||
'../../templates/**/*.html',
|
||||
|
||||
/*
|
||||
* Templates in other django apps (BASE_DIR/<any_app_name>/templates).
|
||||
* Adjust the following line to match your project structure.
|
||||
*/
|
||||
'../../**/templates/**/*.html',
|
||||
|
||||
/**
|
||||
* JS: If you use Tailwind CSS in JavaScript, uncomment the following lines and make sure
|
||||
* patterns match your project structure.
|
||||
*/
|
||||
/* JS 1: Ignore any JavaScript in node_modules folder. */
|
||||
// '!../../**/node_modules',
|
||||
/* JS 2: Process all JavaScript files in the project. */
|
||||
// '../../**/*.js',
|
||||
|
||||
/**
|
||||
* Python: If you use Tailwind CSS classes in Python, uncomment the following line
|
||||
* and make sure the pattern below matches your project structure.
|
||||
*/
|
||||
// '../../**/*.py'
|
||||
],
|
||||
theme: {
|
||||
extend: {},
|
||||
},
|
||||
plugins: [
|
||||
/**
|
||||
* '@tailwindcss/forms' is the forms plugin that provides a minimal styling
|
||||
* for forms. If you don't like it or have own styling for forms,
|
||||
* comment the line below to disable '@tailwindcss/forms'.
|
||||
*/
|
||||
require('@tailwindcss/forms'),
|
||||
require('@tailwindcss/typography'),
|
||||
require('@tailwindcss/aspect-ratio'),
|
||||
],
|
||||
}
|
||||
18
theme/templates/base.html
Normal file
18
theme/templates/base.html
Normal file
@ -0,0 +1,18 @@
|
||||
{% load static tailwind_tags %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<title>Zitate</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
{% tailwind_css %}
|
||||
</head>
|
||||
|
||||
<body class="bg-gray-50 dark:bg-gray-900 dark:text-white-90">
|
||||
<div class="container mx-auto">
|
||||
{% block content %}
|
||||
{% endblock content %}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
45
theme/templates/login.html
Normal file
45
theme/templates/login.html
Normal file
@ -0,0 +1,45 @@
|
||||
{%extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<section class="bg-gray-50 dark:bg-gray-900">
|
||||
<div class="flex flex-col items-center justify-center px-6 py-8 mx-auto md:h-screen lg:py-0">
|
||||
<div class="w-full bg-white rounded-lg shadow dark:border md:mt-0 sm:max-w-md xl:p-0 dark:bg-gray-800 dark:border-gray-700">
|
||||
<div class="p-6 space-y-4 md:space-y-6 sm:p-8">
|
||||
<h1 class="text-xl font-bold leading-tight tracking-tight text-gray-900 md:text-2xl dark:text-white">
|
||||
Sign in to your account
|
||||
</h1>
|
||||
<form class="space-y-4 md:space-y-6" method="post">
|
||||
<input type="hidden" name="auth_type" value="form">
|
||||
{% csrf_token %}
|
||||
<div>
|
||||
<label for="username" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Your username</label>
|
||||
<input type="text" name="username" id="username" class="bg-gray-50 border border-gray-300 text-gray-900 rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="fooboar" required="">
|
||||
</div>
|
||||
<div>
|
||||
<label for="password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Password</label>
|
||||
<input type="password" name="password" id="password" placeholder="••••••••" class="bg-gray-50 border border-gray-300 text-gray-900 rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" required="">
|
||||
</div>
|
||||
<button type="submit" class="w-full inline-flex items-center justify-center p-0.5 me-2 overflow-hidden text-sm font-medium text-gray-900 rounded-lg group bg-gradient-to-br from-purple-600 to-blue-500 group-hover:from-purple-600 group-hover:to-blue-500 hover:text-white dark:text-white focus:ring-4 focus:outline-none focus:ring-blue-300 dark:focus:ring-blue-800">
|
||||
<span class="w-full px-5 py-2.5 transition-all ease-in duration-75 bg-white dark:bg-gray-900 rounded-md group-hover:bg-opacity-0">
|
||||
Login
|
||||
</span>
|
||||
</button>
|
||||
</form>
|
||||
<form class="md:space-y-6" method="post">
|
||||
<input type="hidden" name="auth_type" value="openid">
|
||||
{% csrf_token %}
|
||||
<div class="inline-flex items-center justify-center w-full">
|
||||
<hr class="w-64 h-px my-8 bg-gray-200 border-0 dark:bg-gray-700">
|
||||
<span class="absolute px-3 font-medium text-gray-900 -translate-x-1/2 bg-white left-1/2 dark:text-white dark:bg-gray-800">or</span>
|
||||
</div>
|
||||
<button class="w-full inline-flex items-center justify-center p-0.5 mb-2 me-2 overflow-hidden text-sm font-medium text-gray-900 rounded-lg group bg-gradient-to-br from-purple-600 to-blue-500 group-hover:from-purple-600 group-hover:to-blue-500 hover:text-white dark:text-white focus:ring-4 focus:outline-none focus:ring-blue-300 dark:focus:ring-blue-800">
|
||||
<span class="w-full px-5 py-2.5 transition-all ease-in duration-75 bg-white dark:bg-gray-900 rounded-md group-hover:bg-opacity-0">
|
||||
Login with StuVe SSO
|
||||
</span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% endblock content %}
|
||||
36
theme/templates/register.html
Normal file
36
theme/templates/register.html
Normal file
@ -0,0 +1,36 @@
|
||||
{%extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<section class="bg-gray-50 dark:bg-gray-900">
|
||||
<div class="flex flex-col items-center justify-center px-6 py-8 mx-auto md:h-screen lg:py-0">
|
||||
<div class="w-full bg-white rounded-lg shadow dark:border md:mt-0 sm:max-w-md xl:p-0 dark:bg-gray-800 dark:border-gray-700">
|
||||
<div class="p-6 space-y-4 md:space-y-6 sm:p-8">
|
||||
<h1 class="text-xl font-bold leading-tight tracking-tight text-gray-900 md:text-2xl dark:text-white">
|
||||
Create your account
|
||||
</h1>
|
||||
<form class="space-y-4 md:space-y-6" method="post">
|
||||
<input type="hidden" name="auth_type" value="form">
|
||||
{% csrf_token %}
|
||||
<div>
|
||||
<label for="username" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Your username</label>
|
||||
<input type="text" name="username" id="username" class="bg-gray-50 border border-gray-300 text-gray-900 rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="fooboar" required="">
|
||||
</div>
|
||||
<div>
|
||||
<label for="email" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Your email</label>
|
||||
<input type="email" name="email" id="email" class="bg-gray-50 border border-gray-300 text-gray-900 rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="foo@bar.it" required="">
|
||||
</div>
|
||||
<div>
|
||||
<label for="password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Password</label>
|
||||
<input type="password" name="password" id="password" placeholder="••••••••" class="bg-gray-50 border border-gray-300 text-gray-900 rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" required="">
|
||||
</div>
|
||||
<button type="submit" class="w-full inline-flex items-center justify-center p-0.5 me-2 overflow-hidden text-sm font-medium text-gray-900 rounded-lg group bg-gradient-to-br from-purple-600 to-blue-500 group-hover:from-purple-600 group-hover:to-blue-500 hover:text-white dark:text-white focus:ring-4 focus:outline-none focus:ring-blue-300 dark:focus:ring-blue-800">
|
||||
<span class="w-full px-5 py-2.5 transition-all ease-in duration-75 bg-white dark:bg-gray-900 rounded-md group-hover:bg-opacity-0">
|
||||
Signup
|
||||
</span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% endblock content %}
|
||||
13
zitate/forms.py
Normal file
13
zitate/forms.py
Normal file
@ -0,0 +1,13 @@
|
||||
from django import forms
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
class LoginForm(forms.Form):
|
||||
username = forms.CharField(label="username", max_length=255)
|
||||
password = forms.CharField(label="password", max_length=255, widget=forms.PasswordInput)
|
||||
auth_type = forms.CharField(label="auth_type", max_length=255)
|
||||
|
||||
|
||||
class RegisterForm(forms.Form):
|
||||
username = forms.CharField(label="username", max_length=255)
|
||||
password = forms.CharField(label="password", max_length=255, widget=forms.PasswordInput)
|
||||
email = forms.CharField(label="email", max_length=255)
|
||||
@ -37,6 +37,11 @@ INSTALLED_APPS = [
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'tailwind',
|
||||
'theme',
|
||||
'django_browser_reload',
|
||||
'settings',
|
||||
'person',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
@ -47,6 +52,7 @@ MIDDLEWARE = [
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
"django_browser_reload.middleware.BrowserReloadMiddleware",
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'zitate.urls'
|
||||
@ -54,7 +60,7 @@ ROOT_URLCONF = 'zitate.urls'
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'DIRS': [BASE_DIR / 'theme'],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
@ -103,9 +109,9 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/4.2/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
LANGUAGE_CODE = 'de-de'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
TIME_ZONE = 'Europe/Berlin'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
@ -121,3 +127,9 @@ STATIC_URL = 'static/'
|
||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
TAILWIND_APP_NAME = 'theme'
|
||||
|
||||
INTERNAL_IPS = [
|
||||
"127.0.0.1",
|
||||
]
|
||||
@ -15,8 +15,14 @@ Including another URLconf
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import path
|
||||
from django.urls import path, include
|
||||
from .views import *
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path("__reload__/", include("django_browser_reload.urls")),
|
||||
path("login", login, name="login"),
|
||||
path("register", register, name="register"),
|
||||
path("logout", logout, name="logout"),
|
||||
path("settings/", include('settings.urls')),
|
||||
]
|
||||
|
||||
48
zitate/views.py
Normal file
48
zitate/views.py
Normal file
@ -0,0 +1,48 @@
|
||||
from django.shortcuts import render
|
||||
import django.contrib.auth as dauth
|
||||
from django.shortcuts import redirect
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from zitate.forms import LoginForm, RegisterForm
|
||||
|
||||
|
||||
def login(request):
|
||||
if request.method == "GET":
|
||||
return render(request, "login.html")
|
||||
elif request.method == "POST":
|
||||
form = LoginForm(request.POST)
|
||||
auth_type = request.POST.get("auth_type")
|
||||
if auth_type == "form":
|
||||
if form.is_valid():
|
||||
username = form.cleaned_data["username"]
|
||||
password = form.cleaned_data["password"]
|
||||
user = dauth.authenticate(request, username=username, password=password)
|
||||
if user is not None:
|
||||
dauth.login(request, user)
|
||||
return redirect("/")
|
||||
else:
|
||||
return render(request, "login.html", {"userError": True})
|
||||
elif auth_type == "openid":
|
||||
return render(request, "login.html")
|
||||
|
||||
def register(request):
|
||||
if request.method == "GET":
|
||||
return render(request, "register.html")
|
||||
elif request.method == "POST":
|
||||
form = RegisterForm(request.POST)
|
||||
if form.is_valid():
|
||||
username = form.cleaned_data["username"]
|
||||
password = form.cleaned_data["password"]
|
||||
email = form.cleaned_data["email"]
|
||||
User.objects.create_user(username, email, password)
|
||||
user = dauth.authenticate(request, username=username, password=password)
|
||||
if user is not None:
|
||||
dauth.login(request, user)
|
||||
return redirect("/")
|
||||
else:
|
||||
return render(request, "register.html", {"userError": True})
|
||||
|
||||
|
||||
def logout(request):
|
||||
dauth.logout(request)
|
||||
return redirect("/")
|
||||
Loading…
x
Reference in New Issue
Block a user