feat: created first ticket class
This commit is contained in:
@@ -31,6 +31,7 @@ ALLOWED_HOSTS = []
|
|||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
|
'ticketsystem.apps.TicketsystemConfig',
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
'django.contrib.contenttypes',
|
'django.contrib.contenttypes',
|
||||||
@@ -102,9 +103,9 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||||||
# Internationalization
|
# Internationalization
|
||||||
# https://docs.djangoproject.com/en/5.2/topics/i18n/
|
# https://docs.djangoproject.com/en/5.2/topics/i18n/
|
||||||
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
LANGUAGE_CODE = 'de-de'
|
||||||
|
|
||||||
TIME_ZONE = 'UTC'
|
TIME_ZONE = 'CET'
|
||||||
|
|
||||||
USE_I18N = True
|
USE_I18N = True
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,9 @@ Including another URLconf
|
|||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import include, path
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path("ticketsystem/", include("ticketsystem.urls")),
|
||||||
]
|
path("admin/", admin.site.urls),
|
||||||
|
]
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
# Register your models here.
|
from .models import Ticket
|
||||||
|
|
||||||
|
admin.site.register(Ticket)
|
||||||
@@ -1,3 +1,28 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
# Create your models here.
|
|
||||||
|
class Ticket(models.Model):
|
||||||
|
STATUS_CHOICES = [
|
||||||
|
('open', 'Offen'),
|
||||||
|
('in_progress', 'In Bearbeitung'),
|
||||||
|
('closed', 'Geschlossen'),
|
||||||
|
]
|
||||||
|
|
||||||
|
PRIORITY_CHOICES = [
|
||||||
|
('low', 'Niedrig'),
|
||||||
|
('medium', 'Mittel'),
|
||||||
|
('high', 'Hoch'),
|
||||||
|
]
|
||||||
|
|
||||||
|
title = models.CharField(max_length=200)
|
||||||
|
description = models.TextField()
|
||||||
|
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='open')
|
||||||
|
priority = models.CharField(max_length=10, choices=PRIORITY_CHOICES, default='medium')
|
||||||
|
created_by = models.ForeignKey(User, related_name='tickets_created', on_delete=models.CASCADE)
|
||||||
|
assigned_to = models.ForeignKey(User, related_name='tickets_assigned', null=True, blank=True, on_delete=models.SET_NULL)
|
||||||
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
|
updated_at = models.DateTimeField(auto_now=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"[{self.get_priority_display()}] {self.title} ({self.get_status_display()})"
|
||||||
|
|||||||
10
ticketsystem/urls.py
Normal file
10
ticketsystem/urls.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from django.urls import path
|
||||||
|
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
# /ticketsystem/
|
||||||
|
path("", views.index, name="index"),
|
||||||
|
# /ticketsystem/detail/
|
||||||
|
path("<int:ticket_id>/", views.detail, name="detail"),
|
||||||
|
]
|
||||||
@@ -1,3 +1,12 @@
|
|||||||
from django.shortcuts import render
|
from django.http import HttpResponse
|
||||||
|
from .models import Ticket
|
||||||
|
|
||||||
# Create your views here.
|
|
||||||
|
def index(request):
|
||||||
|
latest_ticket_list = Ticket.objects.order_by("-created_at")[:5]
|
||||||
|
output = ", ".join([t.title for t in latest_ticket_list])
|
||||||
|
return HttpResponse(output)
|
||||||
|
|
||||||
|
|
||||||
|
def detail(request, ticket_id):
|
||||||
|
return HttpResponse("You're looking at Ticket %s." % ticket_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user