本文整理匯總了Python中core.models.Event.get_or_create_dummy方法的典型用法代碼示例。如果您正苦於以下問題:Python Event.get_or_create_dummy方法的具體用法?Python Event.get_or_create_dummy怎麽用?Python Event.get_or_create_dummy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類core.models.Event
的用法示例。
在下文中一共展示了Event.get_or_create_dummy方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_or_create_dummy
# 需要導入模塊: from core.models import Event [as 別名]
# 或者: from core.models.Event import get_or_create_dummy [as 別名]
def get_or_create_dummy(cls):
from core.models import Event
event, unused = Event.get_or_create_dummy()
admin_group, hosts_group = cls.get_or_create_groups(event, ["admins", "hosts"])
return cls.objects.get_or_create(event=event, defaults=dict(admin_group=admin_group, public=True))
示例2: get_or_create_dummy
# 需要導入模塊: from core.models import Event [as 別名]
# 或者: from core.models.Event import get_or_create_dummy [as 別名]
def get_or_create_dummy(cls):
from core.models import Event
event, unused = Event.get_or_create_dummy()
return cls.objects.get_or_create(
event=event,
name='Iso sali',
)
示例3: get_or_create_dummy
# 需要導入模塊: from core.models import Event [as 別名]
# 或者: from core.models.Event import get_or_create_dummy [as 別名]
def get_or_create_dummy(cls):
from django.contrib.auth.models import Group
from core.models import Event
group, unused = Group.objects.get_or_create(name='Dummy ticket admin group')
event, unused = Event.get_or_create_dummy()
return cls.objects.get_or_create(event=event, defaults=dict(admin_group=group))
示例4: get_or_create_dummies
# 需要導入模塊: from core.models import Event [as 別名]
# 或者: from core.models.Event import get_or_create_dummy [as 別名]
def get_or_create_dummies(cls):
from core.models import Event
event, unused = Event.get_or_create_dummy()
jc1, unused = cls.objects.get_or_create(event=event, name="Dummy 1", slug='dummy-1')
jc2, unused = cls.objects.get_or_create(event=event, name="Dummy 2", slug='dummy-2')
return [jc1, jc2]
示例5: get_or_create_dummy
# 需要導入模塊: from core.models import Event [as 別名]
# 或者: from core.models.Event import get_or_create_dummy [as 別名]
def get_or_create_dummy(cls):
from core.models import Event
event, unused = Event.get_or_create_dummy()
admin_group, organizer_group = cls.get_or_create_groups(event, ['admins', 'organizers'])
return cls.objects.get_or_create(event=event, defaults=dict(
admin_group=admin_group,
organizer_group=organizer_group,
))
示例6: get_or_create_dummies
# 需要導入模塊: from core.models import Event [as 別名]
# 或者: from core.models.Event import get_or_create_dummy [as 別名]
def get_or_create_dummies(cls):
from core.models import Event
event, unused = Event.get_or_create_dummy()
limit_saturday, unused = cls.objects.get_or_create(event=event, description='Testing saturday', defaults=dict(limit=5000))
limit_sunday, unused = cls.objects.get_or_create(event=event, description='Testing sunday', defaults=dict(limit=5000))
return [limit_saturday, limit_sunday]
示例7: test_event_filter
# 需要導入模塊: from core.models import Event [as 別名]
# 或者: from core.models.Event import get_or_create_dummy [as 別名]
def test_event_filter(self):
event, unused = Event.get_or_create_dummy()
event2, unused = Event.get_or_create_dummy(name='Dummy event 2')
kwargs = dict(
channel='callback',
callback_code=f'{__name__}:notification_callback',
)
subscription_with_event_filter, unused = Subscription.get_or_create_dummy(event_filter=event, **kwargs)
subscription_without_event_filter, unused = Subscription.get_or_create_dummy(event_filter=None, **kwargs)
entry_type = subscription_with_event_filter.entry_type
emit(entry_type, event=event)
emit(entry_type, event=event2)
assert len(notifications) == 3
示例8: get_or_create_dummy
# 需要導入模塊: from core.models import Event [as 別名]
# 或者: from core.models.Event import get_or_create_dummy [as 別名]
def get_or_create_dummy(cls, app_label='labour', name='Smallfolk', priority=0):
from core.models import Event
event, unused = Event.get_or_create_dummy()
return PersonnelClass.objects.get_or_create(
event=event,
slug=slugify(name),
app_label=app_label,
defaults=dict(
name=app_label,
priority=priority,
)
)
示例9: get_or_create_dummy
# 需要導入模塊: from core.models import Event [as 別名]
# 或者: from core.models.Event import get_or_create_dummy [as 別名]
def get_or_create_dummy(cls, event=None):
from django.contrib.auth.models import Group
from core.models import Event
if event is None:
event, unused = Event.get_or_create_dummy()
group, = PaymentsEventMeta.get_or_create_groups(event, ['admins'])
return cls.objects.get_or_create(event=event, defaults=dict(
EVENT_META_DEFAULTS,
admin_group=group,
))
示例10: get_or_create_dummy
# 需要導入模塊: from core.models import Event [as 別名]
# 或者: from core.models.Event import get_or_create_dummy [as 別名]
def get_or_create_dummy(cls):
from core.models import Event
from django.utils.timezone import now
event, unused = Event.get_or_create_dummy()
admin_group, hosts_group = cls.get_or_create_groups(event, ['admins', 'hosts'])
return cls.objects.get_or_create(
event=event,
defaults=dict(
admin_group=admin_group,
public_from=now(),
)
)
示例11: get_or_create_dummy
# 需要導入模塊: from core.models import Event [as 別名]
# 或者: from core.models.Event import get_or_create_dummy [as 別名]
def get_or_create_dummy(cls, event=None, title="Dummy survey", **kwargs):
if event is None:
from core.models import Event
event, unused = Event.get_or_create_dummy()
slug = slugify(title)
defaults = dict(
event=event,
title=title,
model=dict(),
)
defaults.update(kwargs)
return cls.objects.get_or_create(
slug=slug,
defaults=defaults,
)
示例12: get_or_create_dummy
# 需要導入模塊: from core.models import Event [as 別名]
# 或者: from core.models.Event import get_or_create_dummy [as 別名]
def get_or_create_dummy(cls, accepted=False):
from core.models import Person, Event
from .job_category import JobCategory
person, unused = Person.get_or_create_dummy()
event, unused = Event.get_or_create_dummy()
job_category, unused = JobCategory.get_or_create_dummy()
signup, created = Signup.objects.get_or_create(person=person, event=event)
if created:
signup.job_categories.set([job_category])
if accepted:
signup.job_categories_accepted.set(signup.job_categories.all())
signup.personnel_classes.add(signup.job_categories.first().personnel_classes.first())
signup.state = 'accepted'
signup.save()
signup.apply_state()
return signup, created
示例13: get_or_create_dummy
# 需要導入模塊: from core.models import Event [as 別名]
# 或者: from core.models.Event import get_or_create_dummy [as 別名]
def get_or_create_dummy(cls):
from core.models import Event
event, unused = Event.get_or_create_dummy()
group, = cls.get_or_create_groups(event, ['admins'])
return cls.objects.get_or_create(event=event, defaults=dict(admin_group=group))