Added filter functionality and combined both base.html
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def create_permissions(apps, schema_editor):
|
||||
EmployeePermission = apps.get_model('accounts', 'EmployeePermission')
|
||||
ClientPermission = apps.get_model('accounts', 'ClientPermission')
|
||||
|
||||
employee_permissions = [
|
||||
(1, 'can_manage_containers', 'Can manage containers'),
|
||||
(2, 'can_view_reports', 'Can view reports'),
|
||||
(3, 'can_handle_operations', 'Can handle operations'),
|
||||
]
|
||||
for _id, codename, name in employee_permissions:
|
||||
EmployeePermission.objects.create(id=_id, codename=codename, name=name)
|
||||
|
||||
client_permissions = [
|
||||
(1, 'can_view_booking', 'Can view booking'),
|
||||
(2, 'can_manage_booking', 'Can book container'),
|
||||
(3, 'can_view_preinfo', 'Can view preinfo'),
|
||||
(4, 'can_manage_preinfo', 'Can manage preinfo'),
|
||||
(5, 'can_view_payment', 'Can view payment'),
|
||||
(6, 'can_manage_payment', 'Can manage payment'),
|
||||
(7, 'can_manage_company_users', 'Can manage company users'),
|
||||
]
|
||||
for _id, codename, name in client_permissions:
|
||||
ClientPermission.objects.create(id=_id, codename=codename, name=name)
|
||||
|
||||
|
||||
def reverse_permissions(apps, schema_editor):
|
||||
EmployeePermission = apps.get_model('accounts', 'EmployeePermission')
|
||||
ClientPermission = apps.get_model('accounts', 'ClientPermission')
|
||||
|
||||
EmployeePermission.objects.all().delete()
|
||||
ClientPermission.objects.all().delete()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('accounts', '0007_auto_20250725_1920'), # Adjust this to your last migration
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(create_permissions, reverse_permissions),
|
||||
]
|
||||
@@ -0,0 +1,29 @@
|
||||
from django.db import migrations
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.hashers import make_password
|
||||
|
||||
def create_superuser(apps, schema_editor):
|
||||
User = apps.get_model('accounts', 'DepotUser')
|
||||
if not User.objects.filter(email=settings.ADMIN_USER_EMAIL).exists():
|
||||
user = User.objects.create(
|
||||
email=settings.ADMIN_USER_EMAIL,
|
||||
username=settings.ADMIN_USER_NAME,
|
||||
is_staff=True,
|
||||
is_superuser=True,
|
||||
is_active=True,
|
||||
user_type='AD',
|
||||
password=make_password(settings.ADMIN_USER_PASSWORD)
|
||||
)
|
||||
|
||||
def reverse_superuser(apps, schema_editor):
|
||||
User = apps.get_model('accounts', 'DepotUser')
|
||||
User.objects.filter(email=settings.ADMIN_USER_EMAIL).delete()
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('accounts', '0008_populate_permissions'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(create_superuser, reverse_superuser),
|
||||
]
|
||||
Reference in New Issue
Block a user