diff --git a/cookies.txt b/cookies.txt new file mode 100644 index 0000000..0b8b044 --- /dev/null +++ b/cookies.txt @@ -0,0 +1,5 @@ +# Netscape HTTP Cookie File +# https://curl.se/docs/http-cookies.html +# This file was generated by libcurl! Edit at your own risk. + +127.0.0.1 FALSE / TRUE 1797450401 csrftoken gNby2S5EHlDB1Xsw0eGC7JVKq4F45wQW diff --git a/core/__pycache__/admin.cpython-311.pyc b/core/__pycache__/admin.cpython-311.pyc index cd6f855..0b8cbdb 100644 Binary files a/core/__pycache__/admin.cpython-311.pyc and b/core/__pycache__/admin.cpython-311.pyc differ diff --git a/core/__pycache__/forms.cpython-311.pyc b/core/__pycache__/forms.cpython-311.pyc index 054082f..0864d42 100644 Binary files a/core/__pycache__/forms.cpython-311.pyc and b/core/__pycache__/forms.cpython-311.pyc differ diff --git a/core/__pycache__/models.cpython-311.pyc b/core/__pycache__/models.cpython-311.pyc index 9b59ba3..acdcf23 100644 Binary files a/core/__pycache__/models.cpython-311.pyc and b/core/__pycache__/models.cpython-311.pyc differ diff --git a/core/__pycache__/urls.cpython-311.pyc b/core/__pycache__/urls.cpython-311.pyc index 4c8f574..57df135 100644 Binary files a/core/__pycache__/urls.cpython-311.pyc and b/core/__pycache__/urls.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index bfef9f0..cbb0ef3 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/admin.py b/core/admin.py index 8c38f3f..4ff6fd6 100644 --- a/core/admin.py +++ b/core/admin.py @@ -1,3 +1,14 @@ from django.contrib import admin +from .models import Project, Client -# Register your models here. +@admin.register(Client) +class ClientAdmin(admin.ModelAdmin): + list_display = ('name', 'email', 'phone') + search_fields = ('name',) + +@admin.register(Project) +class ProjectAdmin(admin.ModelAdmin): + list_display = ('name', 'client', 'start_date', 'end_date', 'status') + list_filter = ('status', 'client') + search_fields = ('name', 'client__name') + autocomplete_fields = ('client',) \ No newline at end of file diff --git a/core/forms.py b/core/forms.py index 81f090e..f917e0d 100644 --- a/core/forms.py +++ b/core/forms.py @@ -1,5 +1,5 @@ from django import forms -from .models import Project +from .models import Project, Client class ProjectForm(forms.ModelForm): class Meta: @@ -7,8 +7,18 @@ class ProjectForm(forms.ModelForm): fields = ['name', 'client', 'start_date', 'end_date', 'status'] widgets = { 'name': forms.TextInput(attrs={'class': 'form-control'}), - 'client': forms.TextInput(attrs={'class': 'form-control'}), + 'client': forms.Select(attrs={'class': 'form-select'}), 'start_date': forms.DateInput(attrs={'class': 'form-control', 'type': 'date'}), 'end_date': forms.DateInput(attrs={'class': 'form-control', 'type': 'date'}), 'status': forms.Select(attrs={'class': 'form-select'}), } + +class ClientForm(forms.ModelForm): + class Meta: + model = Client + fields = ['name', 'email', 'phone'] + widgets = { + 'name': forms.TextInput(attrs={'class': 'form-control'}), + 'email': forms.EmailInput(attrs={'class': 'form-control'}), + 'phone': forms.TextInput(attrs={'class': 'form-control'}), + } \ No newline at end of file diff --git a/core/migrations/0002_client_alter_project_end_date_alter_project_name_and_more.py b/core/migrations/0002_client_alter_project_end_date_alter_project_name_and_more.py new file mode 100644 index 0000000..9f9af2c --- /dev/null +++ b/core/migrations/0002_client_alter_project_end_date_alter_project_name_and_more.py @@ -0,0 +1,93 @@ +# Generated by Django 5.2.7 on 2025-12-17 19:22 + +from django.db import migrations, models +import django.db.models.deletion + +def migrate_clients_forward(apps, schema_editor): + Project = apps.get_model('core', 'Project') + Client = apps.get_model('core', 'Client') + for project in Project.objects.all(): + client_name = getattr(project, 'client_temp', None) + if client_name: + client, created = Client.objects.get_or_create(name=client_name) + project.client = client + project.save() + +def migrate_clients_backward(apps, schema_editor): + # This is a one-way migration, but we can try to restore the old values + Project = apps.get_model('core', 'Project') + for project in Project.objects.all(): + if project.client: + project.client_temp = project.client.name + project.save() + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0001_initial'), + ] + + operations = [ + # 1. Create the new Client model + migrations.CreateModel( + name='Client', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=200, verbose_name='Client Name')), + ('email', models.EmailField(blank=True, max_length=200, null=True, verbose_name='Email')), + ('phone', models.CharField(blank=True, max_length=20, null=True, verbose_name='Phone')), + ], + ), + + # 2. Rename the existing 'client' CharField to a temporary field + migrations.RenameField( + model_name='project', + old_name='client', + new_name='client_temp', + ), + + # 3. Add the new 'client' ForeignKey field, allowing it to be null for now + migrations.AddField( + model_name='project', + name='client', + field=models.ForeignKey( + to='core.Client', + on_delete=django.db.models.deletion.CASCADE, + related_name='projects', + verbose_name='Client', + null=True, # Allow null during migration + blank=True + ), + ), + + # 4. Run the Python script to migrate the data + migrations.RunPython(migrate_clients_forward, migrate_clients_backward), + + # 5. Remove the temporary CharField + migrations.RemoveField( + model_name='project', + name='client_temp', + ), + + # 6. Alter other fields (translations) + migrations.AlterField( + model_name='project', + name='end_date', + field=models.DateField(verbose_name='End Date'), + ), + migrations.AlterField( + model_name='project', + name='name', + field=models.CharField(max_length=200, verbose_name='Project Name'), + ), + migrations.AlterField( + model_name='project', + name='start_date', + field=models.DateField(verbose_name='Start Date'), + ), + migrations.AlterField( + model_name='project', + name='status', + field=models.CharField(choices=[('planning', 'Planning'), ('in_progress', 'In Progress'), ('completed', 'Completed')], default='planning', max_length=20, verbose_name='Status'), + ), + ] \ No newline at end of file diff --git a/core/migrations/__pycache__/0002_client_alter_project_end_date_alter_project_name_and_more.cpython-311.pyc b/core/migrations/__pycache__/0002_client_alter_project_end_date_alter_project_name_and_more.cpython-311.pyc new file mode 100644 index 0000000..65e0b60 Binary files /dev/null and b/core/migrations/__pycache__/0002_client_alter_project_end_date_alter_project_name_and_more.cpython-311.pyc differ diff --git a/core/models.py b/core/models.py index 1aa45a7..4e3a136 100644 --- a/core/models.py +++ b/core/models.py @@ -1,17 +1,25 @@ from django.db import models +class Client(models.Model): + name = models.CharField(max_length=200, verbose_name="Client Name") + email = models.EmailField(max_length=200, verbose_name="Email", blank=True, null=True) + phone = models.CharField(max_length=20, verbose_name="Phone", blank=True, null=True) + + def __str__(self): + return self.name + class Project(models.Model): STATUS_CHOICES = [ - ('planowany', 'Planowany'), - ('realizowany', 'Realizowany'), - ('zakonczony', 'Zakończony'), + ('planning', 'Planning'), + ('in_progress', 'In Progress'), + ('completed', 'Completed'), ] - name = models.CharField(max_length=200, verbose_name="Nazwa projektu") - client = models.CharField(max_length=200, verbose_name="Kontrahent") - start_date = models.DateField(verbose_name="Data rozpoczęcia") - end_date = models.DateField(verbose_name="Data zakończenia") - status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='planowany', verbose_name="Status") + name = models.CharField(max_length=200, verbose_name="Project Name") + client = models.ForeignKey(Client, on_delete=models.CASCADE, related_name='projects', verbose_name="Client", null=True, blank=True) + start_date = models.DateField(verbose_name="Start Date") + end_date = models.DateField(verbose_name="End Date") + status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='planning', verbose_name="Status") def __str__(self): return self.name \ No newline at end of file diff --git a/core/templates/base.html b/core/templates/base.html index 19b1e50..35df213 100644 --- a/core/templates/base.html +++ b/core/templates/base.html @@ -33,7 +33,7 @@
  • Dashboard
  • Projects
  • Invoices
  • -
  • Clients
  • +
  • Clients
  • Settings