diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..ff19b07 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,18 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python Debugger: Django", + "type": "debugpy", + "request": "launch", + "program": "${workspaceFolder}/techdb/manage.py", + "args": ["runserver"], + "console": "integratedTerminal", + "django": true, + "justMyCode": false + } + ] +} \ No newline at end of file diff --git a/techdb/flightslot/admin.py b/techdb/flightslot/admin.py index a328fab..413d45f 100644 --- a/techdb/flightslot/admin.py +++ b/techdb/flightslot/admin.py @@ -1,29 +1,55 @@ from django.contrib import admin import nested_admin +from django import forms from .models import * +class TrainingForm(forms.ModelForm): + model=Training + + def get_form(self, request, obj=None, **kwargs): + form = super().get_form(request, obj, **kwargs) + form.base_fields['mission'].widget.can_add_related = False + form.base_fields['mission'].widget.can_delete_related = False + form.base_fields['mission'].widget.can_change_related = False + print("pluto") + return form + # Register your models here. class HourBuildingLegInline(nested_admin.NestedTabularInline): model = HourBuildingLeg - extra = 1 + extra = 0 fk_name = 'hb' class HourBuildingInLine(nested_admin.NestedTabularInline): model = HourBuilding - extra = 1 + extra = 0 inlines = [HourBuildingLegInline] fk_name = 'weekpref' + verbose_name_plural = "Hour Building" + max_num = 7 class TrainingInLIne(nested_admin.NestedTabularInline): model = Training - extra = 0 + form = TrainingForm + extra = 1 fk_name = 'weekpref' + verbose_name_plural = "Training Missions" + max_num = 7 + + def get_formset(self, request, obj=None, **kwargs): + formset = super(TrainingInLIne, self).get_formset(request, obj=None, **kwargs) + return formset class WeekPreferenceAdmin(nested_admin.NestedModelAdmin): - list_display = ('week', 'student') - list_filter = ['week', 'student'] inlines = [TrainingInLIne, HourBuildingInLine] + def get_form(self, request, obj=None, **kwargs): + form: forms.Form = super().get_form(request, obj, **kwargs) + form.base_fields['student'].widget.can_add_related = False + form.base_fields['student'].widget.can_delete_related = False + form.base_fields['student'].widget.can_change_related = False + return form + class StudentAdmin(admin.ModelAdmin): list_display = ("surname", "name", "course", "email","active") list_filter = ["course", "active"] diff --git a/techdb/flightslot/models.py b/techdb/flightslot/models.py index bba807d..52aa45c 100644 --- a/techdb/flightslot/models.py +++ b/techdb/flightslot/models.py @@ -75,14 +75,16 @@ class WeekPreference(models.Model): null=False, db_index=True, default=ExtractWeek(Now()) + 1, - auto_created=True + auto_created=True, + verbose_name="Week Number" ) student = models.ForeignKey( Student, null=False, db_index=True, - on_delete=models.DO_NOTHING + on_delete=models.DO_NOTHING, + verbose_name="Student Selection" ) def __str__(self): @@ -105,12 +107,14 @@ class MissionProfile(models.Model): mtype = models.CharField( null=False, default=MissionType.PPL, - choices=MissionType + choices=MissionType, + verbose_name="Mission Type" ) mnum = models.PositiveSmallIntegerField( null=True, - default=0 + default=0, + verbose_name="Mission Number" ) duration = models.DurationField( diff --git a/techdb/static/cantorair.jpg b/techdb/static/cantorair.jpg new file mode 100644 index 0000000..b150ed7 Binary files /dev/null and b/techdb/static/cantorair.jpg differ diff --git a/techdb/techdb/settings.py b/techdb/techdb/settings.py index 02df5d8..c15242f 100644 --- a/techdb/techdb/settings.py +++ b/techdb/techdb/settings.py @@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/5.1/ref/settings/ """ from pathlib import Path +import os # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -38,7 +39,6 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'nested_admin', - 'catops', 'flightslot' ] @@ -57,7 +57,7 @@ ROOT_URLCONF = 'techdb.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], + 'DIRS': [os.path.join(BASE_DIR, 'templates/')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -72,6 +72,9 @@ TEMPLATES = [ WSGI_APPLICATION = 'techdb.wsgi.application' +STATICFILES_DIRS = [ + os.path.join(BASE_DIR, "static"), +] # Database # https://docs.djangoproject.com/en/5.1/ref/settings/#databases diff --git a/techdb/techdb/urls.py b/techdb/techdb/urls.py index 9a692c1..b269d16 100644 --- a/techdb/techdb/urls.py +++ b/techdb/techdb/urls.py @@ -20,3 +20,7 @@ from django.urls import path urlpatterns = [ path('admin/', admin.site.urls), ] + +admin.site.site_header = "CantorAir Flight Scheduler" +admin.site.site_title = "CantorAir Flight Scheduler" +admin.site.index_title = "Welcome to CantorAir Flight Scheduler Portal" \ No newline at end of file diff --git a/techdb/templates/admin/base_site.html b/techdb/templates/admin/base_site.html new file mode 100644 index 0000000..0839ac6 --- /dev/null +++ b/techdb/templates/admin/base_site.html @@ -0,0 +1,22 @@ +{% extends "admin/base.html" %} + +{% load static %} + +{% block title %}{% if subtitle %}{{ subtitle }} | {% endif %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %} + +{% block branding %} + +
+
+