Merge pull request 'addBootstrap' (#1) from addBootstrap into main

Reviewed-on: #1
This commit is contained in:
Jochen 2023-12-19 18:18:29 +00:00
commit ce2035278d
25 changed files with 285 additions and 2 deletions

View File

@ -22,6 +22,9 @@ default:
before_script:
- apt -y update
- apt -y install apt-utils -yqq
- 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
- apt -y upgrade
- pip3 install -r requirements.txt
@ -41,5 +44,23 @@ 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
qodana:
stage: test
inherit:
default: false
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'

8
.idea/.gitignore generated vendored Normal file
View File

@ -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

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

7
.idea/misc.xml generated Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.11 (quoteMe)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (quoteMe)" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/quoteMe.iml" filepath="$PROJECT_DIR$/.idea/quoteMe.iml" />
</modules>
</component>
</project>

29
.idea/quoteMe.iml generated Normal file
View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="FacetManager">
<facet type="django" name="Django">
<configuration>
<option name="rootFolder" value="$MODULE_DIR$" />
<option name="settingsModule" value="quoteMe/settings.py" />
<option name="manageScript" value="$MODULE_DIR$/manage.py" />
<option name="environment" value="&lt;map/&gt;" />
<option name="doNotUseTestRunner" value="false" />
<option name="trackFilePattern" value="migrations" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/env" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">
<option name="format" value="PLAIN" />
<option name="myDocStringFormat" value="Plain" />
</component>
<component name="TemplatesService">
<option name="TEMPLATE_CONFIGURATION" value="Django" />
</component>
</module>

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -38,6 +38,8 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'bootstrap5',
'sourcePerson'
]
MIDDLEWARE = [

View File

@ -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'))
]

View File

@ -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

0
sourcePerson/__init__.py Normal file
View File

4
sourcePerson/admin.py Normal file
View File

@ -0,0 +1,4 @@
from django.contrib import admin
from .models import sourcePerson
# Register your models here.
admin.site.register(sourcePerson)

6
sourcePerson/apps.py Normal file
View File

@ -0,0 +1,6 @@
from django.apps import AppConfig
class SourcepersonConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'sourcePerson'

View File

@ -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()),
],
),
]

View File

@ -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)),
),
]

View File

@ -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)),
),
]

View File

13
sourcePerson/models.py Normal file
View File

@ -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())

View File

@ -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"]

View File

@ -0,0 +1,3 @@
{% extends "header.html" %}
{% block title %}Person anlegen{% endblock %}

View File

@ -0,0 +1,31 @@
{% load bootstrap5 %}
{% bootstrap_css %}
{% bootstrap_javascript %}
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %} Quote Me {% endblock %}</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
</div>
</nav>
<main class="container">
{% block content %}{% endblock %}
</main>
</body>
</html>

View File

@ -0,0 +1,28 @@
{% extends "header.html" %}
{% block title %}Personlist{% endblock %}
{% block content %}
{% if persons %}
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Beschreibung</th>
<th scope="col">Aktiviert</th>
</tr>
</thead>
<tbody>
{% for person in persons %}
<tr>
<td>{{ person.name }}</td>
<td>{{ person.description }}</td>
<td>{{ person.isActive}}</td>
</tr>
{% endfor %}
</tbody>
</table>
{%else%}
Nothing found
{%endif%}
{% endblock %}

3
sourcePerson/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

9
sourcePerson/urls.py Normal file
View File

@ -0,0 +1,9 @@
from django.urls import path
from django.views.generic.base import TemplateView
from . import views
from . import models
urlpatterns = [
path("create", TemplateView.as_view(template_name="create.html"), name="create"),
path("list", views.listPersons, name="list")
]

14
sourcePerson/views.py Normal file
View File

@ -0,0 +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
}
return render(request, 'list.html', data)