from django.contrib.auth.models import Group
from django.core.management import call_command


def helpdesk_group():
    helpdesk_groups = Group.objects.filter(
        permissions__codename="dashboard_access",
        permissions__content_type__app_label="partner",
        permissions__content_type__model="partner",
    )
    if not helpdesk_groups.exists():
        call_command("loaddata", "wagtail_oscar_integration/helpdesk")
        return "helpdesk group created"

    return "A helpdesk group allready exists %s" % helpdesk_groups
