signals.py 4.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. from django.contrib.auth.models import Group
  2. from django.dispatch import receiver
  3. from django.db.models.signals import post_migrate
  4. from tickets.models import TicketList
  5. @receiver(post_migrate)
  6. def create_initial_groups(sender, **kwargs):
  7. Group.objects.get_or_create(pk=21, name='METASERVICE-ADMIN')
  8. Group.objects.get_or_create(pk=22, name='METASERVICE-SUPERVISOR')
  9. Group.objects.get_or_create(pk=23, name='METASERVICE-SUPPORT')
  10. Group.objects.get_or_create(pk=24, name='METASERVICE-TECHSUPPORT')
  11. Group.objects.get_or_create(pk=31, name='PARTNER-ADMIN')
  12. Group.objects.get_or_create(pk=32, name='PARTNER-SUPERVISOR')
  13. Group.objects.get_or_create(pk=33, name='PARTNER-SUPPORT')
  14. Group.objects.get_or_create(pk=34, name='PARTNER-TECHSUPPORT')
  15. Group.objects.get_or_create(pk=41, name='PROVIDER')
  16. Group.objects.get_or_create(pk=51, name='CLIENT')
  17. Group.objects.get_or_create(pk=61, name='GUEST')
  18. @receiver(post_migrate)
  19. def create_initial_ticket_lists(sender, **kwargs):
  20. if sender.name == 'tickets':
  21. # METASERVICE
  22. ## ADMIN
  23. TicketList.objects.get_or_create(pk=2101, name='Активация партнеров (NEG_REQUEST)', group=Group.objects.get(name='METASERVICE-ADMIN'))
  24. TicketList.objects.get_or_create(pk=2102, name='Права в сервисе (ACCESS_REQUEST)', group=Group.objects.get(name='METASERVICE-ADMIN'))
  25. TicketList.objects.get_or_create(pk=2103, name='Проверка документов (ST_REQUEST)', group=Group.objects.get(name='METASERVICE-ADMIN'))
  26. ## SUPERVISOR
  27. TicketList.objects.get_or_create(pk=2201, name='Активность пользователей (ST_REQUEST)', group=Group.objects.get(name='METASERVICE-SUPERVISOR'))
  28. TicketList.objects.get_or_create(pk=2202, name='Оперативный доступ (ST_REQUEST)', group=Group.objects.get(name='METASERVICE-SUPERVISOR'))
  29. TicketList.objects.get_or_create(pk=2203, name='Оперативный доступ экстра (ACCESS_REQUEST)', group=Group.objects.get(name='METASERVICE-SUPERVISOR'))
  30. TicketList.objects.get_or_create(pk=2204, name='Права сервиса (ST_REQUEST)', group=Group.objects.get(name='METASERVICE-SUPERVISOR'))
  31. TicketList.objects.get_or_create(pk=2205, name='Проверка документов (ST_REQUEST)', group=Group.objects.get(name='METASERVICE-SUPERVISOR'))
  32. ## SUPPORT
  33. TicketList.objects.get_or_create(pk=2301, name='Входящие обычные заявки (ST_REQUEST)', group=Group.objects.get(name='METASERVICE-SUPPORT'))
  34. TicketList.objects.get_or_create(pk=2302, name='Заявки на услуги сервиса (SERVICE_REQUEST)', group=Group.objects.get(name='METASERVICE-SUPPORT'))
  35. ## TECHSUPPORT
  36. TicketList.objects.get_or_create(pk=2401, name='Входящие технические заявки (ST_REQUEST)', group=Group.objects.get(name='METASERVICE-TECHSUPPORT'))
  37. # PARTNER
  38. ## ADMIN
  39. TicketList.objects.get_or_create(pk=3101, name='Документы исполнителей (ST_REQUEST)', group=Group.objects.get(name='PARTNER-ADMIN'))
  40. TicketList.objects.get_or_create(pk=3102, name='Документы ресурсов (ST_REQUEST)', group=Group.objects.get(name='PARTNER-ADMIN'))
  41. TicketList.objects.get_or_create(pk=3103, name='Права в партнерке (ACCESS_REQUEST)', group=Group.objects.get(name='PARTNER-ADMIN'))
  42. ## SUPERVISOR
  43. TicketList.objects.get_or_create(pk=3201, name='Активность внутри партнера (ST_REQUEST)', group=Group.objects.get(name='PARTNER-SUPERVISOR'))
  44. TicketList.objects.get_or_create(pk=3202, name='Документы исполнителей (ST_REQUEST)', group=Group.objects.get(name='PARTNER-SUPERVISOR'))
  45. TicketList.objects.get_or_create(pk=3203, name='Документы ресурсов (ST_REQUEST)', group=Group.objects.get(name='PARTNER-SUPERVISOR'))
  46. TicketList.objects.get_or_create(pk=3204, name='Доступ внутри партнера (ST_REQUEST)', group=Group.objects.get(name='PARTNER-SUPERVISOR'))
  47. TicketList.objects.get_or_create(pk=3205, name='Оперативный доступ (ST_REQUEST)', group=Group.objects.get(name='PARTNER-SUPERVISOR'))
  48. TicketList.objects.get_or_create(pk=3206, name='Оперативный доступ экстра (ST_REQUEST)', group=Group.objects.get(name='PARTNER-SUPERVISOR'))
  49. TicketList.objects.get_or_create(pk=3207, name='Ручное подтверждение заявок (ACCESS-REQUEST)', group=Group.objects.get(name='PARTNER-SUPERVISOR'))
  50. ## TECHSUPPORT
  51. TicketList.objects.get_or_create(pk=3401, name='Входящие технические заявки (ST_REQUEST)', group=Group.objects.get(name='PARTNER-TECHSUPPORT'))