diff --git a/crm/admin.py b/crm/admin.py index c6858ff..819de9a 100644 --- a/crm/admin.py +++ b/crm/admin.py @@ -11,9 +11,9 @@ from .models import ( @admin.register(Prospect) class ProspectAdmin(admin.ModelAdmin): - list_display = ('name', 'email', 'region', 'created_at') - list_filter = ('region', 'created_at') - search_fields = ('name', 'email', 'region') + list_display = ('entity_name', 'first_name', 'last_name', 'email', 'address', 'zip_code', 'city', 'created_at') + list_filter = ('zip_code', 'created_at') + search_fields = ('entity_name', 'first_name', 'last_name', 'email', 'zip_code', 'city') filter_horizontal = ('users',) date_hierarchy = 'created_at' diff --git a/crm/filters.py b/crm/filters.py index a78b63f..002ac07 100644 --- a/crm/filters.py +++ b/crm/filters.py @@ -3,16 +3,12 @@ import django_filters from .models import Event, Status, Prospect class ProspectFilter(django_filters.FilterSet): - region = django_filters.CharFilter(lookup_expr='icontains') + zip_code = django_filters.CharFilter(lookup_expr='icontains') events = django_filters.ModelMultipleChoiceFilter( queryset=Event.objects.all(), field_name='events', ) - statuses = django_filters.ModelMultipleChoiceFilter( - queryset=Status.objects.all(), - field_name='prospectstatus__status', - ) class Meta: model = Prospect - fields = ['region', 'events', 'statuses'] + fields = ['city', 'events'] diff --git a/crm/migrations/0003_remove_prospect_region_prospect_address_and_more.py b/crm/migrations/0003_remove_prospect_region_prospect_address_and_more.py new file mode 100644 index 0000000..7ed0884 --- /dev/null +++ b/crm/migrations/0003_remove_prospect_region_prospect_address_and_more.py @@ -0,0 +1,32 @@ +# Generated by Django 5.1 on 2024-12-16 15:43 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('crm', '0002_alter_event_options_alter_prospect_options_and_more'), + ] + + operations = [ + migrations.RemoveField( + model_name='prospect', + name='region', + ), + migrations.AddField( + model_name='prospect', + name='address', + field=models.CharField(blank=True, max_length=200, null=True), + ), + migrations.AddField( + model_name='prospect', + name='city', + field=models.CharField(blank=True, max_length=500, null=True), + ), + migrations.AddField( + model_name='prospect', + name='zip_code', + field=models.CharField(blank=True, max_length=20, null=True), + ), + ] diff --git a/crm/migrations/0004_remove_prospect_name_prospect_entity_name_and_more.py b/crm/migrations/0004_remove_prospect_name_prospect_entity_name_and_more.py new file mode 100644 index 0000000..47776b9 --- /dev/null +++ b/crm/migrations/0004_remove_prospect_name_prospect_entity_name_and_more.py @@ -0,0 +1,32 @@ +# Generated by Django 5.1 on 2024-12-16 16:24 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('crm', '0003_remove_prospect_region_prospect_address_and_more'), + ] + + operations = [ + migrations.RemoveField( + model_name='prospect', + name='name', + ), + migrations.AddField( + model_name='prospect', + name='entity_name', + field=models.CharField(blank=True, max_length=200, null=True), + ), + migrations.AddField( + model_name='prospect', + name='first_name', + field=models.CharField(blank=True, max_length=200, null=True), + ), + migrations.AddField( + model_name='prospect', + name='last_name', + field=models.CharField(blank=True, max_length=200, null=True), + ), + ] diff --git a/crm/migrations/0005_prospect_phone.py b/crm/migrations/0005_prospect_phone.py new file mode 100644 index 0000000..1b5a25f --- /dev/null +++ b/crm/migrations/0005_prospect_phone.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1 on 2024-12-16 16:49 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('crm', '0004_remove_prospect_name_prospect_entity_name_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='prospect', + name='phone', + field=models.CharField(blank=True, max_length=25, null=True), + ), + ] diff --git a/crm/models.py b/crm/models.py index e9be339..8baa4e9 100644 --- a/crm/models.py +++ b/crm/models.py @@ -12,8 +12,13 @@ class EventType(models.TextChoices): class Prospect(models.Model): email = models.EmailField(unique=True) - name = models.CharField(max_length=200) - region = models.CharField(max_length=100) + entity_name = models.CharField(max_length=200, null=True, blank=True) + first_name = models.CharField(max_length=200, null=True, blank=True) + last_name = models.CharField(max_length=200, null=True, blank=True) + address = models.CharField(max_length=200, null=True, blank=True) + zip_code = models.CharField(max_length=20, null=True, blank=True) + city = models.CharField(max_length=500, null=True, blank=True) + phone = models.CharField(max_length=25, null=True, blank=True) users = models.ManyToManyField(get_user_model(), blank=True) created_at = models.DateTimeField(auto_now_add=True) created_by = models.ForeignKey( @@ -37,7 +42,7 @@ class Prospect(models.Model): ] def __str__(self): - return f"{self.name} ({self.email})" + return ' - '.join(filter(None, [self.entity_name, self.first_name, self.last_name, f"({self.email})"])) class Status(models.Model): name = models.CharField(max_length=100, unique=True) diff --git a/crm/templates/crm/add_prospect.html b/crm/templates/crm/add_prospect.html index 01aeba1..0c60407 100644 --- a/crm/templates/crm/add_prospect.html +++ b/crm/templates/crm/add_prospect.html @@ -7,8 +7,18 @@