# Path: mqueue/models.py
# class MEvent(models.Model):
#     # required fields
#     content_type = models.ForeignKey(
#         ContentType,
#         null=True,
#         blank=True,
#         verbose_name=_("Content type"),
#         on_delete=SET_NULL,
#     )
#     obj_pk = models.IntegerField(
#         blank=True, null=True, verbose_name=_("Object primary key")
#     )
#     name = models.CharField(max_length=120, verbose_name=_("Name"))
#     # content fields
#     url = models.CharField(max_length=255, blank=True, verbose_name=_("Url"))
#     admin_url = models.CharField(
#         max_length=255, blank=True, verbose_name=_("Admin url")
#     )
#     notes = models.TextField(blank=True)
#     # meta
#     date_posted = models.DateTimeField(auto_now_add=True, verbose_name=_("Date posted"))
#     event_class = models.CharField(max_length=120, blank=True, verbose_name=_("Class"))
#     user = models.ForeignKey(
#         USER_MODEL,
#         null=True,
#         blank=True,
#         related_name="+",
#         on_delete=models.SET_NULL,
#         verbose_name=_("User"),
#     )
#     groups = models.ManyToManyField(
#         Group,
#         blank=True,
#         verbose_name=_("Groups"),
#     )
#     request = models.TextField(blank=True, verbose_name=_("Request"))
#     bucket = models.CharField(max_length=60, blank=True, verbose_name=_("Bucket"))
#     data = models.TextField(blank=True, verbose_name=_("Data"))
#     # manager
#     scope = models.CharField(
#         max_length=18,
#         choices=SCOPE,
#         default=SCOPE[0][0],
#         verbose_name=_("Scope"),
#     )
#     objects = MEventManager()
# 
#     class Meta:  # type: ignore
#         app_label = "mqueue"
#         verbose_name = _("Event")
#         verbose_name_plural = _("Events")
#         ordering = ["-date_posted"]
#         # permissions = (("view_mevent", "Can see Events"),)
# 
#     def __str__(self) -> str:
#         return f"{self.name} - {self.date_posted}"


import graphene
from graphene import relay
from graphene_django.types import DjangoObjectType
from graphene_django.filter import DjangoFilterConnectionField
from graphene_django.debug import DjangoDebug
from django.conf import settings
from .models import MEvent


class EventNode(DjangoObjectType):
    class Meta:
        model = MEvent
        only_fields = ("name", "event_class", "url", "date_posted", "data")
        filter_fields = {
            "name": ["exact", "icontains", "istartswith"],
            "event_class": ["exact", "icontains", "istartswith"],
            "date_posted": ["exact", "icontains", "istartswith"],
            "bucket": ["exact", "icontains", "istartswith"],
        }
        interfaces = (relay.Node,)


class StaffEventNode(DjangoObjectType):
    class Meta:

# Path: mqueue/models.py
# class MEvent(models.Model):
#     # required fields
#     content_type = models.ForeignKey(
#         ContentType,
#         null=True,
#         blank=True,
#         verbose_name=_("Content type"),
#         on_delete=SET_NULL,
#     )
#     obj_pk = models.IntegerField(
#         blank=True, null=True, verbose_name=_("Object primary key")
#     )
#     name = models.CharField(max_length=120, verbose_name=_("Name"))
#     # content fields
#     url = models.CharField(max_length=255, blank=True, verbose_name=_("Url"))
#     admin_url = models.CharField(
#         max_length=255, blank=True, verbose_name=_("Admin url")
#     )
#     notes = models.TextField(blank=True)
#     # meta
#     date_posted = models.DateTimeField(auto_now_add=True, verbose_name=_("Date posted"))
#     event_class = models.CharField(max_length=120, blank=True, verbose_name=_("Class"))
#     user = models.ForeignKey(
#         USER_MODEL,
#         null=True,
#         blank=True,
#         related_name="+",
#         on_delete=models.SET_NULL,
#         verbose_name=_("User"),
#     )
#     groups = models.ManyToManyField(
#         Group,
#         blank=True,
#         verbose_name=_("Groups"),
#     )
#     request = models.TextField(blank=True, verbose_name=_("Request"))
#     bucket = models.CharField(max_length=60, blank=True, verbose_name=_("Bucket"))
#     data = models.TextField(blank=True, verbose_name=_("Data"))
#     # manager
#     scope = models.CharField(
#         max_length=18,
#         choices=SCOPE,
#         default=SCOPE[0][0],
#         verbose_name=_("Scope"),
#     )
#     objects = MEventManager()
# 
#     class Meta:  # type: ignore
#         app_label = "mqueue"
#         verbose_name = _("Event")
#         verbose_name_plural = _("Events")
#         ordering = ["-date_posted"]
#         # permissions = (("view_mevent", "Can see Events"),)
# 
#     def __str__(self) -> str:
#         return f"{self.name} - {self.date_posted}"


# Path: mqueue/schema.py
import graphene
from graphene import relay
from graphene_django.types import DjangoObjectType
from graphene_django.filter import DjangoFilterConnectionField
from graphene_django.debug import DjangoDebug
from django.conf import settings
from .models import MEvent



class EventNode(DjangoObjectType):
    class Meta:
        model = MEvent
        only_fields = ("name", "event_class", "url", "date_posted", "data")
        filter_fields = {
            "name": ["exact", "icontains", "istartswith"],
            "event_class": ["exact", "icontains", "istartswith"],
            "date_posted": ["exact", "icontains", "istartswith"],
            "bucket": ["exact", "icontains", "istartswith"],
        }
        interfaces = (relay.Node,)


class StaffEventNode(DjangoObjectType):
    class Meta:

        model = MEvent