本文整理汇总了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))