From bb673b64a9d7610e8c014c1a384e83c061843d54 Mon Sep 17 00:00:00 2001 From: Jochen Mehlich Date: Wed, 29 Nov 2023 17:19:51 +0100 Subject: [PATCH 01/15] cicd fix Signed-off-by: Jochen Mehlich --- .gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a4343b8..2e49e4d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,6 +23,9 @@ default: - apt -y update - apt -y install apt-utils -yqq - apt -y install net-tools python3.8 python3-pip mysql-client libmysqlclient-dev pkg-config -yqq + - echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections + - DEBIAN_FRONTEND=noninteractive sudo apt-get update && sudo apt-get -y --no-install-recommends install tzdata + - sudo cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime - apt -y upgrade - pip3 install -r requirements.txt From 2a98e17b31c74983d6a41e03835bdf9ba39ba6b3 Mon Sep 17 00:00:00 2001 From: Jochen Mehlich Date: Wed, 29 Nov 2023 17:23:16 +0100 Subject: [PATCH 02/15] cicd reorder Signed-off-by: Jochen Mehlich --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2e49e4d..d6ed870 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,10 +22,10 @@ default: before_script: - apt -y update - apt -y install apt-utils -yqq - - apt -y install net-tools python3.8 python3-pip mysql-client libmysqlclient-dev pkg-config -yqq - echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections - DEBIAN_FRONTEND=noninteractive sudo apt-get update && sudo apt-get -y --no-install-recommends install tzdata - sudo cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime + - apt -y install net-tools python3.8 python3-pip mysql-client libmysqlclient-dev pkg-config -yqq - apt -y upgrade - pip3 install -r requirements.txt From 1e7eefc535ebd1bb5ec36213991f47c467b8d32a Mon Sep 17 00:00:00 2001 From: Jochen Mehlich Date: Wed, 29 Nov 2023 17:25:10 +0100 Subject: [PATCH 03/15] cicd removed sudo Signed-off-by: Jochen Mehlich --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d6ed870..8894409 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,8 +23,8 @@ default: - apt -y update - apt -y install apt-utils -yqq - echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections - - DEBIAN_FRONTEND=noninteractive sudo apt-get update && sudo apt-get -y --no-install-recommends install tzdata - - sudo cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime + - DEBIAN_FRONTEND=noninteractive apt-get update && apt-get -y --no-install-recommends install tzdata + - cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime - apt -y install net-tools python3.8 python3-pip mysql-client libmysqlclient-dev pkg-config -yqq - apt -y upgrade - pip3 install -r requirements.txt From c4149bcf3d1ace3c00bbd6f68f56361a6bf480cd Mon Sep 17 00:00:00 2001 From: Jochen Mehlich Date: Wed, 29 Nov 2023 17:28:21 +0100 Subject: [PATCH 04/15] cicd removed sudo Signed-off-by: Jochen Mehlich --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8894409..cdfb90b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,7 +22,7 @@ default: before_script: - apt -y update - apt -y install apt-utils -yqq - - echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections + - echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections - DEBIAN_FRONTEND=noninteractive apt-get update && apt-get -y --no-install-recommends install tzdata - cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime - apt -y install net-tools python3.8 python3-pip mysql-client libmysqlclient-dev pkg-config -yqq From 29545e8889595da4eff23200aa86ee9d28cc5130 Mon Sep 17 00:00:00 2001 From: Jochen Mehlich Date: Wed, 29 Nov 2023 17:49:33 +0100 Subject: [PATCH 05/15] cicd database Signed-off-by: Jochen Mehlich --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cdfb90b..5e33d20 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -44,5 +44,5 @@ django-tests: # The MYSQL user only gets permissions for MYSQL_DB, so Django can't create a test database. - echo "GRANT ALL on *.* to '${MYSQL_USER}';"| mysql -u root --password="${MYSQL_ROOT_PASSWORD}" -h mysql # use python3 explicitly. see https://wiki.ubuntu.com/Python/3 - - python3 manage.py test --database=test + - python3 manage.py test From 0bf082a1ef8db2b32d723a16af4af59a0ade140f Mon Sep 17 00:00:00 2001 From: Jochen Mehlich Date: Wed, 29 Nov 2023 18:01:33 +0100 Subject: [PATCH 06/15] added qodana report Signed-off-by: Jochen Mehlich --- .gitlab-ci.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5e33d20..23c1d38 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -46,3 +46,19 @@ django-tests: # use python3 explicitly. see https://wiki.ubuntu.com/Python/3 - python3 manage.py test +qodana: + stage: quality + image: + name: jetbrains/qodana-python:2023.3-eap + entrypoint: [""] + variables: + QODANA_REMOTE_URL: git@$CI_SERVER_HOST:$CI_PROJECT_PATH.git + QODANA_BRANCH: $CI_COMMIT_BRANCH + QODANA_REPO_URL: $CI_PROJECT_URL + QODANA_JOB_URL: $CI_JOB_URL + script: + - qodana --save-report --results-dir=$CI_PROJECT_DIR/qodana --report-dir=$CI_PROJECT_DIR/qodana/report + artifacts: + paths: + - qodana/report/ + expose_as: 'Qodana report' From 5a4b799783e01615f52e553470cf8c122dc0dd39 Mon Sep 17 00:00:00 2001 From: Jochen Mehlich Date: Wed, 29 Nov 2023 18:01:48 +0100 Subject: [PATCH 07/15] fixed qodana cicd stage Signed-off-by: Jochen Mehlich --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 23c1d38..378a967 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -47,7 +47,7 @@ django-tests: - python3 manage.py test qodana: - stage: quality + stage: test image: name: jetbrains/qodana-python:2023.3-eap entrypoint: [""] From 0b5b8be8530cb8818de2c8c2c37f0eea3a8ebefa Mon Sep 17 00:00:00 2001 From: Jochen Mehlich Date: Wed, 29 Nov 2023 18:11:32 +0100 Subject: [PATCH 08/15] forbid default for qodana report Signed-off-by: Jochen Mehlich --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 378a967..4324b8b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,6 +48,8 @@ django-tests: qodana: stage: test + inherit: + default: false image: name: jetbrains/qodana-python:2023.3-eap entrypoint: [""] From c529ff1a5ff2475281e57cd61aa987b0ed792495 Mon Sep 17 00:00:00 2001 From: Jochen Mehlich Date: Wed, 29 Nov 2023 18:29:43 +0100 Subject: [PATCH 09/15] added model for sourcePerson Signed-off-by: Jochen Mehlich --- .idea/.gitignore | 8 +++++ .../inspectionProfiles/profiles_settings.xml | 6 ++++ .idea/misc.xml | 7 +++++ .idea/modules.xml | 8 +++++ .idea/quoteMe.iml | 29 +++++++++++++++++++ .idea/vcs.xml | 6 ++++ quoteMe/settings.py | 1 + sourcePerson/__init__.py | 0 sourcePerson/admin.py | 3 ++ sourcePerson/apps.py | 6 ++++ sourcePerson/migrations/0001_initial.py | 25 ++++++++++++++++ .../migrations/0002_auto_20231129_1829.py | 25 ++++++++++++++++ sourcePerson/migrations/__init__.py | 0 sourcePerson/models.py | 13 +++++++++ sourcePerson/tests.py | 3 ++ sourcePerson/views.py | 3 ++ 16 files changed, 143 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/quoteMe.iml create mode 100644 .idea/vcs.xml create mode 100644 sourcePerson/__init__.py create mode 100644 sourcePerson/admin.py create mode 100644 sourcePerson/apps.py create mode 100644 sourcePerson/migrations/0001_initial.py create mode 100644 sourcePerson/migrations/0002_auto_20231129_1829.py create mode 100644 sourcePerson/migrations/__init__.py create mode 100644 sourcePerson/models.py create mode 100644 sourcePerson/tests.py create mode 100644 sourcePerson/views.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..5396ca5 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..eefee65 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/quoteMe.iml b/.idea/quoteMe.iml new file mode 100644 index 0000000..0214946 --- /dev/null +++ b/.idea/quoteMe.iml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/quoteMe/settings.py b/quoteMe/settings.py index c6719e7..433510e 100644 --- a/quoteMe/settings.py +++ b/quoteMe/settings.py @@ -38,6 +38,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'sourcePerson' ] MIDDLEWARE = [ diff --git a/sourcePerson/__init__.py b/sourcePerson/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sourcePerson/admin.py b/sourcePerson/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/sourcePerson/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/sourcePerson/apps.py b/sourcePerson/apps.py new file mode 100644 index 0000000..a981cfe --- /dev/null +++ b/sourcePerson/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class SourcepersonConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'sourcePerson' diff --git a/sourcePerson/migrations/0001_initial.py b/sourcePerson/migrations/0001_initial.py new file mode 100644 index 0000000..6bce57b --- /dev/null +++ b/sourcePerson/migrations/0001_initial.py @@ -0,0 +1,25 @@ +# Generated by Django 3.2.18 on 2023-11-29 17:26 + +from django.db import migrations, models +import uuid + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='sourcePerson', + fields=[ + ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), + ('name', models.CharField(max_length=200)), + ('isActive', models.BooleanField(default=True)), + ('isArchived', models.BooleanField(default=False)), + ('description', models.TextField()), + ], + ), + ] diff --git a/sourcePerson/migrations/0002_auto_20231129_1829.py b/sourcePerson/migrations/0002_auto_20231129_1829.py new file mode 100644 index 0000000..e84d26c --- /dev/null +++ b/sourcePerson/migrations/0002_auto_20231129_1829.py @@ -0,0 +1,25 @@ +# Generated by Django 3.2.18 on 2023-11-29 17:29 + +import datetime +from django.db import migrations, models +from django.utils.timezone import utc + + +class Migration(migrations.Migration): + + dependencies = [ + ('sourcePerson', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='sourceperson', + name='created_at', + field=models.DateTimeField(default=datetime.datetime(2023, 11, 29, 17, 29, 16, 298686, tzinfo=utc)), + ), + migrations.AddField( + model_name='sourceperson', + name='updated_at', + field=models.DateTimeField(default=datetime.datetime(2023, 11, 29, 17, 29, 16, 298700, tzinfo=utc)), + ), + ] diff --git a/sourcePerson/migrations/__init__.py b/sourcePerson/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sourcePerson/models.py b/sourcePerson/models.py new file mode 100644 index 0000000..bb4852b --- /dev/null +++ b/sourcePerson/models.py @@ -0,0 +1,13 @@ +from django.db import models +from django.utils import timezone +import uuid +# Create your models here. + +class sourcePerson(models.Model): + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) + name = models.CharField(max_length=200) + isActive = models.BooleanField(default=True) + isArchived = models.BooleanField(default=False) + description = models.TextField() + created_at = models.DateTimeField(default=timezone.now()) + updated_at = models.DateTimeField(default=timezone.now()) \ No newline at end of file diff --git a/sourcePerson/tests.py b/sourcePerson/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/sourcePerson/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/sourcePerson/views.py b/sourcePerson/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/sourcePerson/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. From 1b1f65371121215686c8f91ec3b9b39e967b1286 Mon Sep 17 00:00:00 2001 From: Jochen Mehlich Date: Wed, 29 Nov 2023 18:34:52 +0100 Subject: [PATCH 10/15] added to admin panel Signed-off-by: Jochen Mehlich --- sourcePerson/admin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sourcePerson/admin.py b/sourcePerson/admin.py index 8c38f3f..f5b3ac1 100644 --- a/sourcePerson/admin.py +++ b/sourcePerson/admin.py @@ -1,3 +1,4 @@ from django.contrib import admin - +from .models import sourcePerson # Register your models here. +admin.site.register(sourcePerson) From 1849b2edf9fe3a1896e3c736860fa9fc434afc7e Mon Sep 17 00:00:00 2001 From: Jochen Mehlich Date: Wed, 29 Nov 2023 18:47:34 +0100 Subject: [PATCH 11/15] added sourcePerson serializers Signed-off-by: Jochen Mehlich --- sourcePerson/serializers.py | 7 +++++++ sourcePerson/views.py | 1 + 2 files changed, 8 insertions(+) create mode 100644 sourcePerson/serializers.py diff --git a/sourcePerson/serializers.py b/sourcePerson/serializers.py new file mode 100644 index 0000000..3c78e79 --- /dev/null +++ b/sourcePerson/serializers.py @@ -0,0 +1,7 @@ +from rest_framework import serializers +from .models import sourcePerson + +class sourcePersonSerializer(serializers.ModelSerializer): + class Meta: + model = sourcePerson + fields = ["id", "name", "description", "isActive", "isArchived", "created_at", "updated_at"] \ No newline at end of file diff --git a/sourcePerson/views.py b/sourcePerson/views.py index 91ea44a..dc1ba72 100644 --- a/sourcePerson/views.py +++ b/sourcePerson/views.py @@ -1,3 +1,4 @@ from django.shortcuts import render + # Create your views here. From e73d0cb954f7680994d58d8025162d5825fc4b3d Mon Sep 17 00:00:00 2001 From: Jochen Mehlich Date: Wed, 29 Nov 2023 18:49:41 +0100 Subject: [PATCH 12/15] added sourcePerson ping Signed-off-by: Jochen Mehlich --- sourcePerson/views.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sourcePerson/views.py b/sourcePerson/views.py index dc1ba72..073d140 100644 --- a/sourcePerson/views.py +++ b/sourcePerson/views.py @@ -1,4 +1,11 @@ -from django.shortcuts import render +from rest_framework.decorators import api_view, permission_classes +from django.http import JsonResponse +from django.views.decorators.csrf import csrf_exempt # Create your views here. +@api_view(["GET"]) +@csrf_exempt +def ping(request): + content = {"message": "pong"} + return JsonResponse(content) From 4e12de8407dfd336f8983c30802ad8e633733130 Mon Sep 17 00:00:00 2001 From: Jochen Mehlich Date: Wed, 29 Nov 2023 19:05:31 +0100 Subject: [PATCH 13/15] updated requirements.txt Signed-off-by: Jochen Mehlich --- requirements.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/requirements.txt b/requirements.txt index 8b53a49..5b1b146 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,6 @@ asgiref==3.7.2 Django==4.2.7 +djangorestframework==3.14.0 mysqlclient==2.2.0 +pytz==2023.3.post1 sqlparse==0.4.4 From 1962761bebcd14887bf41ebcbe5beef41ae7f0ab Mon Sep 17 00:00:00 2001 From: Jochen Mehlich Date: Tue, 19 Dec 2023 15:35:09 +0100 Subject: [PATCH 14/15] added bootstrap Signed-off-by: Jochen Mehlich --- quoteMe/settings.py | 1 + quoteMe/urls.py | 4 +++- sourcePerson/urls.py | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 sourcePerson/urls.py diff --git a/quoteMe/settings.py b/quoteMe/settings.py index 433510e..d605a5d 100644 --- a/quoteMe/settings.py +++ b/quoteMe/settings.py @@ -38,6 +38,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'bootstrap5', 'sourcePerson' ] diff --git a/quoteMe/urls.py b/quoteMe/urls.py index 9c7a8ba..aeedc79 100644 --- a/quoteMe/urls.py +++ b/quoteMe/urls.py @@ -14,8 +14,10 @@ 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 sourcePerson import urls urlpatterns = [ path('admin/', admin.site.urls), + path('person/', include('sourcePerson.urls')) ] diff --git a/sourcePerson/urls.py b/sourcePerson/urls.py new file mode 100644 index 0000000..3523727 --- /dev/null +++ b/sourcePerson/urls.py @@ -0,0 +1,6 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path("create", views.ping) +] \ No newline at end of file From b9b568c31f99c311f94de3f930d4d37421bccfff Mon Sep 17 00:00:00 2001 From: Jochen Mehlich Date: Tue, 19 Dec 2023 19:06:21 +0100 Subject: [PATCH 15/15] added bootstrap --- ..._alter_sourceperson_created_at_and_more.py | 24 ++++++++++++++ sourcePerson/templates/create.html | 3 ++ sourcePerson/templates/header.html | 31 +++++++++++++++++++ sourcePerson/templates/list.html | 28 +++++++++++++++++ sourcePerson/urls.py | 5 ++- sourcePerson/views.py | 15 +++++---- 6 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 sourcePerson/migrations/0003_alter_sourceperson_created_at_and_more.py create mode 100644 sourcePerson/templates/create.html create mode 100644 sourcePerson/templates/header.html create mode 100644 sourcePerson/templates/list.html diff --git a/sourcePerson/migrations/0003_alter_sourceperson_created_at_and_more.py b/sourcePerson/migrations/0003_alter_sourceperson_created_at_and_more.py new file mode 100644 index 0000000..f461256 --- /dev/null +++ b/sourcePerson/migrations/0003_alter_sourceperson_created_at_and_more.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.7 on 2023-12-19 16:48 + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('sourcePerson', '0002_auto_20231129_1829'), + ] + + operations = [ + migrations.AlterField( + model_name='sourceperson', + name='created_at', + field=models.DateTimeField(default=datetime.datetime(2023, 12, 19, 16, 48, 48, 328450, tzinfo=datetime.timezone.utc)), + ), + migrations.AlterField( + model_name='sourceperson', + name='updated_at', + field=models.DateTimeField(default=datetime.datetime(2023, 12, 19, 16, 48, 48, 328467, tzinfo=datetime.timezone.utc)), + ), + ] diff --git a/sourcePerson/templates/create.html b/sourcePerson/templates/create.html new file mode 100644 index 0000000..542b7ca --- /dev/null +++ b/sourcePerson/templates/create.html @@ -0,0 +1,3 @@ +{% extends "header.html" %} + +{% block title %}Person anlegen{% endblock %} \ No newline at end of file diff --git a/sourcePerson/templates/header.html b/sourcePerson/templates/header.html new file mode 100644 index 0000000..035b8ef --- /dev/null +++ b/sourcePerson/templates/header.html @@ -0,0 +1,31 @@ +{% load bootstrap5 %} +{% bootstrap_css %} +{% bootstrap_javascript %} + + + + + + {% block title %} Quote Me {% endblock %} + + + +
+ {% block content %}{% endblock %} +
+ + \ No newline at end of file diff --git a/sourcePerson/templates/list.html b/sourcePerson/templates/list.html new file mode 100644 index 0000000..02096ed --- /dev/null +++ b/sourcePerson/templates/list.html @@ -0,0 +1,28 @@ +{% extends "header.html" %} + +{% block title %}Personlist{% endblock %} + +{% block content %} +{% if persons %} + + + + + + + + + + {% for person in persons %} + + + + + + {% endfor %} + +
NameBeschreibungAktiviert
{{ person.name }}{{ person.description }}{{ person.isActive}}
+ {%else%} + Nothing found + {%endif%} +{% endblock %} \ No newline at end of file diff --git a/sourcePerson/urls.py b/sourcePerson/urls.py index 3523727..eb12097 100644 --- a/sourcePerson/urls.py +++ b/sourcePerson/urls.py @@ -1,6 +1,9 @@ from django.urls import path +from django.views.generic.base import TemplateView from . import views +from . import models urlpatterns = [ - path("create", views.ping) + path("create", TemplateView.as_view(template_name="create.html"), name="create"), + path("list", views.listPersons, name="list") ] \ No newline at end of file diff --git a/sourcePerson/views.py b/sourcePerson/views.py index 073d140..b86974e 100644 --- a/sourcePerson/views.py +++ b/sourcePerson/views.py @@ -1,11 +1,14 @@ from rest_framework.decorators import api_view, permission_classes +from django.shortcuts import render from django.http import JsonResponse from django.views.decorators.csrf import csrf_exempt +from django.views.generic.base import TemplateView +from . import models +def listPersons(request, **kwargs): + persons = models.sourcePerson.objects.all() + data = { + "persons": persons + } -# Create your views here. -@api_view(["GET"]) -@csrf_exempt -def ping(request): - content = {"message": "pong"} - return JsonResponse(content) + return render(request, 'list.html', data) \ No newline at end of file