new
parent
3e79d5b4e2
commit
bff4bfacac
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,12 +1,23 @@
|
||||
from billing.models import *
|
||||
from osinacore.models import *
|
||||
from customercore.models import *
|
||||
from django.db.models import Count, Q
|
||||
|
||||
def utilities(request):
|
||||
active_subscriptions = None
|
||||
customer_open_tickets = None
|
||||
if request.user.is_authenticated and CustomerProfile.objects.filter(user=request.user):
|
||||
customer = request.user.customerprofile
|
||||
active_subscriptions = OrderItem.objects.filter(active=True, order__customer=customer)
|
||||
customer_open_tickets = Ticket.objects.filter(
|
||||
Q(status__in=['Open', 'Working On']) & Q(customer=request.user.customerprofile)
|
||||
).order_by('-id')
|
||||
|
||||
for ticket in customer_open_tickets:
|
||||
unread_updates_count = 0
|
||||
for ticket_update in ticket.ticketupdate_set.all():
|
||||
if not TicketRead.objects.filter(ticket_update=ticket_update, user=request.user, read=True).exists():
|
||||
unread_updates_count += 1
|
||||
ticket.unread_updates_count = unread_updates_count
|
||||
|
||||
|
||||
return {'active_subscriptions': active_subscriptions,}
|
||||
return {'active_subscriptions': active_subscriptions, 'customer_open_tickets': customer_open_tickets}
|
||||
|
@ -0,0 +1,26 @@
|
||||
# Generated by Django 4.2.5 on 2024-04-25 15:32
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('customercore', '0004_ticket_ticket_number_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='TicketStatusUpdate',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('status', models.CharField(choices=[('Open', 'Open'), ('Working On', 'Working On'), ('Closed', 'Closed')], max_length=50, null=True)),
|
||||
('date_added', models.DateTimeField()),
|
||||
('added_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
|
||||
('ticket', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='customercore.ticket')),
|
||||
],
|
||||
),
|
||||
]
|
@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.2.5 on 2024-04-25 16:02
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('customercore', '0005_ticketstatusupdate'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='ticketupdate',
|
||||
name='read',
|
||||
field=models.BooleanField(default=False, null=True),
|
||||
),
|
||||
]
|
@ -0,0 +1,29 @@
|
||||
# Generated by Django 4.2.5 on 2024-04-25 18:16
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('customercore', '0006_ticketupdate_read'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='ticketupdate',
|
||||
name='read',
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='TicketUpdateReadStatus',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('read', models.BooleanField(default=False)),
|
||||
('ticket_update', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='customercore.ticketupdate')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
]
|
@ -0,0 +1,19 @@
|
||||
# Generated by Django 4.2.5 on 2024-04-25 18:25
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('customercore', '0007_remove_ticketupdate_read_ticketupdatereadstatus'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameModel(
|
||||
old_name='TicketUpdateReadStatus',
|
||||
new_name='TicketRead',
|
||||
),
|
||||
]
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue